From 7a08d0368f067f46c05bd7075f098ac84a50d468 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 12 Mar 2025 19:38:09 +0000 Subject: [PATCH 1/3] Add an opt-out in pretty printing for RTN rendering --- compiler/rustc_hir_analysis/src/check/mod.rs | 5 +- compiler/rustc_middle/src/ty/print/pretty.rs | 117 ++++++++++++++---- .../src/error_reporting/traits/suggestions.rs | 7 +- .../return-type-notation/basic.without.stderr | 4 + .../return-type-notation/display.stderr | 8 ++ .../return-type-notation/rendering.fixed | 15 +++ .../return-type-notation/rendering.rs | 14 +++ .../return-type-notation/rendering.stderr | 12 ++ 8 files changed, 152 insertions(+), 30 deletions(-) create mode 100644 tests/ui/associated-type-bounds/return-type-notation/rendering.fixed create mode 100644 tests/ui/associated-type-bounds/return-type-notation/rendering.rs create mode 100644 tests/ui/associated-type-bounds/return-type-notation/rendering.stderr diff --git a/compiler/rustc_hir_analysis/src/check/mod.rs b/compiler/rustc_hir_analysis/src/check/mod.rs index 9c28fac809da7..b4a16b2b8054c 100644 --- a/compiler/rustc_hir_analysis/src/check/mod.rs +++ b/compiler/rustc_hir_analysis/src/check/mod.rs @@ -84,6 +84,7 @@ use rustc_infer::infer::{self, TyCtxtInferExt as _}; use rustc_infer::traits::ObligationCause; use rustc_middle::query::Providers; use rustc_middle::ty::error::{ExpectedFound, TypeError}; +use rustc_middle::ty::print::with_types_for_signature; use rustc_middle::ty::{self, GenericArgs, GenericArgsRef, Ty, TyCtxt, TypingMode}; use rustc_middle::{bug, span_bug}; use rustc_session::parse::feature_err; @@ -240,11 +241,11 @@ fn missing_items_err( (Vec::new(), Vec::new(), Vec::new()); for &trait_item in missing_items { - let snippet = suggestion_signature( + let snippet = with_types_for_signature!(suggestion_signature( tcx, trait_item, tcx.impl_trait_ref(impl_def_id).unwrap().instantiate_identity(), - ); + )); let code = format!("{padding}{snippet}\n{padding}"); if let Some(span) = tcx.hir().span_if_local(trait_item.def_id) { missing_trait_item_label diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 2a3a7705b7b60..72924c0dd4b27 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -63,6 +63,18 @@ thread_local! { static FORCE_TRIMMED_PATH: Cell = const { Cell::new(false) }; static REDUCED_QUERIES: Cell = const { Cell::new(false) }; static NO_VISIBLE_PATH: Cell = const { Cell::new(false) }; + static RTN_MODE: Cell = const { Cell::new(RtnMode::ForDiagnostic) }; +} + +/// Rendering style for RTN types. +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +pub enum RtnMode { + /// Print the RTN type as an impl trait with its path, i.e.e `impl Sized { T::method(..) }`. + ForDiagnostic, + /// Print the RTN type as an impl trait, i.e. `impl Sized`. + ForSignature, + /// Print the RTN type as a value path, i.e. `T::method(..): ...`. + ForSuggestion, } macro_rules! define_helper { @@ -124,6 +136,38 @@ define_helper!( fn with_no_visible_paths(NoVisibleGuard, NO_VISIBLE_PATH); ); +#[must_use] +pub struct RtnModeHelper(RtnMode); + +impl RtnModeHelper { + pub fn with(mode: RtnMode) -> RtnModeHelper { + RtnModeHelper(RTN_MODE.with(|c| c.replace(mode))) + } +} + +impl Drop for RtnModeHelper { + fn drop(&mut self) { + RTN_MODE.with(|c| c.set(self.0)) + } +} + +/// Print types for the purposes of a suggestion. +/// +/// Specifically, this will render RPITITs as `T::method(..)` which is suitable for +/// things like where-clauses. +pub macro with_types_for_suggestion($e:expr) {{ + let _guard = $crate::ty::print::pretty::RtnModeHelper::with(RtnMode::ForSuggestion); + $e +}} + +/// Print types for the purposes of a signature suggestion. +/// +/// Specifically, this will render RPITITs as `impl Trait` rather than `T::method(..)`. +pub macro with_types_for_signature($e:expr) {{ + let _guard = $crate::ty::print::pretty::RtnModeHelper::with(RtnMode::ForSignature); + $e +}} + /// Avoids running any queries during prints. pub macro with_no_queries($e:expr) {{ $crate::ty::print::with_reduced_queries!($crate::ty::print::with_forced_impl_filename_line!( @@ -1223,22 +1267,6 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { } } - if self.tcx().features().return_type_notation() - && let Some(ty::ImplTraitInTraitData::Trait { fn_def_id, .. }) = - self.tcx().opt_rpitit_info(def_id) - && let ty::Alias(_, alias_ty) = - self.tcx().fn_sig(fn_def_id).skip_binder().output().skip_binder().kind() - && alias_ty.def_id == def_id - && let generics = self.tcx().generics_of(fn_def_id) - // FIXME(return_type_notation): We only support lifetime params for now. - && generics.own_params.iter().all(|param| matches!(param.kind, ty::GenericParamDefKind::Lifetime)) - { - let num_args = generics.count(); - write!(self, " {{ ")?; - self.print_def_path(fn_def_id, &args[..num_args])?; - write!(self, "(..) }}")?; - } - Ok(()) } @@ -1306,6 +1334,46 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { ) } + fn pretty_print_rpitit( + &mut self, + def_id: DefId, + args: ty::GenericArgsRef<'tcx>, + ) -> Result<(), PrintError> { + let fn_args = if self.tcx().features().return_type_notation() + && let Some(ty::ImplTraitInTraitData::Trait { fn_def_id, .. }) = + self.tcx().opt_rpitit_info(def_id) + && let ty::Alias(_, alias_ty) = + self.tcx().fn_sig(fn_def_id).skip_binder().output().skip_binder().kind() + && alias_ty.def_id == def_id + && let generics = self.tcx().generics_of(fn_def_id) + // FIXME(return_type_notation): We only support lifetime params for now. + && generics.own_params.iter().all(|param| matches!(param.kind, ty::GenericParamDefKind::Lifetime)) + { + let num_args = generics.count(); + Some((fn_def_id, &args[..num_args])) + } else { + None + }; + + match (fn_args, RTN_MODE.with(|c| c.get())) { + (Some((fn_def_id, fn_args)), RtnMode::ForDiagnostic) => { + self.pretty_print_opaque_impl_type(def_id, args)?; + write!(self, " {{ ")?; + self.print_def_path(fn_def_id, fn_args)?; + write!(self, "(..) }}")?; + } + (Some((fn_def_id, fn_args)), RtnMode::ForSuggestion) => { + self.print_def_path(fn_def_id, fn_args)?; + write!(self, "(..)")?; + } + _ => { + self.pretty_print_opaque_impl_type(def_id, args)?; + } + } + + Ok(()) + } + fn ty_infer_name(&self, _: ty::TyVid) -> Option { None } @@ -3123,22 +3191,21 @@ define_print! { ty::AliasTerm<'tcx> { match self.kind(cx.tcx()) { ty::AliasTermKind::InherentTy => p!(pretty_print_inherent_projection(*self)), - ty::AliasTermKind::ProjectionTy - | ty::AliasTermKind::WeakTy - | ty::AliasTermKind::OpaqueTy - | ty::AliasTermKind::UnevaluatedConst - | ty::AliasTermKind::ProjectionConst => { - // If we're printing verbosely, or don't want to invoke queries - // (`is_impl_trait_in_trait`), then fall back to printing the def path. - // This is likely what you want if you're debugging the compiler anyways. + ty::AliasTermKind::ProjectionTy => { if !(cx.should_print_verbose() || with_reduced_queries()) && cx.tcx().is_impl_trait_in_trait(self.def_id) { - return cx.pretty_print_opaque_impl_type(self.def_id, self.args); + p!(pretty_print_rpitit(self.def_id, self.args)) } else { p!(print_def_path(self.def_id, self.args)); } } + | ty::AliasTermKind::WeakTy + | ty::AliasTermKind::OpaqueTy + | ty::AliasTermKind::UnevaluatedConst + | ty::AliasTermKind::ProjectionConst => { + p!(print_def_path(self.def_id, self.args)); + } } } diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index ad46a15a5ac6d..944196182f4ed 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -27,7 +27,7 @@ use rustc_middle::traits::IsConstable; use rustc_middle::ty::error::TypeError; use rustc_middle::ty::print::{ PrintPolyTraitPredicateExt as _, PrintPolyTraitRefExt, PrintTraitPredicateExt as _, - with_forced_trimmed_paths, with_no_trimmed_paths, + with_forced_trimmed_paths, with_no_trimmed_paths, with_types_for_suggestion, }; use rustc_middle::ty::{ self, AdtKind, GenericArgs, InferTy, IsSuggestable, Ty, TyCtxt, TypeFoldable, TypeFolder, @@ -111,7 +111,7 @@ impl<'a, 'tcx> CoroutineData<'a, 'tcx> { fn predicate_constraint(generics: &hir::Generics<'_>, pred: ty::Predicate<'_>) -> (Span, String) { ( generics.tail_span_for_predicate_suggestion(), - format!("{} {}", generics.add_where_or_trailing_comma(), pred), + with_types_for_suggestion!(format!("{} {}", generics.add_where_or_trailing_comma(), pred)), ) } @@ -137,7 +137,8 @@ pub fn suggest_restriction<'tcx, G: EmissionGuarantee>( if hir_generics.where_clause_span.from_expansion() || hir_generics.where_clause_span.desugaring_kind().is_some() || projection.is_some_and(|projection| { - tcx.is_impl_trait_in_trait(projection.def_id) + (tcx.is_impl_trait_in_trait(projection.def_id) + && !tcx.features().return_type_notation()) || tcx.lookup_stability(projection.def_id).is_some_and(|stab| stab.is_unstable()) }) { diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr b/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr index 0a31cc6753340..459f3ea164202 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr @@ -15,6 +15,10 @@ note: required by a bound in `is_send` | LL | fn is_send(_: impl Send) {} | ^^^^ required by this bound in `is_send` +help: consider further restricting the associated type + | +LL | >() where ::method(..): Send { + | ++++++++++++++++++++++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/associated-type-bounds/return-type-notation/display.stderr b/tests/ui/associated-type-bounds/return-type-notation/display.stderr index b895d79695272..a614089ce407a 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/display.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/display.stderr @@ -11,6 +11,10 @@ note: required by a bound in `needs_trait` | LL | fn needs_trait(_: impl Trait) {} | ^^^^^ required by this bound in `needs_trait` +help: consider further restricting the associated type + | +LL | fn foo(t: T) where ::method(..): Trait { + | +++++++++++++++++++++++++++++++++++++ error[E0277]: the trait bound `impl Sized { ::method_with_lt(..) }: Trait` is not satisfied --> $DIR/display.rs:16:17 @@ -25,6 +29,10 @@ note: required by a bound in `needs_trait` | LL | fn needs_trait(_: impl Trait) {} | ^^^^^ required by this bound in `needs_trait` +help: consider further restricting the associated type + | +LL | fn foo(t: T) where ::method_with_lt(..): Trait { + | +++++++++++++++++++++++++++++++++++++++++++++ error[E0277]: the trait bound `impl Sized: Trait` is not satisfied --> $DIR/display.rs:18:17 diff --git a/tests/ui/associated-type-bounds/return-type-notation/rendering.fixed b/tests/ui/associated-type-bounds/return-type-notation/rendering.fixed new file mode 100644 index 0000000000000..72c174a0ca020 --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/rendering.fixed @@ -0,0 +1,15 @@ +//@ run-rustfix + +#![allow(unused)] +#![feature(return_type_notation)] + +trait Foo { + fn missing() -> impl Sized; +} + +impl Foo for () { + //~^ ERROR not all trait items implemented, missing: `missing` +fn missing() -> impl Sized { todo!() } +} + +fn main() {} diff --git a/tests/ui/associated-type-bounds/return-type-notation/rendering.rs b/tests/ui/associated-type-bounds/return-type-notation/rendering.rs new file mode 100644 index 0000000000000..4c9948d4c0604 --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/rendering.rs @@ -0,0 +1,14 @@ +//@ run-rustfix + +#![allow(unused)] +#![feature(return_type_notation)] + +trait Foo { + fn missing() -> impl Sized; +} + +impl Foo for () { + //~^ ERROR not all trait items implemented, missing: `missing` +} + +fn main() {} diff --git a/tests/ui/associated-type-bounds/return-type-notation/rendering.stderr b/tests/ui/associated-type-bounds/return-type-notation/rendering.stderr new file mode 100644 index 0000000000000..62fdeb059dd84 --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/rendering.stderr @@ -0,0 +1,12 @@ +error[E0046]: not all trait items implemented, missing: `missing` + --> $DIR/rendering.rs:10:1 + | +LL | fn missing() -> impl Sized; + | --------------------------- `missing` from trait +... +LL | impl Foo for () { + | ^^^^^^^^^^^^^^^ missing `missing` in implementation + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0046`. From 61b6abdd117c6cdc5b0997e6fa0e37e167691933 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 12 Mar 2025 18:35:53 +0000 Subject: [PATCH 2/3] Stabilize RTN --- compiler/rustc_ast_lowering/src/lib.rs | 12 +-- compiler/rustc_ast_lowering/src/path.rs | 13 +-- compiler/rustc_ast_passes/src/feature_gate.rs | 1 - compiler/rustc_feature/src/accepted.rs | 2 + compiler/rustc_feature/src/unstable.rs | 2 - .../src/check/compare_impl_item.rs | 6 +- .../src/check/compare_impl_item/refine.rs | 5 +- compiler/rustc_hir_analysis/src/check/mod.rs | 6 +- compiler/rustc_lint/src/async_fn_in_trait.rs | 3 +- compiler/rustc_middle/src/ty/print/pretty.rs | 10 ++- compiler/rustc_parse/src/parser/path.rs | 2 - .../traits/fulfillment_errors.rs | 1 - .../src/error_reporting/traits/suggestions.rs | 88 +------------------ .../all-generics-lookup.rs | 2 - .../implied-from-self-where-clause.rs | 2 - .../bad-inputs-and-output.fixed | 2 +- .../bad-inputs-and-output.rs | 2 +- .../return-type-notation/bare-path.rs | 2 - .../return-type-notation/bare-path.stderr | 4 +- .../return-type-notation/basic.rs | 2 - .../return-type-notation/basic.without.stderr | 6 +- .../return-type-notation/display.rs | 2 - .../return-type-notation/display.stderr | 20 ++--- .../return-type-notation/equality.rs | 2 - .../return-type-notation/equality.stderr | 2 +- .../higher-ranked-bound-works.rs | 2 - .../impl-trait-in-trait.rs | 2 - .../impl-trait-in-trait.stderr | 8 +- .../issue-120208-higher-ranked-const.rs | 2 - .../issue-120208-higher-ranked-const.stderr | 2 +- .../return-type-notation/missing.rs | 2 - .../return-type-notation/missing.stderr | 2 +- .../namespace-conflict.rs | 2 - .../return-type-notation/non-rpitit.rs | 2 - .../return-type-notation/non-rpitit.stderr | 4 +- .../return-type-notation/not-a-method.rs | 2 - .../return-type-notation/not-a-method.stderr | 12 +-- .../return-type-notation/path-ambiguous.rs | 2 - .../path-ambiguous.stderr | 4 +- .../path-constrained-in-method.rs | 2 - .../path-higher-ranked.rs | 2 - .../path-higher-ranked.stderr | 4 +- .../return-type-notation/path-missing.rs | 2 - .../return-type-notation/path-missing.stderr | 6 +- .../return-type-notation/path-no-qself.rs | 2 - .../return-type-notation/path-no-qself.stderr | 2 +- .../path-non-param-qself.rs | 2 - .../path-non-param-qself.stderr | 6 +- .../return-type-notation/path-self-qself.rs | 2 - .../return-type-notation/path-type-param.rs | 2 - .../path-type-param.stderr | 4 +- .../return-type-notation/path-unsatisfied.rs | 2 - .../path-unsatisfied.stderr | 6 +- .../return-type-notation/path-works.rs | 2 - .../return-type-notation/rendering.fixed | 1 - .../return-type-notation/rendering.rs | 1 - .../return-type-notation/rendering.stderr | 2 +- ...project-to-specializable-projection.stderr | 2 +- .../in-trait/missing-send-bound.stderr | 11 ++- .../in-trait/send-on-async-fn-in-trait.fixed | 16 ++-- .../in-trait/send-on-async-fn-in-trait.rs | 10 ++- .../in-trait/send-on-async-fn-in-trait.stderr | 42 +++++---- .../send-on-foreign-async-fn-in-trait.rs | 2 +- .../send-on-foreign-async-fn-in-trait.stderr | 15 ++-- tests/ui/async-await/in-trait/warn.rs | 22 ----- tests/ui/async-await/in-trait/warn.stderr | 20 ----- .../issue-110963-early.rs | 2 - .../issue-110963-early.stderr | 4 +- .../return-type-notation/issue-110963-late.rs | 2 - ...ormalizing-self-auto-trait-issue-109924.rs | 2 - .../rtn-implied-in-supertrait.rs | 2 - .../rtn-in-impl-signature.rs | 2 - .../rtn-in-impl-signature.stderr | 4 +- .../super-method-bound-ambig.rs | 2 - .../super-method-bound-ambig.stderr | 2 +- .../super-method-bound.rs | 2 - .../return-type-notation/supertrait-bound.rs | 2 - .../return-type-notation/ty-or-ct-params.rs | 2 - .../ty-or-ct-params.stderr | 4 +- .../ui/borrowck/alias-liveness/rtn-static.rs | 2 - ...ature-gate-return_type_notation.cfg.stderr | 13 --- ...eature-gate-return_type_notation.no.stderr | 13 --- .../feature-gate-return_type_notation.rs | 13 --- .../check-wf-on-non-defaulted-rpitit.stderr | 4 + .../impl-trait/in-trait/issue-102571.stderr | 4 +- .../missing-static-bound-from-impl.rs | 2 +- .../missing-static-bound-from-impl.stderr | 6 +- .../in-trait/return-type-notation.rs | 2 - .../in-trait/return-type-notation.stderr | 8 +- .../in-trait/specialization-broken.stderr | 2 +- .../let-binding-init-expr-as-ty.stderr | 3 - 91 files changed, 147 insertions(+), 394 deletions(-) delete mode 100644 tests/ui/async-await/in-trait/warn.rs delete mode 100644 tests/ui/async-await/in-trait/warn.stderr delete mode 100644 tests/ui/feature-gates/feature-gate-return_type_notation.cfg.stderr delete mode 100644 tests/ui/feature-gates/feature-gate-return_type_notation.no.stderr delete mode 100644 tests/ui/feature-gates/feature-gate-return_type_notation.rs diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 1bf85bbf26c95..fa2b6fcca90e9 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -954,17 +954,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { } } }; - let mut err = self.dcx().create_err(err); - if !self.tcx.features().return_type_notation() - && self.tcx.sess.is_nightly_build() - { - add_feature_diagnostics( - &mut err, - &self.tcx.sess, - sym::return_type_notation, - ); - } - err.emit(); + self.dcx().emit_err(err); GenericArgsCtor { args: Default::default(), constraints: &[], diff --git a/compiler/rustc_ast_lowering/src/path.rs b/compiler/rustc_ast_lowering/src/path.rs index d00c797755f3f..f2ba05844e54e 100644 --- a/compiler/rustc_ast_lowering/src/path.rs +++ b/compiler/rustc_ast_lowering/src/path.rs @@ -6,7 +6,6 @@ use rustc_hir::GenericArg; use rustc_hir::def::{DefKind, PartialRes, Res}; use rustc_hir::def_id::DefId; use rustc_middle::span_bug; -use rustc_session::parse::add_feature_diagnostics; use rustc_span::{BytePos, DUMMY_SP, DesugaringKind, Ident, Span, Symbol, kw, sym}; use smallvec::{SmallVec, smallvec}; use tracing::{debug, instrument}; @@ -287,17 +286,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { } } }; - let mut err = self.dcx().create_err(err); - if !self.tcx.features().return_type_notation() - && self.tcx.sess.is_nightly_build() - { - add_feature_diagnostics( - &mut err, - &self.tcx.sess, - sym::return_type_notation, - ); - } - err.emit(); + self.dcx().emit_err(err); ( GenericArgsCtor { args: Default::default(), diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 31ff102c127a3..76b7682b1d88c 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -498,7 +498,6 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) { gate_all!(postfix_match, "postfix match is experimental"); gate_all!(mut_ref, "mutable by-reference bindings are experimental"); gate_all!(global_registration, "global registration is experimental"); - gate_all!(return_type_notation, "return type notation is experimental"); gate_all!(pin_ergonomics, "pinned reference syntax is experimental"); gate_all!(unsafe_fields, "`unsafe` fields are experimental"); gate_all!(unsafe_binders, "unsafe binder types are experimental"); diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index d50fe8c6a3e6b..5fd2be26a09fe 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -364,6 +364,8 @@ declare_features! ( (accepted, result_ffi_guarantees, "1.84.0", Some(110503)), /// Allows return-position `impl Trait` in traits. (accepted, return_position_impl_trait_in_trait, "1.75.0", Some(91611)), + /// Allows bounding the return type of AFIT/RPITIT. + (accepted, return_type_notation, "CURRENT_RUSTC_VERSION", Some(109417)), /// Allows code like `let x: &'static u32 = &42` to work (RFC 1414). (accepted, rvalue_static_promotion, "1.21.0", Some(38865)), /// Allows `Self` in type definitions (RFC 2300). diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 3c61bfd1c93f5..c7364fe96b7ca 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -616,8 +616,6 @@ declare_features! ( (incomplete, repr128, "1.16.0", Some(56071)), /// Allows `repr(simd)` and importing the various simd intrinsics. (unstable, repr_simd, "1.4.0", Some(27731)), - /// Allows bounding the return type of AFIT/RPITIT. - (unstable, return_type_notation, "1.70.0", Some(109417)), /// Allows `extern "rust-cold"`. (unstable, rust_cold_cc, "1.63.0", Some(97544)), /// Allows use of x86 SHA512, SM3 and SM4 target-features and intrinsics diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index c193aad2afd00..f754af186ea09 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -13,6 +13,7 @@ use rustc_infer::infer::{self, InferCtxt, TyCtxtInferExt}; use rustc_infer::traits::util; use rustc_middle::ty::error::{ExpectedFound, TypeError}; use rustc_middle::ty::fold::BottomUpFolder; +use rustc_middle::ty::print::with_types_for_signature; use rustc_middle::ty::util::ExplicitSelf; use rustc_middle::ty::{ self, GenericArgs, GenericParamDefKind, Ty, TyCtxt, TypeFoldable, TypeFolder, @@ -1058,11 +1059,12 @@ fn report_trait_method_mismatch<'tcx>( let ap = Applicability::MachineApplicable; match sig.decl.output { hir::FnRetTy::DefaultReturn(sp) => { - let sugg = format!(" -> {}", trait_sig.output()); + let sugg = + with_types_for_signature!(format!(" -> {}", trait_sig.output())); diag.span_suggestion_verbose(sp, msg, sugg, ap); } hir::FnRetTy::Return(hir_ty) => { - let sugg = trait_sig.output(); + let sugg = with_types_for_signature!(trait_sig.output().to_string()); diag.span_suggestion_verbose(hir_ty.span, msg, sugg, ap); } }; diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs index 4973d84895978..e5bb40b76deaf 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs @@ -6,6 +6,7 @@ use rustc_infer::infer::TyCtxtInferExt; use rustc_lint_defs::builtin::{REFINING_IMPL_TRAIT_INTERNAL, REFINING_IMPL_TRAIT_REACHABLE}; use rustc_middle::span_bug; use rustc_middle::traits::ObligationCause; +use rustc_middle::ty::print::with_types_for_signature; use rustc_middle::ty::{ self, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, TypingMode, @@ -333,7 +334,7 @@ fn report_mismatched_rpitit_signature<'tcx>( }); let span = unmatched_bound.unwrap_or(span); - tcx.emit_node_span_lint( + with_types_for_signature!(tcx.emit_node_span_lint( if is_internal { REFINING_IMPL_TRAIT_INTERNAL } else { REFINING_IMPL_TRAIT_REACHABLE }, tcx.local_def_id_to_hir_id(impl_m_def_id.expect_local()), span, @@ -345,7 +346,7 @@ fn report_mismatched_rpitit_signature<'tcx>( return_ty, unmatched_bound, }, - ); + )); } fn type_visibility<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option> { diff --git a/compiler/rustc_hir_analysis/src/check/mod.rs b/compiler/rustc_hir_analysis/src/check/mod.rs index b4a16b2b8054c..6e0eccac0523e 100644 --- a/compiler/rustc_hir_analysis/src/check/mod.rs +++ b/compiler/rustc_hir_analysis/src/check/mod.rs @@ -475,7 +475,11 @@ fn fn_sig_suggestion<'tcx>( "" }; - let output = if !output.is_unit() { format!(" -> {output}") } else { String::new() }; + let output = if !output.is_unit() { + with_types_for_signature!(format!(" -> {output}")) + } else { + String::new() + }; let safety = sig.safety.prefix_str(); let (generics, where_clauses) = bounds_from_generic_predicates(tcx, predicates); diff --git a/compiler/rustc_lint/src/async_fn_in_trait.rs b/compiler/rustc_lint/src/async_fn_in_trait.rs index 9923f05df3c73..a395b7c2df718 100644 --- a/compiler/rustc_lint/src/async_fn_in_trait.rs +++ b/compiler/rustc_lint/src/async_fn_in_trait.rs @@ -95,7 +95,8 @@ impl<'tcx> LateLintPass<'tcx> for AsyncFnInTrait { && let hir::IsAsync::Async(async_span) = sig.header.asyncness { // RTN can be used to bound `async fn` in traits in a better way than "always" - if cx.tcx.features().return_type_notation() { + // TODO: + if true { return; } diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 72924c0dd4b27..acaa0ec48904e 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -1339,15 +1339,17 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { def_id: DefId, args: ty::GenericArgsRef<'tcx>, ) -> Result<(), PrintError> { - let fn_args = if self.tcx().features().return_type_notation() - && let Some(ty::ImplTraitInTraitData::Trait { fn_def_id, .. }) = - self.tcx().opt_rpitit_info(def_id) + let fn_args = if let Some(ty::ImplTraitInTraitData::Trait { fn_def_id, .. }) = + self.tcx().opt_rpitit_info(def_id) && let ty::Alias(_, alias_ty) = self.tcx().fn_sig(fn_def_id).skip_binder().output().skip_binder().kind() && alias_ty.def_id == def_id && let generics = self.tcx().generics_of(fn_def_id) // FIXME(return_type_notation): We only support lifetime params for now. - && generics.own_params.iter().all(|param| matches!(param.kind, ty::GenericParamDefKind::Lifetime)) + && generics + .own_params + .iter() + .all(|param| matches!(param.kind, ty::GenericParamDefKind::Lifetime)) { let num_args = generics.count(); Some((fn_def_id, &args[..num_args])) diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index 9c6830c36727b..49e744aab6055 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -377,8 +377,6 @@ impl<'a> Parser<'a> { self.expect(exp!(CloseParen))?; let span = lo.to(self.prev_token.span); - self.psess.gated_spans.gate(sym::return_type_notation, span); - let prev_lo = self.prev_token.span.shrink_to_hi(); if self.eat_noexpect(&token::RArrow) { let lo = self.prev_token.span; diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index e2bdd52ba7c80..bad42c2cfae6e 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -524,7 +524,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { } self.explain_hrtb_projection(&mut err, leaf_trait_predicate, obligation.param_env, &obligation.cause); - self.suggest_desugaring_async_fn_in_trait(&mut err, main_trait_predicate); // Return early if the trait is Debug or Display and the invocation // originates within a standard library macro, because the output diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index 944196182f4ed..4a221a82897d3 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -137,9 +137,7 @@ pub fn suggest_restriction<'tcx, G: EmissionGuarantee>( if hir_generics.where_clause_span.from_expansion() || hir_generics.where_clause_span.desugaring_kind().is_some() || projection.is_some_and(|projection| { - (tcx.is_impl_trait_in_trait(projection.def_id) - && !tcx.features().return_type_notation()) - || tcx.lookup_stability(projection.def_id).is_some_and(|stab| stab.is_unstable()) + tcx.lookup_stability(projection.def_id).is_some_and(|stab| stab.is_unstable()) }) { return; @@ -4565,90 +4563,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { } } - pub(super) fn suggest_desugaring_async_fn_in_trait( - &self, - err: &mut Diag<'_>, - trait_pred: ty::PolyTraitPredicate<'tcx>, - ) { - // Don't suggest if RTN is active -- we should prefer a where-clause bound instead. - if self.tcx.features().return_type_notation() { - return; - } - - let trait_def_id = trait_pred.def_id(); - - // Only suggest specifying auto traits - if !self.tcx.trait_is_auto(trait_def_id) { - return; - } - - // Look for an RPITIT - let ty::Alias(ty::Projection, alias_ty) = trait_pred.self_ty().skip_binder().kind() else { - return; - }; - let Some(ty::ImplTraitInTraitData::Trait { fn_def_id, opaque_def_id }) = - self.tcx.opt_rpitit_info(alias_ty.def_id) - else { - return; - }; - - let auto_trait = self.tcx.def_path_str(trait_def_id); - // ... which is a local function - let Some(fn_def_id) = fn_def_id.as_local() else { - // If it's not local, we can at least mention that the method is async, if it is. - if self.tcx.asyncness(fn_def_id).is_async() { - err.span_note( - self.tcx.def_span(fn_def_id), - format!( - "`{}::{}` is an `async fn` in trait, which does not \ - automatically imply that its future is `{auto_trait}`", - alias_ty.trait_ref(self.tcx), - self.tcx.item_name(fn_def_id) - ), - ); - } - return; - }; - let hir::Node::TraitItem(item) = self.tcx.hir_node_by_def_id(fn_def_id) else { - return; - }; - - // ... whose signature is `async` (i.e. this is an AFIT) - let (sig, body) = item.expect_fn(); - let hir::FnRetTy::Return(hir::Ty { kind: hir::TyKind::OpaqueDef(opaq_def, ..), .. }) = - sig.decl.output - else { - // This should never happen, but let's not ICE. - return; - }; - - // Check that this is *not* a nested `impl Future` RPIT in an async fn - // (i.e. `async fn foo() -> impl Future`) - if opaq_def.def_id.to_def_id() != opaque_def_id { - return; - } - - let Some(sugg) = suggest_desugaring_async_fn_to_impl_future_in_trait( - self.tcx, - *sig, - *body, - opaque_def_id.expect_local(), - &format!(" + {auto_trait}"), - ) else { - return; - }; - - let function_name = self.tcx.def_path_str(fn_def_id); - err.multipart_suggestion( - format!( - "`{auto_trait}` can be made part of the associated future's \ - guarantees for all implementations of `{function_name}`" - ), - sugg, - Applicability::MachineApplicable, - ); - } - pub fn ty_kind_suggestion( &self, param_env: ty::ParamEnv<'tcx>, diff --git a/tests/ui/associated-type-bounds/all-generics-lookup.rs b/tests/ui/associated-type-bounds/all-generics-lookup.rs index c5940c14f440c..819dbf699fd31 100644 --- a/tests/ui/associated-type-bounds/all-generics-lookup.rs +++ b/tests/ui/associated-type-bounds/all-generics-lookup.rs @@ -1,7 +1,5 @@ //@ check-pass -#![feature(return_type_notation)] - trait Trait { fn method(&self) -> impl Sized; } diff --git a/tests/ui/associated-type-bounds/implied-from-self-where-clause.rs b/tests/ui/associated-type-bounds/implied-from-self-where-clause.rs index 38f556969140a..6c4523947a749 100644 --- a/tests/ui/associated-type-bounds/implied-from-self-where-clause.rs +++ b/tests/ui/associated-type-bounds/implied-from-self-where-clause.rs @@ -3,8 +3,6 @@ //@ check-pass -#![feature(return_type_notation)] - trait Foo where Self::method(..): Send, diff --git a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.fixed b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.fixed index 7af986267aa67..ecc18b678539d 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.fixed +++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.fixed @@ -1,6 +1,6 @@ //@ edition: 2021 //@ run-rustfix -#![feature(return_type_notation)] + #![allow(dead_code)] trait Trait { diff --git a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs index 983836e6433f0..0c32640771b83 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs @@ -1,6 +1,6 @@ //@ edition: 2021 //@ run-rustfix -#![feature(return_type_notation)] + #![allow(dead_code)] trait Trait { diff --git a/tests/ui/associated-type-bounds/return-type-notation/bare-path.rs b/tests/ui/associated-type-bounds/return-type-notation/bare-path.rs index 2bbeb62b922cb..db5d6732f42aa 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/bare-path.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/bare-path.rs @@ -1,5 +1,3 @@ -#![feature(return_type_notation)] - trait Tr { const CONST: usize; diff --git a/tests/ui/associated-type-bounds/return-type-notation/bare-path.stderr b/tests/ui/associated-type-bounds/return-type-notation/bare-path.stderr index 913f84b924c28..5c893a600aeff 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/bare-path.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/bare-path.stderr @@ -1,11 +1,11 @@ error: return type notation not allowed in this position yet - --> $DIR/bare-path.rs:14:23 + --> $DIR/bare-path.rs:12:23 | LL | let _ = T::CONST::(..); | ^^^^ error: return type notation not allowed in this position yet - --> $DIR/bare-path.rs:16:12 + --> $DIR/bare-path.rs:14:12 | LL | let _: T::method(..); | ^^^^^^^^^^^^^ diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.rs b/tests/ui/associated-type-bounds/return-type-notation/basic.rs index cb5872dff444c..8259093910a19 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/basic.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.rs @@ -2,8 +2,6 @@ //@ edition: 2021 //@ [with] check-pass -#![feature(return_type_notation)] - trait Foo { async fn method() -> Result<(), ()>; } diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr b/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr index 459f3ea164202..9a2aec6d516c6 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr @@ -1,17 +1,17 @@ error: future cannot be sent between threads safely - --> $DIR/basic.rs:22:13 + --> $DIR/basic.rs:20:13 | LL | is_send(foo::()); | ^^^^^^^^^^ future returned by `foo` is not `Send` | = help: within `impl Future>`, the trait `Send` is not implemented for `impl Future> { ::method(..) }` note: future is not `Send` as it awaits another future which is not `Send` - --> $DIR/basic.rs:12:5 + --> $DIR/basic.rs:10:5 | LL | T::method().await?; | ^^^^^^^^^^^ await occurs here on type `impl Future> { ::method(..) }`, which is not `Send` note: required by a bound in `is_send` - --> $DIR/basic.rs:16:20 + --> $DIR/basic.rs:14:20 | LL | fn is_send(_: impl Send) {} | ^^^^ required by this bound in `is_send` diff --git a/tests/ui/associated-type-bounds/return-type-notation/display.rs b/tests/ui/associated-type-bounds/return-type-notation/display.rs index 2d613b71c55d2..a4334f238843b 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/display.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/display.rs @@ -1,5 +1,3 @@ -#![feature(return_type_notation)] - trait Trait {} fn needs_trait(_: impl Trait) {} diff --git a/tests/ui/associated-type-bounds/return-type-notation/display.stderr b/tests/ui/associated-type-bounds/return-type-notation/display.stderr index a614089ce407a..24c4bb332f331 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/display.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/display.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `impl Sized { ::method(..) }: Trait` is not satisfied - --> $DIR/display.rs:14:17 + --> $DIR/display.rs:12:17 | LL | needs_trait(T::method()); | ----------- ^^^^^^^^^^^ the trait `Trait` is not implemented for `impl Sized { ::method(..) }` @@ -7,7 +7,7 @@ LL | needs_trait(T::method()); | required by a bound introduced by this call | note: required by a bound in `needs_trait` - --> $DIR/display.rs:4:24 + --> $DIR/display.rs:2:24 | LL | fn needs_trait(_: impl Trait) {} | ^^^^^ required by this bound in `needs_trait` @@ -17,7 +17,7 @@ LL | fn foo(t: T) where ::method(..): Trait { | +++++++++++++++++++++++++++++++++++++ error[E0277]: the trait bound `impl Sized { ::method_with_lt(..) }: Trait` is not satisfied - --> $DIR/display.rs:16:17 + --> $DIR/display.rs:14:17 | LL | needs_trait(T::method_with_lt()); | ----------- ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `impl Sized { ::method_with_lt(..) }` @@ -25,7 +25,7 @@ LL | needs_trait(T::method_with_lt()); | required by a bound introduced by this call | note: required by a bound in `needs_trait` - --> $DIR/display.rs:4:24 + --> $DIR/display.rs:2:24 | LL | fn needs_trait(_: impl Trait) {} | ^^^^^ required by this bound in `needs_trait` @@ -35,7 +35,7 @@ LL | fn foo(t: T) where ::method_with_lt(..): Trait { | +++++++++++++++++++++++++++++++++++++++++++++ error[E0277]: the trait bound `impl Sized: Trait` is not satisfied - --> $DIR/display.rs:18:17 + --> $DIR/display.rs:16:17 | LL | needs_trait(T::method_with_ty()); | ----------- ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `impl Sized` @@ -43,18 +43,18 @@ LL | needs_trait(T::method_with_ty()); | required by a bound introduced by this call | help: this trait has no implementations, consider adding one - --> $DIR/display.rs:3:1 + --> $DIR/display.rs:1:1 | LL | trait Trait {} | ^^^^^^^^^^^ note: required by a bound in `needs_trait` - --> $DIR/display.rs:4:24 + --> $DIR/display.rs:2:24 | LL | fn needs_trait(_: impl Trait) {} | ^^^^^ required by this bound in `needs_trait` error[E0277]: the trait bound `impl Sized: Trait` is not satisfied - --> $DIR/display.rs:20:17 + --> $DIR/display.rs:18:17 | LL | needs_trait(T::method_with_ct()); | ----------- ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `impl Sized` @@ -62,12 +62,12 @@ LL | needs_trait(T::method_with_ct()); | required by a bound introduced by this call | help: this trait has no implementations, consider adding one - --> $DIR/display.rs:3:1 + --> $DIR/display.rs:1:1 | LL | trait Trait {} | ^^^^^^^^^^^ note: required by a bound in `needs_trait` - --> $DIR/display.rs:4:24 + --> $DIR/display.rs:2:24 | LL | fn needs_trait(_: impl Trait) {} | ^^^^^ required by this bound in `needs_trait` diff --git a/tests/ui/associated-type-bounds/return-type-notation/equality.rs b/tests/ui/associated-type-bounds/return-type-notation/equality.rs index cff0df58b7496..2aaceb5272518 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/equality.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/equality.rs @@ -1,7 +1,5 @@ //@ edition: 2021 -#![feature(return_type_notation)] - use std::future::Future; trait Trait { diff --git a/tests/ui/associated-type-bounds/return-type-notation/equality.stderr b/tests/ui/associated-type-bounds/return-type-notation/equality.stderr index 870f17ee70d2e..40ba3c78c1c94 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/equality.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/equality.stderr @@ -1,5 +1,5 @@ error: return type notation is not allowed to use type equality - --> $DIR/equality.rs:11:18 + --> $DIR/equality.rs:9:18 | LL | fn test>>>() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/associated-type-bounds/return-type-notation/higher-ranked-bound-works.rs b/tests/ui/associated-type-bounds/return-type-notation/higher-ranked-bound-works.rs index c6ae6690c72f5..0cf065186a7ea 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/higher-ranked-bound-works.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/higher-ranked-bound-works.rs @@ -1,7 +1,5 @@ //@ check-pass -#![feature(return_type_notation)] - trait Trait<'a> { fn late<'b>(&'b self, _: &'a ()) -> impl Sized; fn early<'b: 'b>(&'b self, _: &'a ()) -> impl Sized; diff --git a/tests/ui/associated-type-bounds/return-type-notation/impl-trait-in-trait.rs b/tests/ui/associated-type-bounds/return-type-notation/impl-trait-in-trait.rs index 0d3e6f9c8e3ab..fd239d226ab2b 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/impl-trait-in-trait.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/impl-trait-in-trait.rs @@ -1,5 +1,3 @@ -#![feature(return_type_notation)] - trait IntFactory { fn stream(self) -> impl IntFactory; //~^ ERROR cycle detected when resolving lifetimes for `IntFactory::stream` diff --git a/tests/ui/associated-type-bounds/return-type-notation/impl-trait-in-trait.stderr b/tests/ui/associated-type-bounds/return-type-notation/impl-trait-in-trait.stderr index 0ed54415b9e04..10f159cecf727 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/impl-trait-in-trait.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/impl-trait-in-trait.stderr @@ -1,22 +1,22 @@ error[E0391]: cycle detected when resolving lifetimes for `IntFactory::stream` - --> $DIR/impl-trait-in-trait.rs:4:5 + --> $DIR/impl-trait-in-trait.rs:2:5 | LL | fn stream(self) -> impl IntFactory; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: ...which requires computing function signature of `IntFactory::stream`... - --> $DIR/impl-trait-in-trait.rs:4:5 + --> $DIR/impl-trait-in-trait.rs:2:5 | LL | fn stream(self) -> impl IntFactory; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires looking up late bound vars inside `IntFactory::stream`... - --> $DIR/impl-trait-in-trait.rs:4:5 + --> $DIR/impl-trait-in-trait.rs:2:5 | LL | fn stream(self) -> impl IntFactory; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which again requires resolving lifetimes for `IntFactory::stream`, completing the cycle note: cycle used when listing captured lifetimes for opaque `IntFactory::stream::{opaque#0}` - --> $DIR/impl-trait-in-trait.rs:4:24 + --> $DIR/impl-trait-in-trait.rs:2:24 | LL | fn stream(self) -> impl IntFactory; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/associated-type-bounds/return-type-notation/issue-120208-higher-ranked-const.rs b/tests/ui/associated-type-bounds/return-type-notation/issue-120208-higher-ranked-const.rs index 69d0b4b1f8ac4..95d01d99b23e2 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/issue-120208-higher-ranked-const.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/issue-120208-higher-ranked-const.rs @@ -1,7 +1,5 @@ //@ edition: 2021 -#![feature(return_type_notation)] - trait HealthCheck { async fn check() -> bool; } diff --git a/tests/ui/associated-type-bounds/return-type-notation/issue-120208-higher-ranked-const.stderr b/tests/ui/associated-type-bounds/return-type-notation/issue-120208-higher-ranked-const.stderr index 2abf47f002672..49cbd920f5c22 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/issue-120208-higher-ranked-const.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/issue-120208-higher-ranked-const.stderr @@ -1,5 +1,5 @@ error: return type notation is not allowed for functions that have const parameters - --> $DIR/issue-120208-higher-ranked-const.rs:11:21 + --> $DIR/issue-120208-higher-ranked-const.rs:9:21 | LL | async fn check() -> bool; | -------------- const parameter declared here diff --git a/tests/ui/associated-type-bounds/return-type-notation/missing.rs b/tests/ui/associated-type-bounds/return-type-notation/missing.rs index e116ae0ca3bb4..442f3aa1c6903 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/missing.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/missing.rs @@ -1,7 +1,5 @@ //@ edition: 2021 -#![feature(return_type_notation)] - trait Trait { async fn method() {} } diff --git a/tests/ui/associated-type-bounds/return-type-notation/missing.stderr b/tests/ui/associated-type-bounds/return-type-notation/missing.stderr index 0eb965603439c..2b7ae28040b02 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/missing.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/missing.stderr @@ -1,5 +1,5 @@ error[E0220]: associated function `methid` not found for `Trait` - --> $DIR/missing.rs:9:17 + --> $DIR/missing.rs:7:17 | LL | fn bar>() {} | ^^^^^^ help: there is an associated function with a similar name: `method` diff --git a/tests/ui/associated-type-bounds/return-type-notation/namespace-conflict.rs b/tests/ui/associated-type-bounds/return-type-notation/namespace-conflict.rs index 8dfc2376fbd4e..262751cf605d4 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/namespace-conflict.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/namespace-conflict.rs @@ -1,8 +1,6 @@ //@ check-pass #![allow(non_camel_case_types)] -#![feature(return_type_notation)] - trait Foo { type test; diff --git a/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.rs b/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.rs index 0e9dd90095286..4a8ae30037bfc 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.rs @@ -1,5 +1,3 @@ -#![feature(return_type_notation)] - trait Trait { fn method() {} } diff --git a/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.stderr b/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.stderr index 4d3dac2d168f7..9f477f3abd903 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.stderr @@ -1,5 +1,5 @@ error: return type notation used on function that is not `async` and does not return `impl Trait` - --> $DIR/non-rpitit.rs:7:19 + --> $DIR/non-rpitit.rs:5:19 | LL | fn method() {} | ----------- this function must be `async` or return `impl Trait` @@ -10,7 +10,7 @@ LL | fn bound>() {} = note: function returns `()`, which is not compatible with associated type return bounds error: return type notation used on function that is not `async` and does not return `impl Trait` - --> $DIR/non-rpitit.rs:10:30 + --> $DIR/non-rpitit.rs:8:30 | LL | fn method() {} | ----------- this function must be `async` or return `impl Trait` diff --git a/tests/ui/associated-type-bounds/return-type-notation/not-a-method.rs b/tests/ui/associated-type-bounds/return-type-notation/not-a-method.rs index 89a414a3bc863..017cb38f4b021 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/not-a-method.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/not-a-method.rs @@ -1,5 +1,3 @@ -#![feature(return_type_notation)] - fn function() {} fn not_a_method() diff --git a/tests/ui/associated-type-bounds/return-type-notation/not-a-method.stderr b/tests/ui/associated-type-bounds/return-type-notation/not-a-method.stderr index ab987ee48e6c8..80598e6ab72ff 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/not-a-method.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/not-a-method.stderr @@ -1,35 +1,35 @@ error[E0575]: expected function, found function `function` - --> $DIR/not-a-method.rs:7:5 + --> $DIR/not-a-method.rs:5:5 | LL | function(..): Send, | ^^^^^^^^^^^^ not a function error[E0573]: expected type, found function `function` - --> $DIR/not-a-method.rs:15:5 + --> $DIR/not-a-method.rs:13:5 | LL | function(): Send, | ^^^^^^^^^^ not a type error[E0576]: cannot find function `method` in this scope - --> $DIR/not-a-method.rs:27:5 + --> $DIR/not-a-method.rs:25:5 | LL | method(..): Send, | ^^^^^^ not found in this scope error[E0412]: cannot find type `method` in this scope - --> $DIR/not-a-method.rs:36:5 + --> $DIR/not-a-method.rs:34:5 | LL | method(): Send, | ^^^^^^ not found in this scope error: return type notation not allowed in this position yet - --> $DIR/not-a-method.rs:7:5 + --> $DIR/not-a-method.rs:5:5 | LL | function(..): Send, | ^^^^^^^^^^^^ error: return type notation not allowed in this position yet - --> $DIR/not-a-method.rs:27:5 + --> $DIR/not-a-method.rs:25:5 | LL | method(..): Send, | ^^^^^^^^^^ diff --git a/tests/ui/associated-type-bounds/return-type-notation/path-ambiguous.rs b/tests/ui/associated-type-bounds/return-type-notation/path-ambiguous.rs index f9aba1754653a..9b4a73a7aeb11 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/path-ambiguous.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/path-ambiguous.rs @@ -1,5 +1,3 @@ -#![feature(return_type_notation)] - trait A { fn method() -> impl Sized; } diff --git a/tests/ui/associated-type-bounds/return-type-notation/path-ambiguous.stderr b/tests/ui/associated-type-bounds/return-type-notation/path-ambiguous.stderr index 12f6762cb5171..c45e83a6360a6 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/path-ambiguous.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/path-ambiguous.stderr @@ -1,5 +1,5 @@ error[E0221]: ambiguous associated function `method` in bounds of `T` - --> $DIR/path-ambiguous.rs:12:5 + --> $DIR/path-ambiguous.rs:10:5 | LL | fn method() -> impl Sized; | -------------------------- ambiguous `method` from `A` @@ -22,7 +22,7 @@ LL + ::method(..): Send, | error[E0221]: ambiguous associated function `method` in bounds of `T` - --> $DIR/path-ambiguous.rs:21:5 + --> $DIR/path-ambiguous.rs:19:5 | LL | fn method() -> impl Sized; | -------------------------- ambiguous `method` from `A` diff --git a/tests/ui/associated-type-bounds/return-type-notation/path-constrained-in-method.rs b/tests/ui/associated-type-bounds/return-type-notation/path-constrained-in-method.rs index d8bdec0910752..1d9c39e3eb534 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/path-constrained-in-method.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/path-constrained-in-method.rs @@ -1,7 +1,5 @@ //@ check-pass -#![feature(return_type_notation)] - trait Trait { fn method() -> impl Sized; } diff --git a/tests/ui/associated-type-bounds/return-type-notation/path-higher-ranked.rs b/tests/ui/associated-type-bounds/return-type-notation/path-higher-ranked.rs index 8591357dd9eaa..fbb9ff5bf43f9 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/path-higher-ranked.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/path-higher-ranked.rs @@ -1,5 +1,3 @@ -#![feature(return_type_notation)] - trait A<'a> { fn method() -> impl Sized; } diff --git a/tests/ui/associated-type-bounds/return-type-notation/path-higher-ranked.stderr b/tests/ui/associated-type-bounds/return-type-notation/path-higher-ranked.stderr index b3a229c58c815..c75f66f796ffb 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/path-higher-ranked.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/path-higher-ranked.stderr @@ -1,5 +1,5 @@ error[E0212]: cannot use the associated function of a trait with uninferred generic parameters - --> $DIR/path-higher-ranked.rs:11:5 + --> $DIR/path-higher-ranked.rs:9:5 | LL | T::method(..): Send, | ^^^^^^^^^^^^^ @@ -11,7 +11,7 @@ LL + >::method(..): Send, | error[E0212]: cannot use the associated function of a trait with uninferred generic parameters - --> $DIR/path-higher-ranked.rs:19:5 + --> $DIR/path-higher-ranked.rs:17:5 | LL | T::method(..): Send, | ^^^^^^^^^^^^^ diff --git a/tests/ui/associated-type-bounds/return-type-notation/path-missing.rs b/tests/ui/associated-type-bounds/return-type-notation/path-missing.rs index 8cab48bd0c454..2d3f15af344e5 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/path-missing.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/path-missing.rs @@ -1,5 +1,3 @@ -#![feature(return_type_notation)] - trait A { #[allow(non_camel_case_types)] type bad; diff --git a/tests/ui/associated-type-bounds/return-type-notation/path-missing.stderr b/tests/ui/associated-type-bounds/return-type-notation/path-missing.stderr index edac09db89dae..216ef08058564 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/path-missing.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/path-missing.stderr @@ -1,11 +1,11 @@ error[E0576]: cannot find method or associated constant `method` in trait `A` - --> $DIR/path-missing.rs:10:15 + --> $DIR/path-missing.rs:8:15 | LL | ::method(..): Send, | ^^^^^^ not found in `A` error[E0575]: expected method or associated constant, found associated type `A::bad` - --> $DIR/path-missing.rs:12:5 + --> $DIR/path-missing.rs:10:5 | LL | ::bad(..): Send, | ^^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ LL | ::bad(..): Send, = note: can't use a type alias as a constructor error[E0220]: associated function `method` not found for `T` - --> $DIR/path-missing.rs:19:8 + --> $DIR/path-missing.rs:17:8 | LL | T::method(..): Send, | ^^^^^^ associated function `method` not found diff --git a/tests/ui/associated-type-bounds/return-type-notation/path-no-qself.rs b/tests/ui/associated-type-bounds/return-type-notation/path-no-qself.rs index 17a3d0f7af675..f2bbd222bf156 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/path-no-qself.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/path-no-qself.rs @@ -1,5 +1,3 @@ -#![feature(return_type_notation)] - trait Trait { fn method() -> impl Sized; } diff --git a/tests/ui/associated-type-bounds/return-type-notation/path-no-qself.stderr b/tests/ui/associated-type-bounds/return-type-notation/path-no-qself.stderr index aad6dfc496b75..33f3a4871fb84 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/path-no-qself.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/path-no-qself.stderr @@ -1,5 +1,5 @@ error[E0223]: ambiguous associated type - --> $DIR/path-no-qself.rs:9:5 + --> $DIR/path-no-qself.rs:7:5 | LL | Trait::method(..): Send, | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/associated-type-bounds/return-type-notation/path-non-param-qself.rs b/tests/ui/associated-type-bounds/return-type-notation/path-non-param-qself.rs index 8107772f151ef..19bcdb2848a9c 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/path-non-param-qself.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/path-non-param-qself.rs @@ -1,5 +1,3 @@ -#![feature(return_type_notation)] - trait Trait { fn method() -> impl Sized; } diff --git a/tests/ui/associated-type-bounds/return-type-notation/path-non-param-qself.stderr b/tests/ui/associated-type-bounds/return-type-notation/path-non-param-qself.stderr index 38202bdbf0727..385eb9578000e 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/path-non-param-qself.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/path-non-param-qself.stderr @@ -1,17 +1,17 @@ error[E0223]: ambiguous associated function - --> $DIR/path-non-param-qself.rs:11:5 + --> $DIR/path-non-param-qself.rs:9:5 | LL | <()>::method(..): Send, | ^^^^^^^^^^^^^^^^ error[E0223]: ambiguous associated function - --> $DIR/path-non-param-qself.rs:13:5 + --> $DIR/path-non-param-qself.rs:11:5 | LL | i32::method(..): Send, | ^^^^^^^^^^^^^^^ error[E0223]: ambiguous associated function - --> $DIR/path-non-param-qself.rs:15:5 + --> $DIR/path-non-param-qself.rs:13:5 | LL | Adt::method(..): Send, | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/associated-type-bounds/return-type-notation/path-self-qself.rs b/tests/ui/associated-type-bounds/return-type-notation/path-self-qself.rs index d805556f4c720..5e010c394b17d 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/path-self-qself.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/path-self-qself.rs @@ -1,7 +1,5 @@ //@ check-pass -#![feature(return_type_notation)] - trait Foo { fn method() -> impl Sized; } diff --git a/tests/ui/associated-type-bounds/return-type-notation/path-type-param.rs b/tests/ui/associated-type-bounds/return-type-notation/path-type-param.rs index 6e2355c389b88..97ac8fdc171e0 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/path-type-param.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/path-type-param.rs @@ -1,5 +1,3 @@ -#![feature(return_type_notation)] - trait Foo { fn method() -> impl Sized; } diff --git a/tests/ui/associated-type-bounds/return-type-notation/path-type-param.stderr b/tests/ui/associated-type-bounds/return-type-notation/path-type-param.stderr index 67e83060a76b2..9b88e1a5dab2c 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/path-type-param.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/path-type-param.stderr @@ -1,5 +1,5 @@ error: return type notation is not allowed for functions that have type parameters - --> $DIR/path-type-param.rs:9:5 + --> $DIR/path-type-param.rs:7:5 | LL | fn method() -> impl Sized; | - type parameter declared here @@ -8,7 +8,7 @@ LL | ::method(..): Send, | ^^^^^^^^^^^^^^^^^^^^^^ error: return type notation is not allowed for functions that have type parameters - --> $DIR/path-type-param.rs:16:5 + --> $DIR/path-type-param.rs:14:5 | LL | fn method() -> impl Sized; | - type parameter declared here diff --git a/tests/ui/associated-type-bounds/return-type-notation/path-unsatisfied.rs b/tests/ui/associated-type-bounds/return-type-notation/path-unsatisfied.rs index c9cb0f953e26b..a4eea3f445a3b 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/path-unsatisfied.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/path-unsatisfied.rs @@ -1,5 +1,3 @@ -#![feature(return_type_notation)] - trait Trait { fn method() -> impl Sized; } diff --git a/tests/ui/associated-type-bounds/return-type-notation/path-unsatisfied.stderr b/tests/ui/associated-type-bounds/return-type-notation/path-unsatisfied.stderr index 90d0feb521743..759f9a891dd95 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/path-unsatisfied.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/path-unsatisfied.stderr @@ -1,5 +1,5 @@ error[E0277]: `*mut ()` cannot be sent between threads safely - --> $DIR/path-unsatisfied.rs:22:12 + --> $DIR/path-unsatisfied.rs:20:12 | LL | fn method() -> impl Sized { | ---------- within this `impl Sized` @@ -9,12 +9,12 @@ LL | test::(); | = help: within `impl Sized`, the trait `Send` is not implemented for `*mut ()` note: required because it appears within the type `impl Sized` - --> $DIR/path-unsatisfied.rs:9:20 + --> $DIR/path-unsatisfied.rs:7:20 | LL | fn method() -> impl Sized { | ^^^^^^^^^^ note: required by a bound in `test` - --> $DIR/path-unsatisfied.rs:17:20 + --> $DIR/path-unsatisfied.rs:15:20 | LL | fn test() | ---- required by a bound in this function diff --git a/tests/ui/associated-type-bounds/return-type-notation/path-works.rs b/tests/ui/associated-type-bounds/return-type-notation/path-works.rs index 87abfc07ee9f2..6c5b9652a88b3 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/path-works.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/path-works.rs @@ -1,7 +1,5 @@ //@ check-pass -#![feature(return_type_notation)] - trait Trait { fn method() -> impl Sized; } diff --git a/tests/ui/associated-type-bounds/return-type-notation/rendering.fixed b/tests/ui/associated-type-bounds/return-type-notation/rendering.fixed index 72c174a0ca020..4ebea15394664 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/rendering.fixed +++ b/tests/ui/associated-type-bounds/return-type-notation/rendering.fixed @@ -1,7 +1,6 @@ //@ run-rustfix #![allow(unused)] -#![feature(return_type_notation)] trait Foo { fn missing() -> impl Sized; diff --git a/tests/ui/associated-type-bounds/return-type-notation/rendering.rs b/tests/ui/associated-type-bounds/return-type-notation/rendering.rs index 4c9948d4c0604..02402eba5d689 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/rendering.rs +++ b/tests/ui/associated-type-bounds/return-type-notation/rendering.rs @@ -1,7 +1,6 @@ //@ run-rustfix #![allow(unused)] -#![feature(return_type_notation)] trait Foo { fn missing() -> impl Sized; diff --git a/tests/ui/associated-type-bounds/return-type-notation/rendering.stderr b/tests/ui/associated-type-bounds/return-type-notation/rendering.stderr index 62fdeb059dd84..c38b95563624e 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/rendering.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/rendering.stderr @@ -1,5 +1,5 @@ error[E0046]: not all trait items implemented, missing: `missing` - --> $DIR/rendering.rs:10:1 + --> $DIR/rendering.rs:9:1 | LL | fn missing() -> impl Sized; | --------------------------- `missing` from trait diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr index 62cca41f6cfd8..ea0fcc4ee5395 100644 --- a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr +++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr @@ -9,7 +9,7 @@ note: type in trait | LL | async fn foo(_: T) -> &'static str; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: expected signature `fn(_) -> impl Future` + = note: expected signature `fn(_) -> impl Future { >::foo(..) }` found signature `fn(_) -> impl Future` error: async associated function in trait cannot be specialized diff --git a/tests/ui/async-await/in-trait/missing-send-bound.stderr b/tests/ui/async-await/in-trait/missing-send-bound.stderr index aeabb5931dfc7..de3b45bab62f3 100644 --- a/tests/ui/async-await/in-trait/missing-send-bound.stderr +++ b/tests/ui/async-await/in-trait/missing-send-bound.stderr @@ -4,22 +4,21 @@ error: future cannot be sent between threads safely LL | assert_is_send(test::()); | ^^^^^^^^^^^ future returned by `test` is not `Send` | - = help: within `impl Future`, the trait `Send` is not implemented for `impl Future` + = help: within `impl Future`, the trait `Send` is not implemented for `impl Future { ::bar(..) }` note: future is not `Send` as it awaits another future which is not `Send` --> $DIR/missing-send-bound.rs:9:5 | LL | T::bar().await; - | ^^^^^^^^ await occurs here on type `impl Future`, which is not `Send` + | ^^^^^^^^ await occurs here on type `impl Future { ::bar(..) }`, which is not `Send` note: required by a bound in `assert_is_send` --> $DIR/missing-send-bound.rs:17:27 | LL | fn assert_is_send(_: impl Send) {} | ^^^^ required by this bound in `assert_is_send` -help: `Send` can be made part of the associated future's guarantees for all implementations of `Foo::bar` - | -LL - async fn bar(); -LL + fn bar() -> impl std::future::Future + Send; +help: consider further restricting the associated type | +LL | fn test2() where ::bar(..): Send { + | +++++++++++++++++++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/async-await/in-trait/send-on-async-fn-in-trait.fixed b/tests/ui/async-await/in-trait/send-on-async-fn-in-trait.fixed index c69605b4c22e0..b703576cc25d2 100644 --- a/tests/ui/async-await/in-trait/send-on-async-fn-in-trait.fixed +++ b/tests/ui/async-await/in-trait/send-on-async-fn-in-trait.fixed @@ -4,16 +4,20 @@ #![allow(unused)] trait Foo { - fn test() -> impl std::future::Future + Send { async {} } - fn test2() -> impl std::future::Future + Send {async { 1 + 2 } } + async fn test() -> () {} + async fn test2() -> i32 { 1 + 2 } } -fn bar() { - fn needs_send(_: impl Send) {} +fn needs_send(_: impl Send) {} + +fn bar() where ::test(..): Send { needs_send(T::test()); - //~^ ERROR `impl Future` cannot be sent between threads safely + //~^ ERROR `impl Future { ::test(..) }` cannot be sent between threads safely +} + +fn bar2() where ::test2(..): Send { needs_send(T::test2()); - //~^ ERROR `impl Future` cannot be sent between threads safely + //~^ ERROR `impl Future { ::test2(..) }` cannot be sent between threads safely } fn main() {} diff --git a/tests/ui/async-await/in-trait/send-on-async-fn-in-trait.rs b/tests/ui/async-await/in-trait/send-on-async-fn-in-trait.rs index 0025b95716273..399c5d29ce760 100644 --- a/tests/ui/async-await/in-trait/send-on-async-fn-in-trait.rs +++ b/tests/ui/async-await/in-trait/send-on-async-fn-in-trait.rs @@ -8,12 +8,16 @@ trait Foo { async fn test2() -> i32 { 1 + 2 } } +fn needs_send(_: impl Send) {} + fn bar() { - fn needs_send(_: impl Send) {} needs_send(T::test()); - //~^ ERROR `impl Future` cannot be sent between threads safely + //~^ ERROR `impl Future { ::test(..) }` cannot be sent between threads safely +} + +fn bar2() { needs_send(T::test2()); - //~^ ERROR `impl Future` cannot be sent between threads safely + //~^ ERROR `impl Future { ::test2(..) }` cannot be sent between threads safely } fn main() {} diff --git a/tests/ui/async-await/in-trait/send-on-async-fn-in-trait.stderr b/tests/ui/async-await/in-trait/send-on-async-fn-in-trait.stderr index da51f10af9486..65133353cfb5a 100644 --- a/tests/ui/async-await/in-trait/send-on-async-fn-in-trait.stderr +++ b/tests/ui/async-await/in-trait/send-on-async-fn-in-trait.stderr @@ -1,42 +1,40 @@ -error[E0277]: `impl Future` cannot be sent between threads safely - --> $DIR/send-on-async-fn-in-trait.rs:13:16 +error[E0277]: `impl Future { ::test(..) }` cannot be sent between threads safely + --> $DIR/send-on-async-fn-in-trait.rs:14:16 | LL | needs_send(T::test()); - | ---------- ^^^^^^^^^ `impl Future` cannot be sent between threads safely + | ---------- ^^^^^^^^^ `impl Future { ::test(..) }` cannot be sent between threads safely | | | required by a bound introduced by this call | - = help: the trait `Send` is not implemented for `impl Future` + = help: the trait `Send` is not implemented for `impl Future { ::test(..) }` note: required by a bound in `needs_send` - --> $DIR/send-on-async-fn-in-trait.rs:12:27 + --> $DIR/send-on-async-fn-in-trait.rs:11:23 | -LL | fn needs_send(_: impl Send) {} - | ^^^^ required by this bound in `needs_send` -help: `Send` can be made part of the associated future's guarantees for all implementations of `Foo::test` - | -LL - async fn test() -> () {} -LL + fn test() -> impl std::future::Future + Send { async {} } +LL | fn needs_send(_: impl Send) {} + | ^^^^ required by this bound in `needs_send` +help: consider further restricting the associated type | +LL | fn bar() where ::test(..): Send { + | ++++++++++++++++++++++++++++++++ -error[E0277]: `impl Future` cannot be sent between threads safely - --> $DIR/send-on-async-fn-in-trait.rs:15:16 +error[E0277]: `impl Future { ::test2(..) }` cannot be sent between threads safely + --> $DIR/send-on-async-fn-in-trait.rs:19:16 | LL | needs_send(T::test2()); - | ---------- ^^^^^^^^^^ `impl Future` cannot be sent between threads safely + | ---------- ^^^^^^^^^^ `impl Future { ::test2(..) }` cannot be sent between threads safely | | | required by a bound introduced by this call | - = help: the trait `Send` is not implemented for `impl Future` + = help: the trait `Send` is not implemented for `impl Future { ::test2(..) }` note: required by a bound in `needs_send` - --> $DIR/send-on-async-fn-in-trait.rs:12:27 - | -LL | fn needs_send(_: impl Send) {} - | ^^^^ required by this bound in `needs_send` -help: `Send` can be made part of the associated future's guarantees for all implementations of `Foo::test2` + --> $DIR/send-on-async-fn-in-trait.rs:11:23 | -LL - async fn test2() -> i32 { 1 + 2 } -LL + fn test2() -> impl std::future::Future + Send {async { 1 + 2 } } +LL | fn needs_send(_: impl Send) {} + | ^^^^ required by this bound in `needs_send` +help: consider further restricting the associated type | +LL | fn bar2() where ::test2(..): Send { + | +++++++++++++++++++++++++++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.rs b/tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.rs index a6da3f7c81c2e..10d692e3e8bff 100644 --- a/tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.rs +++ b/tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.rs @@ -7,7 +7,7 @@ use foreign_async_fn::Foo; fn bar() { fn needs_send(_: impl Send) {} needs_send(T::test()); - //~^ ERROR `impl Future` cannot be sent between threads safely + //~^ ERROR `impl Future { ::test(..) }` cannot be sent between threads safely } fn main() {} diff --git a/tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.stderr b/tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.stderr index dd38e205b03f9..717963301354c 100644 --- a/tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.stderr +++ b/tests/ui/async-await/in-trait/send-on-foreign-async-fn-in-trait.stderr @@ -1,22 +1,21 @@ -error[E0277]: `impl Future` cannot be sent between threads safely +error[E0277]: `impl Future { ::test(..) }` cannot be sent between threads safely --> $DIR/send-on-foreign-async-fn-in-trait.rs:9:16 | LL | needs_send(T::test()); - | ---------- ^^^^^^^^^ `impl Future` cannot be sent between threads safely + | ---------- ^^^^^^^^^ `impl Future { ::test(..) }` cannot be sent between threads safely | | | required by a bound introduced by this call | - = help: the trait `Send` is not implemented for `impl Future` -note: `::test` is an `async fn` in trait, which does not automatically imply that its future is `Send` - --> $DIR/auxiliary/foreign-async-fn.rs:4:5 - | -LL | async fn test(); - | ^^^^^^^^^^^^^^^^ + = help: the trait `Send` is not implemented for `impl Future { ::test(..) }` note: required by a bound in `needs_send` --> $DIR/send-on-foreign-async-fn-in-trait.rs:8:27 | LL | fn needs_send(_: impl Send) {} | ^^^^ required by this bound in `needs_send` +help: consider further restricting the associated type + | +LL | fn bar() where ::test(..): Send { + | ++++++++++++++++++++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/async-await/in-trait/warn.rs b/tests/ui/async-await/in-trait/warn.rs deleted file mode 100644 index 8cdb8887f4205..0000000000000 --- a/tests/ui/async-await/in-trait/warn.rs +++ /dev/null @@ -1,22 +0,0 @@ -//@ edition: 2021 - -#![deny(async_fn_in_trait)] - -pub trait Foo { - async fn not_send(); - //~^ ERROR use of `async fn` in public traits is discouraged -} - -mod private { - pub trait FooUnreachable { - async fn not_send(); - // No warning - } -} - -pub(crate) trait FooCrate { - async fn not_send(); - // No warning -} - -fn main() {} diff --git a/tests/ui/async-await/in-trait/warn.stderr b/tests/ui/async-await/in-trait/warn.stderr deleted file mode 100644 index c741a23c6d56e..0000000000000 --- a/tests/ui/async-await/in-trait/warn.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: use of `async fn` in public traits is discouraged as auto trait bounds cannot be specified - --> $DIR/warn.rs:6:5 - | -LL | async fn not_send(); - | ^^^^^ - | - = note: you can suppress this lint if you plan to use the trait only in your own code, or do not care about auto traits like `Send` on the `Future` -note: the lint level is defined here - --> $DIR/warn.rs:3:9 - | -LL | #![deny(async_fn_in_trait)] - | ^^^^^^^^^^^^^^^^^ -help: you can alternatively desugar to a normal `fn` that returns `impl Future` and add any desired bounds such as `Send`, but these cannot be relaxed without a breaking API change - | -LL - async fn not_send(); -LL + fn not_send() -> impl std::future::Future + Send; - | - -error: aborting due to 1 previous error - diff --git a/tests/ui/async-await/return-type-notation/issue-110963-early.rs b/tests/ui/async-await/return-type-notation/issue-110963-early.rs index 46b8fbf6f86e3..61d89fcaab402 100644 --- a/tests/ui/async-await/return-type-notation/issue-110963-early.rs +++ b/tests/ui/async-await/return-type-notation/issue-110963-early.rs @@ -1,8 +1,6 @@ //@ edition: 2021 //@ known-bug: #110963 -#![feature(return_type_notation)] - trait HealthCheck { async fn check<'a: 'a>(&'a mut self) -> bool; } diff --git a/tests/ui/async-await/return-type-notation/issue-110963-early.stderr b/tests/ui/async-await/return-type-notation/issue-110963-early.stderr index d6c3bd12aee3b..0284fff446f84 100644 --- a/tests/ui/async-await/return-type-notation/issue-110963-early.stderr +++ b/tests/ui/async-await/return-type-notation/issue-110963-early.stderr @@ -1,5 +1,5 @@ error: implementation of `Send` is not general enough - --> $DIR/issue-110963-early.rs:14:5 + --> $DIR/issue-110963-early.rs:12:5 | LL | / spawn(async move { LL | | let mut hc = hc; @@ -13,7 +13,7 @@ LL | | }); = note: ...but `Send` is actually implemented for the type `impl Future { ::check<'2>(..) }`, for some specific lifetime `'2` error: implementation of `Send` is not general enough - --> $DIR/issue-110963-early.rs:14:5 + --> $DIR/issue-110963-early.rs:12:5 | LL | / spawn(async move { LL | | let mut hc = hc; diff --git a/tests/ui/async-await/return-type-notation/issue-110963-late.rs b/tests/ui/async-await/return-type-notation/issue-110963-late.rs index 1f56361f5e50f..0aedeab985594 100644 --- a/tests/ui/async-await/return-type-notation/issue-110963-late.rs +++ b/tests/ui/async-await/return-type-notation/issue-110963-late.rs @@ -1,8 +1,6 @@ //@ edition: 2021 //@ check-pass -#![feature(return_type_notation)] - trait HealthCheck { async fn check(&mut self) -> bool; } diff --git a/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.rs b/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.rs index 3fbd74eddcbbf..6064ba1bfbfd7 100644 --- a/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.rs +++ b/tests/ui/async-await/return-type-notation/normalizing-self-auto-trait-issue-109924.rs @@ -4,8 +4,6 @@ //@[next] compile-flags: -Znext-solver //@ edition:2021 -#![feature(return_type_notation)] - trait Foo { async fn bar(&self); } diff --git a/tests/ui/async-await/return-type-notation/rtn-implied-in-supertrait.rs b/tests/ui/async-await/return-type-notation/rtn-implied-in-supertrait.rs index fdbeb4f3c8758..330ee53b383b5 100644 --- a/tests/ui/async-await/return-type-notation/rtn-implied-in-supertrait.rs +++ b/tests/ui/async-await/return-type-notation/rtn-implied-in-supertrait.rs @@ -1,8 +1,6 @@ //@ edition:2021 //@ check-pass -#![feature(return_type_notation)] - use std::future::Future; struct JoinHandle(fn() -> T); diff --git a/tests/ui/async-await/return-type-notation/rtn-in-impl-signature.rs b/tests/ui/async-await/return-type-notation/rtn-in-impl-signature.rs index bbdfcf607318b..ef86924b8b163 100644 --- a/tests/ui/async-await/return-type-notation/rtn-in-impl-signature.rs +++ b/tests/ui/async-await/return-type-notation/rtn-in-impl-signature.rs @@ -1,5 +1,3 @@ -#![feature(return_type_notation)] - // Shouldn't ICE when we have a (bad) RTN in an impl header trait Super1<'a> { diff --git a/tests/ui/async-await/return-type-notation/rtn-in-impl-signature.stderr b/tests/ui/async-await/return-type-notation/rtn-in-impl-signature.stderr index 2bbf1d504747f..96db30f1488a7 100644 --- a/tests/ui/async-await/return-type-notation/rtn-in-impl-signature.stderr +++ b/tests/ui/async-await/return-type-notation/rtn-in-impl-signature.stderr @@ -1,5 +1,5 @@ error[E0229]: associated item constraints are not allowed here - --> $DIR/rtn-in-impl-signature.rs:9:17 + --> $DIR/rtn-in-impl-signature.rs:7:17 | LL | impl Super1<'_, bar(..): Send> for () {} | ^^^^^^^^^^^^^ associated item constraint not allowed here @@ -11,7 +11,7 @@ LL + impl Super1<'_> for () {} | error[E0046]: not all trait items implemented, missing: `bar` - --> $DIR/rtn-in-impl-signature.rs:9:1 + --> $DIR/rtn-in-impl-signature.rs:7:1 | LL | fn bar<'b>() -> bool; | --------------------- `bar` from trait diff --git a/tests/ui/async-await/return-type-notation/super-method-bound-ambig.rs b/tests/ui/async-await/return-type-notation/super-method-bound-ambig.rs index 1db19628fa37d..c8d06b32eebca 100644 --- a/tests/ui/async-await/return-type-notation/super-method-bound-ambig.rs +++ b/tests/ui/async-await/return-type-notation/super-method-bound-ambig.rs @@ -1,7 +1,5 @@ //@ edition:2021 -#![feature(return_type_notation)] - trait Super1<'a> { async fn test(); } diff --git a/tests/ui/async-await/return-type-notation/super-method-bound-ambig.stderr b/tests/ui/async-await/return-type-notation/super-method-bound-ambig.stderr index e32b07771dc92..2101914ec4675 100644 --- a/tests/ui/async-await/return-type-notation/super-method-bound-ambig.stderr +++ b/tests/ui/async-await/return-type-notation/super-method-bound-ambig.stderr @@ -1,5 +1,5 @@ error[E0221]: ambiguous associated function `test` in bounds of `Foo` - --> $DIR/super-method-bound-ambig.rs:24:12 + --> $DIR/super-method-bound-ambig.rs:22:12 | LL | async fn test(); | ---------------- ambiguous `test` from `for<'a> Super1<'a>` diff --git a/tests/ui/async-await/return-type-notation/super-method-bound.rs b/tests/ui/async-await/return-type-notation/super-method-bound.rs index a1d0307698218..f2f0e50a607f2 100644 --- a/tests/ui/async-await/return-type-notation/super-method-bound.rs +++ b/tests/ui/async-await/return-type-notation/super-method-bound.rs @@ -1,8 +1,6 @@ //@ edition:2021 //@ check-pass -#![feature(return_type_notation)] - trait Super<'a> { async fn test(); } diff --git a/tests/ui/async-await/return-type-notation/supertrait-bound.rs b/tests/ui/async-await/return-type-notation/supertrait-bound.rs index 8d73a34ac482f..18348473c5930 100644 --- a/tests/ui/async-await/return-type-notation/supertrait-bound.rs +++ b/tests/ui/async-await/return-type-notation/supertrait-bound.rs @@ -1,7 +1,5 @@ //@ check-pass -#![feature(return_type_notation)] - trait IntFactory { fn stream(&self) -> impl Iterator; } diff --git a/tests/ui/async-await/return-type-notation/ty-or-ct-params.rs b/tests/ui/async-await/return-type-notation/ty-or-ct-params.rs index edb92d8e26588..726af0ac7a5b7 100644 --- a/tests/ui/async-await/return-type-notation/ty-or-ct-params.rs +++ b/tests/ui/async-await/return-type-notation/ty-or-ct-params.rs @@ -1,7 +1,5 @@ //@ edition: 2021 -#![feature(return_type_notation)] - trait Foo { async fn bar() {} diff --git a/tests/ui/async-await/return-type-notation/ty-or-ct-params.stderr b/tests/ui/async-await/return-type-notation/ty-or-ct-params.stderr index 0e43d69bddc68..cead63b1ea669 100644 --- a/tests/ui/async-await/return-type-notation/ty-or-ct-params.stderr +++ b/tests/ui/async-await/return-type-notation/ty-or-ct-params.stderr @@ -1,5 +1,5 @@ error: return type notation is not allowed for functions that have type parameters - --> $DIR/ty-or-ct-params.rs:13:12 + --> $DIR/ty-or-ct-params.rs:11:12 | LL | async fn bar() {} | - type parameter declared here @@ -8,7 +8,7 @@ LL | T: Foo, | ^^^^^^^^^^^^^ error: return type notation is not allowed for functions that have const parameters - --> $DIR/ty-or-ct-params.rs:13:27 + --> $DIR/ty-or-ct-params.rs:11:27 | LL | async fn baz() {} | -------------- const parameter declared here diff --git a/tests/ui/borrowck/alias-liveness/rtn-static.rs b/tests/ui/borrowck/alias-liveness/rtn-static.rs index 5b6cf5b5c7ccc..3b262b2eb609c 100644 --- a/tests/ui/borrowck/alias-liveness/rtn-static.rs +++ b/tests/ui/borrowck/alias-liveness/rtn-static.rs @@ -1,7 +1,5 @@ //@ check-pass -#![feature(return_type_notation)] - trait Foo { fn borrow(&mut self) -> impl Sized + '_; } diff --git a/tests/ui/feature-gates/feature-gate-return_type_notation.cfg.stderr b/tests/ui/feature-gates/feature-gate-return_type_notation.cfg.stderr deleted file mode 100644 index 18f46928fab54..0000000000000 --- a/tests/ui/feature-gates/feature-gate-return_type_notation.cfg.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: return type notation is experimental - --> $DIR/feature-gate-return_type_notation.rs:10:18 - | -LL | fn foo>() {} - | ^^^^ - | - = note: see issue #109417 for more information - = help: add `#![feature(return_type_notation)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-return_type_notation.no.stderr b/tests/ui/feature-gates/feature-gate-return_type_notation.no.stderr deleted file mode 100644 index 18f46928fab54..0000000000000 --- a/tests/ui/feature-gates/feature-gate-return_type_notation.no.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: return type notation is experimental - --> $DIR/feature-gate-return_type_notation.rs:10:18 - | -LL | fn foo>() {} - | ^^^^ - | - = note: see issue #109417 for more information - = help: add `#![feature(return_type_notation)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-return_type_notation.rs b/tests/ui/feature-gates/feature-gate-return_type_notation.rs deleted file mode 100644 index 254b794e431e9..0000000000000 --- a/tests/ui/feature-gates/feature-gate-return_type_notation.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ edition: 2021 -//@ revisions: cfg no - -trait Trait { - #[allow(async_fn_in_trait)] - async fn m(); -} - -#[cfg(cfg)] -fn foo>() {} -//~^ ERROR return type notation is experimental - -fn main() {} diff --git a/tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.stderr b/tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.stderr index 86f9cc4d99265..6f722441d3193 100644 --- a/tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.stderr +++ b/tests/ui/impl-trait/in-trait/check-wf-on-non-defaulted-rpitit.stderr @@ -10,6 +10,10 @@ note: required by a bound in `Wrapper` | LL | struct Wrapper(G); | ^^^^ required by this bound in `Wrapper` +help: consider further restricting the associated type + | +LL | fn bar() -> Wrapper where impl Sized: Send; + | ++++++++++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/in-trait/issue-102571.stderr b/tests/ui/impl-trait/in-trait/issue-102571.stderr index 1f25069a01699..bb7c1b924ca7e 100644 --- a/tests/ui/impl-trait/in-trait/issue-102571.stderr +++ b/tests/ui/impl-trait/in-trait/issue-102571.stderr @@ -2,11 +2,11 @@ error[E0308]: mismatched types --> $DIR/issue-102571.rs:9:9 | LL | let () = t.bar(); - | ^^ ------- this expression has type `impl Deref` + | ^^ ------- this expression has type `impl Deref { ::bar(..) }` | | | expected associated type, found `()` | - = note: expected associated type `impl Deref` + = note: expected associated type `impl Deref { ::bar(..) }` found unit type `()` error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/in-trait/missing-static-bound-from-impl.rs b/tests/ui/impl-trait/in-trait/missing-static-bound-from-impl.rs index ee9ecdda90289..8970fcdb816fe 100644 --- a/tests/ui/impl-trait/in-trait/missing-static-bound-from-impl.rs +++ b/tests/ui/impl-trait/in-trait/missing-static-bound-from-impl.rs @@ -9,7 +9,7 @@ trait Erased { impl Erased for T { fn f(&self) -> Box { Box::new(::f()) - //~^ ERROR the associated type `impl Fn()` may not live long enough + //~^ ERROR the associated type `impl Fn() { ::f(..) }` may not live long enough } } diff --git a/tests/ui/impl-trait/in-trait/missing-static-bound-from-impl.stderr b/tests/ui/impl-trait/in-trait/missing-static-bound-from-impl.stderr index 1f787c1842cf9..fe269191cc6d7 100644 --- a/tests/ui/impl-trait/in-trait/missing-static-bound-from-impl.stderr +++ b/tests/ui/impl-trait/in-trait/missing-static-bound-from-impl.stderr @@ -1,11 +1,11 @@ -error[E0310]: the associated type `impl Fn()` may not live long enough +error[E0310]: the associated type `impl Fn() { ::f(..) }` may not live long enough --> $DIR/missing-static-bound-from-impl.rs:11:9 | LL | Box::new(::f()) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | the associated type `impl Fn()` must be valid for the static lifetime... - | ...so that the type `impl Fn()` will meet its required lifetime bounds + | the associated type `impl Fn() { ::f(..) }` must be valid for the static lifetime... + | ...so that the type `impl Fn() { ::f(..) }` will meet its required lifetime bounds error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/in-trait/return-type-notation.rs b/tests/ui/impl-trait/in-trait/return-type-notation.rs index 3945eb9bdeef7..70f6f0c560b45 100644 --- a/tests/ui/impl-trait/in-trait/return-type-notation.rs +++ b/tests/ui/impl-trait/in-trait/return-type-notation.rs @@ -1,6 +1,4 @@ #![allow(incomplete_features)] -#![feature(return_type_notation)] - trait IntFactory { fn stream(&self) -> impl IntFactory + Send>; //~^ ERROR cycle detected when resolving lifetimes for `IntFactory::stream` diff --git a/tests/ui/impl-trait/in-trait/return-type-notation.stderr b/tests/ui/impl-trait/in-trait/return-type-notation.stderr index d9fd780cdff3d..b52e3f1bf6516 100644 --- a/tests/ui/impl-trait/in-trait/return-type-notation.stderr +++ b/tests/ui/impl-trait/in-trait/return-type-notation.stderr @@ -1,22 +1,22 @@ error[E0391]: cycle detected when resolving lifetimes for `IntFactory::stream` - --> $DIR/return-type-notation.rs:5:5 + --> $DIR/return-type-notation.rs:3:5 | LL | fn stream(&self) -> impl IntFactory + Send>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: ...which requires computing function signature of `IntFactory::stream`... - --> $DIR/return-type-notation.rs:5:5 + --> $DIR/return-type-notation.rs:3:5 | LL | fn stream(&self) -> impl IntFactory + Send>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires looking up late bound vars inside `IntFactory::stream`... - --> $DIR/return-type-notation.rs:5:5 + --> $DIR/return-type-notation.rs:3:5 | LL | fn stream(&self) -> impl IntFactory + Send>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which again requires resolving lifetimes for `IntFactory::stream`, completing the cycle note: cycle used when listing captured lifetimes for opaque `IntFactory::stream::{opaque#0}` - --> $DIR/return-type-notation.rs:5:25 + --> $DIR/return-type-notation.rs:3:25 | LL | fn stream(&self) -> impl IntFactory + Send>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.stderr b/tests/ui/impl-trait/in-trait/specialization-broken.stderr index fbbe1ac40b9ef..2f05eac784b9b 100644 --- a/tests/ui/impl-trait/in-trait/specialization-broken.stderr +++ b/tests/ui/impl-trait/in-trait/specialization-broken.stderr @@ -12,7 +12,7 @@ note: type in trait | LL | fn bar(&self) -> impl Sized; | ^^^^^^^^^^ - = note: expected signature `fn(&_) -> impl Sized` + = note: expected signature `fn(&_) -> impl Sized { ::bar(..) }` found signature `fn(&_) -> U` help: change the output type to match the trait | diff --git a/tests/ui/suggestions/let-binding-init-expr-as-ty.stderr b/tests/ui/suggestions/let-binding-init-expr-as-ty.stderr index 19a0e4b17d029..dd65ca44e19d0 100644 --- a/tests/ui/suggestions/let-binding-init-expr-as-ty.stderr +++ b/tests/ui/suggestions/let-binding-init-expr-as-ty.stderr @@ -12,9 +12,6 @@ error: argument types not allowed with return type notation LL | let foo: i32::from_be(num); | ^^^^^ | - = note: see issue #109417 for more information - = help: add `#![feature(return_type_notation)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date help: remove the input types | LL - let foo: i32::from_be(num); From f5b0f69bb10b3e6f26d7df37e433572265f8d4b2 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 12 Mar 2025 20:17:42 +0000 Subject: [PATCH 3/3] Remove the async_fn_in_trait lint --- compiler/rustc_lint/messages.ftl | 4 - compiler/rustc_lint/src/async_fn_in_trait.rs | 130 ------------------ compiler/rustc_lint/src/lib.rs | 8 +- compiler/rustc_lint/src/lints.rs | 14 -- .../in-trait/async-associated-types.rs | 2 - .../in-trait/async-default-fn-overridden.rs | 2 - .../in-trait/async-example-desugared-boxed.rs | 1 - .../async-example-desugared-boxed.stderr | 4 +- .../in-trait/async-example-desugared-extra.rs | 1 - .../async-example-desugared-manual.rs | 1 - .../async-example-desugared-manual.stderr | 4 +- .../in-trait/async-example-desugared.rs | 1 - .../ui/async-await/in-trait/async-example.rs | 2 - .../in-trait/async-lifetimes-and-bounds.rs | 1 - .../async-await/in-trait/async-lifetimes.rs | 1 - .../in-trait/auxiliary/bad-region.rs | 2 - tests/ui/async-await/in-trait/bad-region.rs | 2 - .../ui/async-await/in-trait/bad-region.stderr | 2 +- .../ui/async-await/in-trait/early-bound-1.rs | 1 - .../ui/async-await/in-trait/early-bound-2.rs | 1 - .../ui/async-await/in-trait/implied-bounds.rs | 1 - tests/ui/async-await/in-trait/issue-102138.rs | 1 - tests/ui/async-await/in-trait/issue-102219.rs | 1 - tests/ui/async-await/in-trait/issue-102310.rs | 1 - tests/ui/async-await/in-trait/issue-104678.rs | 1 - tests/ui/async-await/in-trait/nested-rpit.rs | 1 - .../normalize-opaque-with-bound-vars.rs | 1 - .../in-trait/assumed-wf-bounds-in-impl.rs | 1 - .../in-trait/default-body-with-rpit.rs | 1 - tests/ui/impl-trait/in-trait/default-body.rs | 1 - tests/ui/impl-trait/in-trait/early.rs | 1 - .../in-trait/suggest-missing-item.fixed | 3 - .../in-trait/suggest-missing-item.rs | 3 - .../in-trait/suggest-missing-item.stderr | 6 +- 34 files changed, 13 insertions(+), 194 deletions(-) delete mode 100644 compiler/rustc_lint/src/async_fn_in_trait.rs diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index d51865810b9a8..360d2bc25b0ce 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -21,10 +21,6 @@ lint_associated_const_elided_lifetime = {$elided -> .suggestion = use the `'static` lifetime .note = cannot automatically infer `'static` because of other lifetimes in scope -lint_async_fn_in_trait = use of `async fn` in public traits is discouraged as auto trait bounds cannot be specified - .note = you can suppress this lint if you plan to use the trait only in your own code, or do not care about auto traits like `Send` on the `Future` - .suggestion = you can alternatively desugar to a normal `fn` that returns `impl Future` and add any desired bounds such as `Send`, but these cannot be relaxed without a breaking API change - lint_atomic_ordering_fence = memory fences cannot have `Relaxed` ordering .help = consider using ordering modes `Acquire`, `Release`, `AcqRel` or `SeqCst` diff --git a/compiler/rustc_lint/src/async_fn_in_trait.rs b/compiler/rustc_lint/src/async_fn_in_trait.rs deleted file mode 100644 index a395b7c2df718..0000000000000 --- a/compiler/rustc_lint/src/async_fn_in_trait.rs +++ /dev/null @@ -1,130 +0,0 @@ -use rustc_hir as hir; -use rustc_session::{declare_lint, declare_lint_pass}; -use rustc_trait_selection::error_reporting::traits::suggestions::suggest_desugaring_async_fn_to_impl_future_in_trait; - -use crate::lints::AsyncFnInTraitDiag; -use crate::{LateContext, LateLintPass}; - -declare_lint! { - /// The `async_fn_in_trait` lint detects use of `async fn` in the - /// definition of a publicly-reachable trait. - /// - /// ### Example - /// - /// ```rust - /// pub trait Trait { - /// async fn method(&self); - /// } - /// # fn main() {} - /// ``` - /// - /// {{produces}} - /// - /// ### Explanation - /// - /// When `async fn` is used in a trait definition, the trait does not - /// promise that the opaque [`Future`] returned by the associated function - /// or method will implement any [auto traits] such as [`Send`]. This may - /// be surprising and may make the associated functions or methods on the - /// trait less useful than intended. On traits exposed publicly from a - /// crate, this may affect downstream crates whose authors cannot alter - /// the trait definition. - /// - /// For example, this code is invalid: - /// - /// ```rust,compile_fail - /// pub trait Trait { - /// async fn method(&self) {} - /// } - /// - /// fn test(x: T) { - /// fn spawn(_: T) {} - /// spawn(x.method()); // Not OK. - /// } - /// ``` - /// - /// This lint exists to warn authors of publicly-reachable traits that - /// they may want to consider desugaring the `async fn` to a normal `fn` - /// that returns an opaque `impl Future<..> + Send` type. - /// - /// For example, instead of: - /// - /// ```rust - /// pub trait Trait { - /// async fn method(&self) {} - /// } - /// ``` - /// - /// The author of the trait may want to write: - /// - /// - /// ```rust - /// use core::future::Future; - /// pub trait Trait { - /// fn method(&self) -> impl Future + Send { async {} } - /// } - /// ``` - /// - /// This still allows the use of `async fn` within impls of the trait. - /// However, it also means that the trait will never be compatible with - /// impls where the returned [`Future`] of the method does not implement - /// `Send`. - /// - /// Conversely, if the trait is used only locally, if it is never used in - /// generic functions, or if it is only used in single-threaded contexts - /// that do not care whether the returned [`Future`] implements [`Send`], - /// then the lint may be suppressed. - /// - /// [`Future`]: https://doc.rust-lang.org/core/future/trait.Future.html - /// [`Send`]: https://doc.rust-lang.org/core/marker/trait.Send.html - /// [auto traits]: https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits - pub ASYNC_FN_IN_TRAIT, - Warn, - "use of `async fn` in definition of a publicly-reachable trait" -} - -declare_lint_pass!( - /// Lint for use of `async fn` in the definition of a publicly-reachable - /// trait. - AsyncFnInTrait => [ASYNC_FN_IN_TRAIT] -); - -impl<'tcx> LateLintPass<'tcx> for AsyncFnInTrait { - fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::TraitItem<'tcx>) { - if let hir::TraitItemKind::Fn(sig, body) = item.kind - && let hir::IsAsync::Async(async_span) = sig.header.asyncness - { - // RTN can be used to bound `async fn` in traits in a better way than "always" - // TODO: - if true { - return; - } - - // Only need to think about library implications of reachable traits - if !cx.tcx.effective_visibilities(()).is_reachable(item.owner_id.def_id) { - return; - } - - let hir::FnRetTy::Return(hir::Ty { - kind: hir::TyKind::OpaqueDef(opaq_def, ..), .. - }) = sig.decl.output - else { - // This should never happen, but let's not ICE. - return; - }; - let sugg = suggest_desugaring_async_fn_to_impl_future_in_trait( - cx.tcx, - sig, - body, - opaq_def.def_id, - " + Send", - ); - cx.tcx.emit_node_span_lint( - ASYNC_FN_IN_TRAIT, - item.hir_id(), - async_span, - AsyncFnInTraitDiag { sugg }, - ); - } - } -} diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 7018774e5c6bc..17be87fd90c40 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -36,7 +36,6 @@ // tidy-alphabetical-end mod async_closures; -mod async_fn_in_trait; pub mod builtin; mod context; mod dangling; @@ -82,7 +81,6 @@ mod unqualified_local_imports; mod unused; use async_closures::AsyncClosureUsage; -use async_fn_in_trait::AsyncFnInTrait; use builtin::*; use dangling::*; use default_could_be_derived::DefaultCouldBeDerived; @@ -238,7 +236,6 @@ late_lint_methods!( MissingDebugImplementations: MissingDebugImplementations, MissingDoc: MissingDoc, AsyncClosureUsage: AsyncClosureUsage, - AsyncFnInTrait: AsyncFnInTrait, NonLocalDefinitions: NonLocalDefinitions::default(), ImplTraitOvercaptures: ImplTraitOvercaptures, IfLetRescope: IfLetRescope::default(), @@ -604,6 +601,11 @@ fn register_builtins(store: &mut LintStore) { "converted into hard error, see issue #127323 \ for more information", ); + store.register_removed( + "async_fn_in_trait", + "lint was relaxed since return-type notation is stabilized; \ + see for more information", + ) } fn register_internals(store: &mut LintStore) { diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 0058630957291..ff0b7fa242079 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -2100,20 +2100,6 @@ pub(crate) struct UnusedAllocationDiag; #[diag(lint_unused_allocation_mut)] pub(crate) struct UnusedAllocationMutDiag; -pub(crate) struct AsyncFnInTraitDiag { - pub sugg: Option>, -} - -impl<'a> LintDiagnostic<'a, ()> for AsyncFnInTraitDiag { - fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { - diag.primary_message(fluent::lint_async_fn_in_trait); - diag.note(fluent::lint_note); - if let Some(sugg) = self.sugg { - diag.multipart_suggestion(fluent::lint_suggestion, sugg, Applicability::MaybeIncorrect); - } - } -} - #[derive(LintDiagnostic)] #[diag(lint_unit_bindings)] pub(crate) struct UnitBindingsDiag { diff --git a/tests/ui/async-await/in-trait/async-associated-types.rs b/tests/ui/async-await/in-trait/async-associated-types.rs index 1f29c19de20df..29aac7c9c1426 100644 --- a/tests/ui/async-await/in-trait/async-associated-types.rs +++ b/tests/ui/async-await/in-trait/async-associated-types.rs @@ -6,14 +6,12 @@ use std::fmt::Debug; trait MyTrait<'a, 'b, T> where Self: 'a, T: Debug + Sized + 'b { type MyAssoc; - #[allow(async_fn_in_trait)] async fn foo(&'a self, key: &'b T) -> Self::MyAssoc; } impl<'a, 'b, T: Debug + Sized + 'b, U: 'a> MyTrait<'a, 'b, T> for U { type MyAssoc = (&'a U, &'b T); - #[allow(async_fn_in_trait)] async fn foo(&'a self, key: &'b T) -> (&'a U, &'b T) { (self, key) } diff --git a/tests/ui/async-await/in-trait/async-default-fn-overridden.rs b/tests/ui/async-await/in-trait/async-default-fn-overridden.rs index 6e36818f04f44..8375c10dc0cf3 100644 --- a/tests/ui/async-await/in-trait/async-default-fn-overridden.rs +++ b/tests/ui/async-await/in-trait/async-default-fn-overridden.rs @@ -4,12 +4,10 @@ use std::future::Future; trait AsyncTrait { - #[allow(async_fn_in_trait)] async fn default_impl() { assert!(false); } - #[allow(async_fn_in_trait)] async fn call_default_impl() { Self::default_impl().await } diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed.rs b/tests/ui/async-await/in-trait/async-example-desugared-boxed.rs index 1b1c858f91626..37c9c8c23f3a2 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-boxed.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed.rs @@ -4,7 +4,6 @@ use std::future::Future; use std::pin::Pin; -#[allow(async_fn_in_trait)] pub trait MyTrait { async fn foo(&self) -> i32; } diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr b/tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr index b7f2879727f24..3e99788e94219 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr @@ -1,5 +1,5 @@ warning: impl trait in impl method signature does not match trait method signature - --> $DIR/async-example-desugared-boxed.rs:14:22 + --> $DIR/async-example-desugared-boxed.rs:13:22 | LL | async fn foo(&self) -> i32; | --------------------------- return type from trait method defined here @@ -10,7 +10,7 @@ LL | fn foo(&self) -> Pin + '_>> { = note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate = note: we are soliciting feedback, see issue #121718 for more information note: the lint level is defined here - --> $DIR/async-example-desugared-boxed.rs:13:12 + --> $DIR/async-example-desugared-boxed.rs:12:12 | LL | #[warn(refining_impl_trait)] | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/async-await/in-trait/async-example-desugared-extra.rs b/tests/ui/async-await/in-trait/async-example-desugared-extra.rs index d85ad869fd403..25537b05d34dc 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-extra.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared-extra.rs @@ -6,7 +6,6 @@ use std::pin::Pin; use std::task::Poll; pub trait MyTrait { - #[allow(async_fn_in_trait)] async fn foo(&self) -> i32; } diff --git a/tests/ui/async-await/in-trait/async-example-desugared-manual.rs b/tests/ui/async-await/in-trait/async-example-desugared-manual.rs index 1d9a7640f5482..0094b6dadb9eb 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-manual.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared-manual.rs @@ -4,7 +4,6 @@ use std::future::Future; use std::task::Poll; -#[allow(async_fn_in_trait)] pub trait MyTrait { async fn foo(&self) -> i32; } diff --git a/tests/ui/async-await/in-trait/async-example-desugared-manual.stderr b/tests/ui/async-await/in-trait/async-example-desugared-manual.stderr index 86546df88c175..04dc61f6665f0 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-manual.stderr +++ b/tests/ui/async-await/in-trait/async-example-desugared-manual.stderr @@ -1,5 +1,5 @@ warning: impl trait in impl method signature does not match trait method signature - --> $DIR/async-example-desugared-manual.rs:22:22 + --> $DIR/async-example-desugared-manual.rs:21:22 | LL | async fn foo(&self) -> i32; | --------------------------- return type from trait method defined here @@ -10,7 +10,7 @@ LL | fn foo(&self) -> MyFuture { = note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate = note: we are soliciting feedback, see issue #121718 for more information note: the lint level is defined here - --> $DIR/async-example-desugared-manual.rs:21:12 + --> $DIR/async-example-desugared-manual.rs:20:12 | LL | #[warn(refining_impl_trait)] | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/async-await/in-trait/async-example-desugared.rs b/tests/ui/async-await/in-trait/async-example-desugared.rs index 149a880ad754a..06387e8397708 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared.rs @@ -4,7 +4,6 @@ use std::future::Future; trait MyTrait { - #[allow(async_fn_in_trait)] async fn foo(&self) -> i32; } diff --git a/tests/ui/async-await/in-trait/async-example.rs b/tests/ui/async-await/in-trait/async-example.rs index 6cdf0e96edf91..7f0eea2950297 100644 --- a/tests/ui/async-await/in-trait/async-example.rs +++ b/tests/ui/async-await/in-trait/async-example.rs @@ -2,10 +2,8 @@ //@ edition: 2021 trait MyTrait { - #[allow(async_fn_in_trait)] async fn foo(&self) -> i32; - #[allow(async_fn_in_trait)] async fn bar(&self) -> i32; } diff --git a/tests/ui/async-await/in-trait/async-lifetimes-and-bounds.rs b/tests/ui/async-await/in-trait/async-lifetimes-and-bounds.rs index 81f70afa2a72b..14295a35e30e0 100644 --- a/tests/ui/async-await/in-trait/async-lifetimes-and-bounds.rs +++ b/tests/ui/async-await/in-trait/async-lifetimes-and-bounds.rs @@ -4,7 +4,6 @@ use std::fmt::Debug; trait MyTrait<'a, 'b, T> { - #[allow(async_fn_in_trait)] async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T) where T: Debug + Sized; } diff --git a/tests/ui/async-await/in-trait/async-lifetimes.rs b/tests/ui/async-await/in-trait/async-lifetimes.rs index d78944553221c..0e48361ac7dee 100644 --- a/tests/ui/async-await/in-trait/async-lifetimes.rs +++ b/tests/ui/async-await/in-trait/async-lifetimes.rs @@ -2,7 +2,6 @@ //@ edition: 2021 trait MyTrait<'a, 'b, T> { - #[allow(async_fn_in_trait)] async fn foo(&'a self, key: &'b T) -> (&'a Self, &'b T); } diff --git a/tests/ui/async-await/in-trait/auxiliary/bad-region.rs b/tests/ui/async-await/in-trait/auxiliary/bad-region.rs index 2bfd9bb37308e..05a6b3e9c4ec2 100644 --- a/tests/ui/async-await/in-trait/auxiliary/bad-region.rs +++ b/tests/ui/async-await/in-trait/auxiliary/bad-region.rs @@ -1,7 +1,5 @@ //@ edition:2021 -#[allow(async_fn_in_trait)] - pub trait BleRadio<'a> { async fn transmit(&mut self); } diff --git a/tests/ui/async-await/in-trait/bad-region.rs b/tests/ui/async-await/in-trait/bad-region.rs index 5d5d8783a324f..0f1426f44ea02 100644 --- a/tests/ui/async-await/in-trait/bad-region.rs +++ b/tests/ui/async-await/in-trait/bad-region.rs @@ -1,8 +1,6 @@ //@ aux-build:bad-region.rs //@ edition:2021 -#![allow(async_fn_in_trait)] - extern crate bad_region as jewel; use jewel::BleRadio; diff --git a/tests/ui/async-await/in-trait/bad-region.stderr b/tests/ui/async-await/in-trait/bad-region.stderr index 9203fd790af78..191d34f5cad67 100644 --- a/tests/ui/async-await/in-trait/bad-region.stderr +++ b/tests/ui/async-await/in-trait/bad-region.stderr @@ -1,5 +1,5 @@ error[E0726]: implicit elided lifetime not allowed here - --> $DIR/bad-region.rs:12:6 + --> $DIR/bad-region.rs:10:6 | LL | impl BleRadio for Radio { | ^^^^^^^^ expected lifetime parameter diff --git a/tests/ui/async-await/in-trait/early-bound-1.rs b/tests/ui/async-await/in-trait/early-bound-1.rs index fd1282908abec..8738b22ae3cb1 100644 --- a/tests/ui/async-await/in-trait/early-bound-1.rs +++ b/tests/ui/async-await/in-trait/early-bound-1.rs @@ -2,7 +2,6 @@ //@ edition:2021 pub trait Foo { - #[allow(async_fn_in_trait)] async fn foo(&mut self); } diff --git a/tests/ui/async-await/in-trait/early-bound-2.rs b/tests/ui/async-await/in-trait/early-bound-2.rs index 33da7d828c79b..e535b1470d8a2 100644 --- a/tests/ui/async-await/in-trait/early-bound-2.rs +++ b/tests/ui/async-await/in-trait/early-bound-2.rs @@ -2,7 +2,6 @@ //@ edition:2021 pub trait Foo { - #[allow(async_fn_in_trait)] async fn foo(&mut self); } diff --git a/tests/ui/async-await/in-trait/implied-bounds.rs b/tests/ui/async-await/in-trait/implied-bounds.rs index 72ae0ce68a2fd..f6067bf04858e 100644 --- a/tests/ui/async-await/in-trait/implied-bounds.rs +++ b/tests/ui/async-await/in-trait/implied-bounds.rs @@ -5,7 +5,6 @@ trait TcpStack { type Connection<'a>: Sized where Self: 'a; fn connect<'a>(&'a self) -> Self::Connection<'a>; - #[allow(async_fn_in_trait)] async fn async_connect<'a>(&'a self) -> Self::Connection<'a>; } diff --git a/tests/ui/async-await/in-trait/issue-102138.rs b/tests/ui/async-await/in-trait/issue-102138.rs index ffb23fcc0da92..b95a414213415 100644 --- a/tests/ui/async-await/in-trait/issue-102138.rs +++ b/tests/ui/async-await/in-trait/issue-102138.rs @@ -8,7 +8,6 @@ async fn yield_now() {} trait AsyncIterator { type Item; - #[allow(async_fn_in_trait)] async fn next(&mut self) -> Option; } diff --git a/tests/ui/async-await/in-trait/issue-102219.rs b/tests/ui/async-await/in-trait/issue-102219.rs index e373b17db4f4a..63aef6396f149 100644 --- a/tests/ui/async-await/in-trait/issue-102219.rs +++ b/tests/ui/async-await/in-trait/issue-102219.rs @@ -3,6 +3,5 @@ //@ check-pass trait T { - #[allow(async_fn_in_trait)] async fn foo(); } diff --git a/tests/ui/async-await/in-trait/issue-102310.rs b/tests/ui/async-await/in-trait/issue-102310.rs index daaafba56bf7f..e95d08c7df9fd 100644 --- a/tests/ui/async-await/in-trait/issue-102310.rs +++ b/tests/ui/async-await/in-trait/issue-102310.rs @@ -2,7 +2,6 @@ //@ edition:2021 pub trait SpiDevice { - #[allow(async_fn_in_trait)] async fn transaction(&mut self); } diff --git a/tests/ui/async-await/in-trait/issue-104678.rs b/tests/ui/async-await/in-trait/issue-104678.rs index e64315157b2d9..395ec6b731691 100644 --- a/tests/ui/async-await/in-trait/issue-104678.rs +++ b/tests/ui/async-await/in-trait/issue-104678.rs @@ -5,7 +5,6 @@ use std::future::Future; pub trait Pool { type Conn; - #[allow(async_fn_in_trait)] async fn async_callback<'a, F: FnOnce(&'a Self::Conn) -> Fut, Fut: Future>( &'a self, callback: F, diff --git a/tests/ui/async-await/in-trait/nested-rpit.rs b/tests/ui/async-await/in-trait/nested-rpit.rs index 789b751fcc90d..dd207f8a610dd 100644 --- a/tests/ui/async-await/in-trait/nested-rpit.rs +++ b/tests/ui/async-await/in-trait/nested-rpit.rs @@ -5,7 +5,6 @@ use std::future::Future; use std::marker::PhantomData; trait Lockable { - #[allow(async_fn_in_trait)] async fn lock_all_entries(&self) -> impl Future>; } diff --git a/tests/ui/async-await/in-trait/normalize-opaque-with-bound-vars.rs b/tests/ui/async-await/in-trait/normalize-opaque-with-bound-vars.rs index 0c1b2b70c0914..e8db78f8574c3 100644 --- a/tests/ui/async-await/in-trait/normalize-opaque-with-bound-vars.rs +++ b/tests/ui/async-await/in-trait/normalize-opaque-with-bound-vars.rs @@ -10,7 +10,6 @@ pub struct SharedState {} pub trait State { - #[allow(async_fn_in_trait)] async fn execute(self, shared_state: &SharedState); } diff --git a/tests/ui/impl-trait/in-trait/assumed-wf-bounds-in-impl.rs b/tests/ui/impl-trait/in-trait/assumed-wf-bounds-in-impl.rs index 869d44d9e3b76..929cfd112c6b8 100644 --- a/tests/ui/impl-trait/in-trait/assumed-wf-bounds-in-impl.rs +++ b/tests/ui/impl-trait/in-trait/assumed-wf-bounds-in-impl.rs @@ -8,7 +8,6 @@ trait AsyncLendingIterator { where Self: 'a; - #[allow(async_fn_in_trait)] async fn next(&mut self) -> Option>; } diff --git a/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs b/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs index 1bbff839ffa56..846b575ef84e4 100644 --- a/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs +++ b/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs @@ -7,7 +7,6 @@ use std::fmt::Debug; trait Foo { - #[allow(async_fn_in_trait)] async fn baz(&self) -> impl Debug { "" } diff --git a/tests/ui/impl-trait/in-trait/default-body.rs b/tests/ui/impl-trait/in-trait/default-body.rs index 5674507ad12ca..6350b8dc88e04 100644 --- a/tests/ui/impl-trait/in-trait/default-body.rs +++ b/tests/ui/impl-trait/in-trait/default-body.rs @@ -4,7 +4,6 @@ use std::fmt::Debug; trait Foo { - #[allow(async_fn_in_trait)] async fn baz(&self) -> &str { "" } diff --git a/tests/ui/impl-trait/in-trait/early.rs b/tests/ui/impl-trait/in-trait/early.rs index 294be02ad8d7d..e6d68d9dd93ff 100644 --- a/tests/ui/impl-trait/in-trait/early.rs +++ b/tests/ui/impl-trait/in-trait/early.rs @@ -2,7 +2,6 @@ //@ edition:2021 pub trait Foo { - #[allow(async_fn_in_trait)] async fn bar<'a: 'a>(&'a mut self); } diff --git a/tests/ui/impl-trait/in-trait/suggest-missing-item.fixed b/tests/ui/impl-trait/in-trait/suggest-missing-item.fixed index 6764ab002a9d6..537aa5089fb58 100644 --- a/tests/ui/impl-trait/in-trait/suggest-missing-item.fixed +++ b/tests/ui/impl-trait/in-trait/suggest-missing-item.fixed @@ -3,15 +3,12 @@ #![allow(dead_code)] trait Trait { - #[allow(async_fn_in_trait)] async fn foo(); - #[allow(async_fn_in_trait)] async fn bar() -> i32; fn test(&self) -> impl Sized + '_; - #[allow(async_fn_in_trait)] async fn baz(&self) -> &i32; } diff --git a/tests/ui/impl-trait/in-trait/suggest-missing-item.rs b/tests/ui/impl-trait/in-trait/suggest-missing-item.rs index 99a8bfe79fd28..df6e8c1633ba7 100644 --- a/tests/ui/impl-trait/in-trait/suggest-missing-item.rs +++ b/tests/ui/impl-trait/in-trait/suggest-missing-item.rs @@ -3,15 +3,12 @@ #![allow(dead_code)] trait Trait { - #[allow(async_fn_in_trait)] async fn foo(); - #[allow(async_fn_in_trait)] async fn bar() -> i32; fn test(&self) -> impl Sized + '_; - #[allow(async_fn_in_trait)] async fn baz(&self) -> &i32; } diff --git a/tests/ui/impl-trait/in-trait/suggest-missing-item.stderr b/tests/ui/impl-trait/in-trait/suggest-missing-item.stderr index 45fd79badb30f..c24526b89a06f 100644 --- a/tests/ui/impl-trait/in-trait/suggest-missing-item.stderr +++ b/tests/ui/impl-trait/in-trait/suggest-missing-item.stderr @@ -1,15 +1,15 @@ error[E0046]: not all trait items implemented, missing: `foo`, `bar`, `test`, `baz` - --> $DIR/suggest-missing-item.rs:20:1 + --> $DIR/suggest-missing-item.rs:17:1 | LL | async fn foo(); | --------------- `foo` from trait -... +LL | LL | async fn bar() -> i32; | ---------------------- `bar` from trait LL | LL | fn test(&self) -> impl Sized + '_; | ---------------------------------- `test` from trait -... +LL | LL | async fn baz(&self) -> &i32; | ---------------------------- `baz` from trait ...