diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index b15ea5da6f0cb..35ac1c41fc1a1 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -611,6 +611,8 @@ declare_features! ( (unstable, lahfsahf_target_feature, "1.78.0", Some(150251)), /// Allows setting the threshold for the `large_assignments` lint. (unstable, large_assignments, "1.52.0", Some(83518)), + /// Allow late-bound lifetimes to be specified explicitly using turbofish syntax. + (unstable, late_bound_turbofishing, "1.98.0", Some(156581)), /// Allows using `#[link(kind = "link-arg", name = "...")]` /// to pass custom arguments to the linker. (unstable, link_arg_attribute, "1.76.0", Some(99427)), diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index a465c1d95f6c8..233b8c7d64a83 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -830,6 +830,7 @@ pub enum GenericParamKind<'hir> { /// A lifetime definition (e.g., `'a: 'b + 'c + 'd`). Lifetime { kind: LifetimeParamKind, + // FIXME(addiesh): add late_bound: bool, }, Type { default: Option<&'hir Ty<'hir>>, diff --git a/compiler/rustc_hir_analysis/src/collect/generics_of.rs b/compiler/rustc_hir_analysis/src/collect/generics_of.rs index dcc5579e14339..e48c958fad769 100644 --- a/compiler/rustc_hir_analysis/src/collect/generics_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/generics_of.rs @@ -60,9 +60,10 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { parent: Some(trait_def_id), parent_count, own_params, + own_lifetime_params: opaque_ty_generics.own_lifetime_params.clone(), param_def_id_to_index, has_self: opaque_ty_generics.has_self, - has_late_bound_regions: opaque_ty_generics.has_late_bound_regions, + own_late_bound_regions: opaque_ty_generics.own_late_bound_regions.clone(), }; } @@ -155,9 +156,10 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { parent: generics.parent, parent_count: generics.parent_count, own_params, + own_lifetime_params: generics.own_lifetime_params.clone(), param_def_id_to_index, has_self: generics.has_self, - has_late_bound_regions: generics.has_late_bound_regions, + own_late_bound_regions: generics.own_late_bound_regions.clone(), }; } ty::AnonConstKind::GCE => Some(parent_did), @@ -269,6 +271,22 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { own_params.push(opt_self); } + let own_lifetime_params = hir_generics + .params + .iter() + .enumerate() + .filter_map(|(i, param)| match param.kind { + GenericParamKind::Lifetime { .. } => Some(ty::GenericParamDef { + name: param.name.ident().name, + index: own_start + i as u32, + def_id: param.def_id.to_def_id(), + pure_wrt_drop: param.pure_wrt_drop, + kind: ty::GenericParamDefKind::Lifetime, + }), + _ => None, + }) + .collect::>(); + let early_lifetimes = super::early_bound_lifetimes_from_generics(tcx, hir_generics); own_params.extend(early_lifetimes.enumerate().map(|(i, param)| ty::GenericParamDef { name: param.name.ident().name, @@ -394,9 +412,10 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { parent: parent_def_id.map(LocalDefId::to_def_id), parent_count, own_params, + own_lifetime_params, param_def_id_to_index, has_self: has_self || parent_has_self, - has_late_bound_regions: has_late_bound_regions(tcx, node), + own_late_bound_regions: late_bound_regions(tcx, node), } } @@ -442,7 +461,7 @@ fn param_default_policy(node: Node<'_>) -> Option { }) } -fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx>, node: Node<'tcx>) -> Option { +fn late_bound_regions<'tcx>(tcx: TyCtxt<'tcx>, node: Node<'tcx>) -> Vec { struct LateBoundRegionsDetector<'tcx> { tcx: TyCtxt<'tcx>, outer_index: ty::DebruijnIndex, @@ -495,25 +514,37 @@ fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx>, node: Node<'tcx>) -> Option( + fn late_bound_regions<'tcx>( tcx: TyCtxt<'tcx>, generics: &'tcx hir::Generics<'tcx>, decl: &'tcx hir::FnDecl<'tcx>, - ) -> Option { + ) -> Vec { let mut visitor = LateBoundRegionsDetector { tcx, outer_index: ty::INNERMOST }; - for param in generics.params { - if let GenericParamKind::Lifetime { .. } = param.kind { - if tcx.is_late_bound(param.hir_id) { - return Some(param.span); + + let spans = generics + .params + .iter() + .flat_map(|param| { + if let GenericParamKind::Lifetime { .. } = param.kind + && tcx.is_late_bound(param.hir_id) + { + Some(param.span) + } else { + None } - } + }) + .collect::>(); + + if !spans.is_empty() { + spans + } else { + visitor.visit_fn_decl(decl).break_value().map_or_default(|val| vec![val]) } - visitor.visit_fn_decl(decl).break_value() } - let decl = node.fn_decl()?; - let generics = node.generics()?; - has_late_bound_regions(tcx, generics, decl) + let Some(decl) = node.fn_decl() else { return vec![] }; + let Some(generics) = node.generics() else { return vec![] }; + late_bound_regions(tcx, generics, decl) } struct AnonConstInParamTyDetector { diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs index 45c2ed205c74d..80a8081331a67 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs @@ -399,7 +399,7 @@ pub fn check_generic_arg_count_for_value_path( /// Checks that the correct number of generic arguments have been provided. /// This is used both for datatypes and function calls. -#[instrument(skip(cx, gen_pos), level = "debug")] +#[instrument(skip(cx, gen_pos), level = "info")] pub(crate) fn check_generic_arg_count( cx: &dyn HirTyLowerer<'_>, def_id: DefId, @@ -409,6 +409,8 @@ pub(crate) fn check_generic_arg_count( has_self: bool, ) -> GenericArgCountResult { let gen_args = seg.args(); + let tcx = cx.tcx(); + let kind = tcx.def_kind(def_id); let default_counts = gen_params.own_defaults(); let param_counts = gen_params.own_counts(); @@ -430,7 +432,33 @@ pub(crate) fn check_generic_arg_count( prohibit_assoc_item_constraint(cx, c, None); } - let tcx = cx.tcx(); + // hidden lifetimes may not be specified explicitly. + // if it doesn't show up in the function signature, + // it can't be written as a lifetime arg. + // + // While most hidden lifetimes are late-bound (e.g. `fn(_: &u32)` ), + // there are some cases (complicated and involve associated types) + // where an early-bound lifetime parameter can be hidden from the function signature. + // + // see: + + let hidden_early_lifetimes = + gen_params.own_params.iter().filter(|x| x.is_anonymous_lifetime()).count(); + + let hidden_late_lifetimes = + gen_params.own_lifetime_params.iter().filter(|x| x.is_anonymous_lifetime()).count() + - hidden_early_lifetimes; + + debug!(?hidden_early_lifetimes, ?hidden_late_lifetimes); + + let late_bound_lt_count = gen_params.own_late_bound_regions.len(); + + if kind.is_fn_like() { + debug!("we are using fn-like {:?} ({gen_pos:?})", tcx.item_name(def_id)); + } + debug!(?late_bound_lt_count); + debug!("gen_args count = {}", gen_args.args.len()); + debug!("lb+eb lifetimes={:?}", gen_params.own_lifetime_params); // Suppress this warning for delegations as it is compiler generated and lifetimes are // propagated while late-bound lifetimes may be present. @@ -449,7 +477,7 @@ pub(crate) fn check_generic_arg_count( return Ok(()); } - if late_bounds_ignore { + if late_bounds_ignore && !tcx.features().late_bound_turbofishing() { return Ok(()); } @@ -476,9 +504,22 @@ pub(crate) fn check_generic_arg_count( Err(reported) }; - let min_expected_lifetime_args = if infer_lifetimes { 0 } else { param_counts.lifetimes }; - let max_expected_lifetime_args = param_counts.lifetimes; + let min_expected_lifetime_args = + if infer_lifetimes { 0 } else { param_counts.lifetimes - hidden_early_lifetimes }; + debug!(?min_expected_lifetime_args); + + let mut max_expected_lifetime_args = param_counts.lifetimes - hidden_early_lifetimes; + + // FIXME: under certain circumstances (which I have had trouble replicating) + // this leads to subtraction with overflow + if tcx.features().late_bound_turbofishing() { + max_expected_lifetime_args = + max_expected_lifetime_args + late_bound_lt_count - hidden_late_lifetimes; + } + debug!(?max_expected_lifetime_args,); + let num_provided_lifetime_args = gen_args.num_lifetime_args(); + debug!(?num_provided_lifetime_args,); let lifetimes_correct = check_lifetime_args( min_expected_lifetime_args, @@ -542,7 +583,7 @@ pub(crate) fn check_generic_arg_count( .map(|param| param.name) .collect(); if constraint_names == param_names { - let has_assoc_ty_with_same_name = if let DefKind::Trait = tcx.def_kind(def_id) { + let has_assoc_ty_with_same_name = if let DefKind::Trait = kind { gen_args.constraints.iter().any(|constraint| { traits::supertrait_def_ids(tcx, def_id).any(|trait_did| { cx.probe_trait_that_defines_assoc_item( @@ -633,20 +674,27 @@ pub(crate) fn prohibit_explicit_late_bound_lifetimes( ) -> ExplicitLateBound { struct LifetimeArgsIssue { msg: &'static str, + note: &'static str, } impl<'a> Diagnostic<'a, ()> for LifetimeArgsIssue { fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { - let Self { msg } = self; - Diag::new(dcx, level, msg) + let Self { msg, note } = self; + Diag::new(dcx, level, msg).with_note(note) } } let param_counts = def.own_counts(); - if let Some(span_late) = def.has_late_bound_regions + // FIXME(addiesh): just turning off the diagnostic is probably not enough to solve the problem. see: + // https://rust-lang.zulipchat.com/#narrow/channel/600108-t-types.2Fearly-late-cleanup/topic/turbofishing.20elided.20lifetimes/near/607748866 + if cx.tcx().features().late_bound_turbofishing() { + ExplicitLateBound::Yes + } else if let Some(span_late) = def.own_late_bound_regions.first().copied() && args.has_lifetime_args() { + let gone_turbofishing = "this may change in the future; see issue #156581 for more information"; + let msg = "cannot specify lifetime arguments explicitly \ if late bound lifetime parameters are present"; let note = "the late bound lifetime parameter is introduced here"; @@ -657,6 +705,7 @@ pub(crate) fn prohibit_explicit_late_bound_lifetimes( { struct_span_code_err!(cx.dcx(), span, E0794, "{}", msg) .with_span_note(span_late, note) + .with_note(gone_turbofishing) .emit(); } else { let mut multispan = MultiSpan::from_span(span); @@ -665,7 +714,7 @@ pub(crate) fn prohibit_explicit_late_bound_lifetimes( LATE_BOUND_LIFETIME_ARGUMENTS, args.args[0].hir_id(), multispan, - LifetimeArgsIssue { msg }, + LifetimeArgsIssue { msg, note: gone_turbofishing }, ); } diff --git a/compiler/rustc_middle/src/ty/generics.rs b/compiler/rustc_middle/src/ty/generics.rs index 0599f51305575..e8841c770e710 100644 --- a/compiler/rustc_middle/src/ty/generics.rs +++ b/compiler/rustc_middle/src/ty/generics.rs @@ -105,7 +105,7 @@ impl GenericParamDef { } } -#[derive(Default)] +#[derive(Debug, Default)] pub struct GenericParamCount { pub lifetimes: usize, pub types: usize, @@ -121,14 +121,30 @@ pub struct GenericParamCount { pub struct Generics { pub parent: Option, pub parent_count: usize, + // FIXME: eventually we should probably include + // late-bound lifetimes in ty::Generics. + // LBLTs _are still lifetimes_ and + // I think it's kind of weird how hard it is + // to look them up without access to HIR. + /// The generic params of the item/method (excluding late-bound lifetimes) pub own_params: Vec, + /// **You probably want to use `own_params` instead.** + /// + /// Contains all lifetime parameters + /// _(including late-bound lifetimes)_ + /// on the item/method. + /// This is only used for behavior + /// involving late-bound lifetimes and will probably be + /// removed entirely in the future. + pub own_lifetime_params: Vec, + /// Reverse map to the `index` field of each `GenericParamDef`. #[stable_hash(ignore)] pub param_def_id_to_index: FxHashMap, pub has_self: bool, - pub has_late_bound_regions: Option, + pub own_late_bound_regions: Vec, } impl std::fmt::Debug for Generics { @@ -143,7 +159,7 @@ impl std::fmt::Debug for Generics { .field("own_params", &self.own_params) .field("param_def_id_to_index", &stabilized_hashmap) .field("has_self", &self.has_self) - .field("has_late_bound_regions", &self.has_late_bound_regions) + .field("own_late_bound_regions", &self.own_late_bound_regions) .finish() } } diff --git a/compiler/rustc_public/src/unstable/convert/stable/ty.rs b/compiler/rustc_public/src/unstable/convert/stable/ty.rs index 17edd29dcbb42..bbd5b612b6a33 100644 --- a/compiler/rustc_public/src/unstable/convert/stable/ty.rs +++ b/compiler/rustc_public/src/unstable/convert/stable/ty.rs @@ -681,8 +681,10 @@ impl<'tcx> Stable<'tcx> for ty::Generics { params, param_def_id_to_index, has_self: self.has_self, + // FIXME: this type def has not been updated in rustc public has_late_bound_regions: self - .has_late_bound_regions + .own_late_bound_regions + .first() .as_ref() .map(|late_bound_regions| late_bound_regions.stable(tables, cx)), } diff --git a/compiler/rustc_ty_utils/src/assoc.rs b/compiler/rustc_ty_utils/src/assoc.rs index de94087498c75..e19c52e517c94 100644 --- a/compiler/rustc_ty_utils/src/assoc.rs +++ b/compiler/rustc_ty_utils/src/assoc.rs @@ -356,9 +356,10 @@ fn associated_type_for_impl_trait_in_impl( parent: Some(impl_local_def_id.to_def_id()), parent_count, own_params, + own_lifetime_params: trait_assoc_generics.own_lifetime_params.clone(), param_def_id_to_index, has_self: false, - has_late_bound_regions: trait_assoc_generics.has_late_bound_regions, + own_late_bound_regions: trait_assoc_generics.own_late_bound_regions.clone(), } }); diff --git a/tests/incremental/hashes/inherent_impls.rs b/tests/incremental/hashes/inherent_impls.rs index e2261f779a2e8..04299e9c887a7 100644 --- a/tests/incremental/hashes/inherent_impls.rs +++ b/tests/incremental/hashes/inherent_impls.rs @@ -421,7 +421,7 @@ impl Foo { // ---------------------------------------------------------- // ----------------------------------------------------------- // ---------------------------------------------------------- - // ---------------------------------------------------------------------- + // ---------------------------------------------------------------------------------- // ------------------------- // ---------------------------------------------------------------------------------- // ------------------------- @@ -443,7 +443,7 @@ impl Foo { // if we lower generics before the body, then the `HirId` for // things in the body will be affected. So if you start to see // `typeck_root` appear dirty, that might be the cause. -nmatsakis - #[rustc_clean(cfg="bpass2", except="hir_owner,fn_sig,type_of")] + #[rustc_clean(cfg="bpass2", except="hir_owner,fn_sig,type_of,generics_of")] #[rustc_clean(cfg="bpass3")] #[rustc_clean(cfg="bpass5", except="hir_owner,fn_sig,type_of,generics_of")] #[rustc_clean(cfg="bpass6")] diff --git a/tests/ui/attributes/dump_generics.rs b/tests/ui/attributes/dump_generics.rs index 8456bccc512e7..2c5d0be984338 100644 --- a/tests/ui/attributes/dump_generics.rs +++ b/tests/ui/attributes/dump_generics.rs @@ -57,6 +57,7 @@ const fn i_dare_you<'a: 'a, 'b, const N: usize, T, U>(you_can: &'a bool, _: &'b let _to_find_it = if *you_can { 1 } else { 2 }; let we_got_to_find_the_foundation = + // FIXME: it isn't doing anything here #[rustc_dump_generics] || {}; // and you gotta help us! diff --git a/tests/ui/attributes/dump_generics.stderr b/tests/ui/attributes/dump_generics.stderr index 5a212e01e8cbc..827e900bb821c 100644 --- a/tests/ui/attributes/dump_generics.stderr +++ b/tests/ui/attributes/dump_generics.stderr @@ -89,7 +89,7 @@ note: Generics { ), ], has_self: true, - has_late_bound_regions: None, + own_late_bound_regions: [], } --> $DIR/dump_generics.rs:8:1 | @@ -187,7 +187,7 @@ note: Generics { ), ], has_self: true, - has_late_bound_regions: None, + own_late_bound_regions: [], } --> $DIR/dump_generics.rs:28:1 | @@ -271,7 +271,7 @@ note: Generics { ), ], has_self: false, - has_late_bound_regions: None, + own_late_bound_regions: [], } --> $DIR/dump_generics.rs:33:1 | @@ -355,7 +355,7 @@ note: Generics { ), ], has_self: false, - has_late_bound_regions: None, + own_late_bound_regions: [], } --> $DIR/dump_generics.rs:40:1 | @@ -439,7 +439,7 @@ note: Generics { ), ], has_self: false, - has_late_bound_regions: None, + own_late_bound_regions: [], } --> $DIR/dump_generics.rs:48:1 | @@ -512,9 +512,9 @@ note: Generics { ), ], has_self: false, - has_late_bound_regions: Some( + own_late_bound_regions: [ $DIR/dump_generics.rs:55:29: 55:31 (#0), - ), + ], } --> $DIR/dump_generics.rs:55:1 | @@ -522,7 +522,7 @@ LL | const fn i_dare_you<'a: 'a, 'b, const N: usize, T, U>(you_can: &'a bool, _: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: rustc_dump_generics: DefId(..) - --> $DIR/dump_generics.rs:66:1 + --> $DIR/dump_generics.rs:67:1 | LL | trait IfYouNeed<'_a: '_a, '_b, const N: usize, T, U: Clone> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -612,15 +612,15 @@ note: Generics { ), ], has_self: true, - has_late_bound_regions: None, + own_late_bound_regions: [], } - --> $DIR/dump_generics.rs:66:1 + --> $DIR/dump_generics.rs:67:1 | LL | trait IfYouNeed<'_a: '_a, '_b, const N: usize, T, U: Clone> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: rustc_dump_generics: DefId(..) - --> $DIR/dump_generics.rs:70:1 + --> $DIR/dump_generics.rs:71:1 | LL | type Instructions<'a: 'a, 'b, const N: usize, T, U: Clone> = dyn IfYouNeed<'a, 'b, N, T, U>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -696,15 +696,15 @@ note: Generics { ), ], has_self: false, - has_late_bound_regions: None, + own_late_bound_regions: [], } - --> $DIR/dump_generics.rs:70:1 + --> $DIR/dump_generics.rs:71:1 | LL | type Instructions<'a: 'a, 'b, const N: usize, T, U: Clone> = dyn IfYouNeed<'a, 'b, N, T, U>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: rustc_dump_generics: DefId(..) - --> $DIR/dump_generics.rs:74:1 + --> $DIR/dump_generics.rs:75:1 | LL | const ON_HOW_TO_GET: usize = <() as NiceOfTheFoundation::<'static, 'static, 7, (), ()>>::OVER_FOR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -715,9 +715,9 @@ note: Generics { own_params: [], param_def_id_to_index: [], has_self: false, - has_late_bound_regions: None, + own_late_bound_regions: [], } - --> $DIR/dump_generics.rs:74:1 + --> $DIR/dump_generics.rs:75:1 | LL | const ON_HOW_TO_GET: usize = <() as NiceOfTheFoundation::<'static, 'static, 7, (), ()>>::OVER_FOR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -752,7 +752,7 @@ note: Generics { ), ], has_self: true, - has_late_bound_regions: None, + own_late_bound_regions: [], } --> $DIR/dump_generics.rs:12:5 | @@ -773,7 +773,7 @@ note: Generics { own_params: [], param_def_id_to_index: [], has_self: true, - has_late_bound_regions: None, + own_late_bound_regions: [], } --> $DIR/dump_generics.rs:16:5 | @@ -813,9 +813,9 @@ note: Generics { ), ], has_self: true, - has_late_bound_regions: Some( + own_late_bound_regions: [ $DIR/dump_generics.rs:21:9: 21:10 (#0), - ), + ], } --> $DIR/dump_generics.rs:20:5 | diff --git a/tests/ui/const-generics/const-arg-in-const-arg.min.stderr b/tests/ui/const-generics/const-arg-in-const-arg.min.stderr index 9ab0a3f137d74..3b83f34e754b6 100644 --- a/tests/ui/const-generics/const-arg-in-const-arg.min.stderr +++ b/tests/ui/const-generics/const-arg-in-const-arg.min.stderr @@ -250,6 +250,7 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ + = note: this may change in the future; see issue #156581 for more information error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:21:23 @@ -262,6 +263,7 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ + = note: this may change in the future; see issue #156581 for more information error: constant expression depends on a generic parameter --> $DIR/const-arg-in-const-arg.rs:25:17 @@ -301,6 +303,7 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ + = note: this may change in the future; see issue #156581 for more information error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:32:23 @@ -313,6 +316,7 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ + = note: this may change in the future; see issue #156581 for more information error[E0747]: unresolved item provided when a constant was expected --> $DIR/const-arg-in-const-arg.rs:36:24 @@ -336,6 +340,7 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ + = note: this may change in the future; see issue #156581 for more information error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:41:24 @@ -348,6 +353,7 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ + = note: this may change in the future; see issue #156581 for more information error[E0747]: unresolved item provided when a constant was expected --> $DIR/const-arg-in-const-arg.rs:45:27 @@ -371,6 +377,7 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ + = note: this may change in the future; see issue #156581 for more information error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:50:27 @@ -383,6 +390,7 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ + = note: this may change in the future; see issue #156581 for more information error: aborting due to 37 previous errors diff --git a/tests/ui/const-generics/issues/issue-83466.stderr b/tests/ui/const-generics/issues/issue-83466.stderr index 5a0f5cbd131be..d1b44e8f101fa 100644 --- a/tests/ui/const-generics/issues/issue-83466.stderr +++ b/tests/ui/const-generics/issues/issue-83466.stderr @@ -7,6 +7,7 @@ LL | fn func<'a, U>(self) -> U { LL | S.func::<'a, 10_u32>() | ^^ | + = note: this may change in the future; see issue #156581 for more information = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 = note: `#[warn(late_bound_lifetime_arguments)]` (part of `#[warn(future_incompatible)]`) on by default diff --git a/tests/ui/feature-gates/feature-gate-late-bound-turbofishing.rs b/tests/ui/feature-gates/feature-gate-late-bound-turbofishing.rs new file mode 100644 index 0000000000000..fc34f2446d610 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-late-bound-turbofishing.rs @@ -0,0 +1,10 @@ +// FIXME: eventually replace E0794 with E0658 + +// 'a is late bound +fn foo<'a>(b: &'a u32) -> &'a u32 { b } + +fn main() { + // error + let f /* : FooFnItem */ = foo::<'static>; + //~^ ERROR +} diff --git a/tests/ui/feature-gates/feature-gate-late-bound-turbofishing.stderr b/tests/ui/feature-gates/feature-gate-late-bound-turbofishing.stderr new file mode 100644 index 0000000000000..d47f60d4905c1 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-late-bound-turbofishing.stderr @@ -0,0 +1,16 @@ +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/feature-gate-late-bound-turbofishing.rs:8:43 + | +LL | let f /* : FooFnItem */ = foo::<'static>; + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/feature-gate-late-bound-turbofishing.rs:4:8 + | +LL | fn foo<'a>(b: &'a u32) -> &'a u32 { b } + | ^^ + = note: this may change in the future; see issue #156581 for more information + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0794`. diff --git a/tests/ui/late-bound-lifetimes/issue-80618.stderr b/tests/ui/late-bound-lifetimes/issue-80618.stderr index 28ea61f38a3ec..67063ae4c6fc8 100644 --- a/tests/ui/late-bound-lifetimes/issue-80618.stderr +++ b/tests/ui/late-bound-lifetimes/issue-80618.stderr @@ -9,6 +9,7 @@ note: the late bound lifetime parameter is introduced here | LL | fn foo<'a>(x: &'a str) -> &'a str { | ^^ + = note: this may change in the future; see issue #156581 for more information error: aborting due to 1 previous error diff --git a/tests/ui/lifetimes/late-bound-lifetime-arguments-warning-72278.stderr b/tests/ui/lifetimes/late-bound-lifetime-arguments-warning-72278.stderr index cffdf0df83cc6..7d4c3d21180ea 100644 --- a/tests/ui/lifetimes/late-bound-lifetime-arguments-warning-72278.stderr +++ b/tests/ui/lifetimes/late-bound-lifetime-arguments-warning-72278.stderr @@ -7,6 +7,7 @@ LL | fn func<'a, U>(&'a self) -> U { LL | S.func::<'a, U>() | ^^ | + = note: this may change in the future; see issue #156581 for more information = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 = note: `#[warn(late_bound_lifetime_arguments)]` (part of `#[warn(future_incompatible)]`) on by default diff --git a/tests/ui/lifetimes/late-bound-lifetime-parameters-60622.stderr b/tests/ui/lifetimes/late-bound-lifetime-parameters-60622.stderr index 880513e02823b..5675fa15b160d 100644 --- a/tests/ui/lifetimes/late-bound-lifetime-parameters-60622.stderr +++ b/tests/ui/lifetimes/late-bound-lifetime-parameters-60622.stderr @@ -7,6 +7,7 @@ LL | fn a(&self) {} LL | b.a::<'_, T>(); | ^^ | + = note: this may change in the future; see issue #156581 for more information = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 note: the lint level is defined here diff --git a/tests/ui/lifetimes/late-bound-turbofishing-basic.rs b/tests/ui/lifetimes/late-bound-turbofishing-basic.rs new file mode 100644 index 0000000000000..0b44da14c008d --- /dev/null +++ b/tests/ui/lifetimes/late-bound-turbofishing-basic.rs @@ -0,0 +1,17 @@ +#![feature(late_bound_turbofishing)] + +fn foo_early<'a: 'a>(b: &'a u32) -> &'a u32 { b } +fn foo_late<'a>(b: &'a u32) -> &'a u32 { b } +fn foo_latest(_: &u32) {} + +fn require_static(_: T) { } + +fn main() { + let f = foo_early::<'static>; + require_static(f); + let f = foo_late::<'static>; + require_static(f); + let f = foo_latest::<'static>; + //~^ ERROR: function takes 0 lifetime arguments but 1 lifetime argument was supplied [E0107] + require_static(f); +} diff --git a/tests/ui/lifetimes/late-bound-turbofishing-basic.stderr b/tests/ui/lifetimes/late-bound-turbofishing-basic.stderr new file mode 100644 index 0000000000000..af261e98d95ea --- /dev/null +++ b/tests/ui/lifetimes/late-bound-turbofishing-basic.stderr @@ -0,0 +1,17 @@ +error[E0107]: function takes 0 lifetime arguments but 1 lifetime argument was supplied + --> $DIR/late-bound-turbofishing-basic.rs:14:13 + | +LL | let f = foo_latest::<'static>; + | ^^^^^^^^^^----------- help: remove the unnecessary generics + | | + | expected 0 lifetime arguments + | +note: function defined here, with 0 lifetime parameters + --> $DIR/late-bound-turbofishing-basic.rs:5:4 + | +LL | fn foo_latest(_: &u32) {} + | ^^^^^^^^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/lifetimes/late-bound-turbofishing.rs b/tests/ui/lifetimes/late-bound-turbofishing.rs new file mode 100644 index 0000000000000..6ecced5954864 --- /dev/null +++ b/tests/ui/lifetimes/late-bound-turbofishing.rs @@ -0,0 +1,175 @@ +#![feature(late_bound_turbofishing)] + +fn require_static(_: T) { } +fn foo_early<'a: 'a>(b: &'a u32) -> &'a u32 { b } +fn foo_late<'a>(b: &'a u32) -> &'a u32 { b } +fn foo_latest(_: &u32) {} + +mod ex1 { + // compiles without errors + + trait Trait { + type Assoc<'a>; + } + + // zero explicit generic lifetimes + fn do_thing(_: Option<::Assoc<'_>>) -> &u32 { + todo!() + } + + fn foo() { + // one explicit generic lifetime + do_thing::<'static, T>(None); + //~^ ERROR: function takes 0 lifetime arguments but 1 lifetime argument was supplied [E0107] + } +} + +mod ex2 { + // compiles without errors + + trait Trait { + type Assoc<'a>; + } + + // one explicit generic lifetime + fn do_thing<'b, T: Trait>(_: Option<::Assoc<'_>>) -> (&u32, &'b i64) { + todo!() + } + + fn foo() { + // two explicit generic lifetimes + do_thing::<'static, 'static, T>(None); + //~^ ERROR: function takes 1 lifetime argument but 2 lifetime arguments were supplied [E0107] + } +} + +mod ex3 { + // compiles without errors + + trait Trait { + type Assoc<'a>; + } + + // zero explicit generic lifetimes + fn do_thing(_: Option<::Assoc<'_>>) -> u32 { + todo!() + } + + fn foo() { + // one explicit generic lifetime + do_thing::<'static, T>(None); + //~^ ERROR: function takes 0 lifetime arguments but 1 lifetime argument was supplied + } +} + +mod ex4 { + // compiles without errors + + trait Trait { + type Assoc<'a>; + // zero explicit generic lifetimes + fn do_thing(_: Option>) -> &u32 { + todo!() + } + } + + fn foo() { + // one explicit generic lifetime + ::do_thing::<'static>(None); + //~^ ERROR: function takes 0 lifetime arguments but 1 lifetime argument was supplied + } +} + +mod ex5 { + // compiles without errors + + trait Trait { + type Assoc; + } + + // zero explicit generic lifetimes + fn do_thing(_: Option<<&T as Trait>::Assoc>) -> &u32 + where + for<'c> &'c T: Trait, + { + todo!() + } + + fn foo() + where + for<'c> &'c T: Trait, + { + // one explicit generic lifetime + do_thing::<'static, T>(None); + //~^ ERROR: function takes 0 lifetime arguments but 1 lifetime argument was supplied + } +} + +mod ex6 { + // compiles without errors + + trait Trait { + type Assoc<'a>; + // FIXME + // zero explicit generic lifetimes + fn do_thing(_: Option>) -> &u32; + } + + impl Trait for u32 { + type Assoc<'a> = i64; + // one explicit generic lifetime + fn do_thing<'b>(_: Option) -> &'b u32 { + todo!() + } + } +} + +mod ex7 { + pub struct ReqLtInvariant<'a, T>(&'a mut (*mut T)); + + fn require_static(_: T) {} + + fn require_exact<'a, T: 'a>(_: T) -> ReqLtInvariant<'a, T> { + ReqLtInvariant(todo!()) + } + + fn foo<'a>(b: &'a u32) -> &'a u32 { b } + + fn bar<'a>(n: &'a u32) { + let f1 = foo::<'static>; + require_static(f1); + require_exact::<'a>(f1); + // ^ this should not compile + f1(n); + + let f2 = foo::<'a>; + require_exact::<'a>(f2); + f2(n); + } + + fn munch() { + let f = foo::<'static>; + let freerf = 4u32; + bar(&freerf); + } +} + +fn bar<'a>(_: &'a u32) { + let f = foo_late::<'a>; + require_static(f); + // ^ FIXME: This SHOULD NOT COMPILE because it is UNSOUND but it does anyway. + // this is related to how FnDef has broken outlives checking. +} + +fn main() { + let f = foo_early::<'static>; + require_static(f); + let f = foo_late::<'static>; + require_static(f); + let f = foo_latest::<'static>; + //~^ ERROR: function takes 0 lifetime arguments but 1 lifetime argument was supplied [E0107] + require_static(f); + { + bar(&4) + } +} diff --git a/tests/ui/lifetimes/late-bound-turbofishing.stderr b/tests/ui/lifetimes/late-bound-turbofishing.stderr new file mode 100644 index 0000000000000..d2ada3878b5ec --- /dev/null +++ b/tests/ui/lifetimes/late-bound-turbofishing.stderr @@ -0,0 +1,87 @@ +error[E0107]: function takes 0 lifetime arguments but 1 lifetime argument was supplied + --> $DIR/late-bound-turbofishing.rs:22:9 + | +LL | do_thing::<'static, T>(None); + | ^^^^^^^^ ------- help: remove the lifetime argument + | | + | expected 0 lifetime arguments + | +note: function defined here, with 0 lifetime parameters + --> $DIR/late-bound-turbofishing.rs:16:8 + | +LL | fn do_thing(_: Option<::Assoc<'_>>) -> &u32 { + | ^^^^^^^^ + +error[E0107]: function takes 1 lifetime argument but 2 lifetime arguments were supplied + --> $DIR/late-bound-turbofishing.rs:41:9 + | +LL | do_thing::<'static, 'static, T>(None); + | ^^^^^^^^ --------- help: remove the lifetime argument + | | + | expected 1 lifetime argument + | +note: function defined here, with 1 lifetime parameter: `'b` + --> $DIR/late-bound-turbofishing.rs:35:8 + | +LL | fn do_thing<'b, T: Trait>(_: Option<::Assoc<'_>>) -> (&u32, &'b i64) { + | ^^^^^^^^ -- + +error[E0107]: function takes 0 lifetime arguments but 1 lifetime argument was supplied + --> $DIR/late-bound-turbofishing.rs:60:9 + | +LL | do_thing::<'static, T>(None); + | ^^^^^^^^ ------- help: remove the lifetime argument + | | + | expected 0 lifetime arguments + | +note: function defined here, with 0 lifetime parameters + --> $DIR/late-bound-turbofishing.rs:54:8 + | +LL | fn do_thing(_: Option<::Assoc<'_>>) -> u32 { + | ^^^^^^^^ + +error[E0107]: associated function takes 0 lifetime arguments but 1 lifetime argument was supplied + --> $DIR/late-bound-turbofishing.rs:78:23 + | +LL | ::do_thing::<'static>(None); + | ^^^^^^^^----------- help: remove the unnecessary generics + | | + | expected 0 lifetime arguments + | +note: associated function defined here, with 0 lifetime parameters + --> $DIR/late-bound-turbofishing.rs:71:12 + | +LL | fn do_thing(_: Option>) -> &u32 { + | ^^^^^^^^ + +error[E0107]: function takes 0 lifetime arguments but 1 lifetime argument was supplied + --> $DIR/late-bound-turbofishing.rs:103:9 + | +LL | do_thing::<'static, T>(None); + | ^^^^^^^^ ------- help: remove the lifetime argument + | | + | expected 0 lifetime arguments + | +note: function defined here, with 0 lifetime parameters + --> $DIR/late-bound-turbofishing.rs:91:8 + | +LL | fn do_thing(_: Option<<&T as Trait>::Assoc>) -> &u32 + | ^^^^^^^^ + +error[E0107]: function takes 0 lifetime arguments but 1 lifetime argument was supplied + --> $DIR/late-bound-turbofishing.rs:169:13 + | +LL | let f = foo_latest::<'static>; + | ^^^^^^^^^^----------- help: remove the unnecessary generics + | | + | expected 0 lifetime arguments + | +note: function defined here, with 0 lifetime parameters + --> $DIR/late-bound-turbofishing.rs:6:4 + | +LL | fn foo_latest(_: &u32) {} + | ^^^^^^^^^^ + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/lifetimes/turbofishing-invisible-lifetimes-154490.rs b/tests/ui/lifetimes/turbofishing-invisible-lifetimes-154490.rs new file mode 100644 index 0000000000000..52c7dda581054 --- /dev/null +++ b/tests/ui/lifetimes/turbofishing-invisible-lifetimes-154490.rs @@ -0,0 +1,73 @@ +// Unless we check for it, we can hide early-bound lifetime parameters on +// a function by using associated items. This is a bug. +// +// Regression test for + +trait EvilTrait { + type EvilAssoc<'a>; + fn evil_assoc_1(_: Option>) -> &i32 { + todo!() + } +} + +// zero explicit generic lifetimes +fn evil_early_bound_1(_: Option<::EvilAssoc<'_>>) -> &i32 { + todo!() +} + +fn evil_early_bound_2(_: Option<::EvilAssoc<'_>>) -> &i32 { + todo!() +} + +fn evil_multi_bound_3<'b, T: EvilTrait>( + _: Option<::EvilAssoc<'_>> +) -> (&i32, &'b i64) { + todo!() +} + +fn evil_early_bound_4(_: Option<::EvilAssoc<'_>>) -> i32 { + todo!() +} + +fn normal_early_bound<'eb: 'eb, T: EvilTrait>(_: &'eb i32 ) -> &'eb i32 { + todo!() +} + +fn normal_late_bound<'lb, T: EvilTrait>(_: &'lb i32 ) -> &'lb i32 { + todo!() +} + +struct LtWrapper<'a>(&'a i32); + +fn elide_struct_1(_: &i32) -> LtWrapper { + todo!() +} + +fn elide_struct_2(_: &i32) -> LtWrapper { + todo!() +} + +fn foo() { + static WHATEVER: i32 = 123; + + evil_early_bound_1::<'static, T>(None); + //~^ ERROR: function takes 0 lifetime arguments but 1 lifetime argument was supplied [E0107] + // ^ FIXME: should this have a better diagnostic? + evil_early_bound_2::(None); + evil_multi_bound_3::<'static, 'static, T>(None); + //~^ ERROR: function takes 1 lifetime argument but 2 lifetime arguments were supplied [E0107] + evil_early_bound_4::<'static, T>(None); + //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + ::evil_assoc_1::<'static>(None); + //~^ ERROR: associated function takes 0 lifetime arguments but 1 lifetime argument was supplied [E0107] + elide_struct_1(&WHATEVER); + elide_struct_2::<'static>(&WHATEVER); + //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] + normal_early_bound::<'static, T>(&WHATEVER); + // ^ this is fine + normal_late_bound::<'static, T>(&WHATEVER); + //~^ ERROR: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] +} + + +fn main() {} diff --git a/tests/ui/lifetimes/turbofishing-invisible-lifetimes-154490.stderr b/tests/ui/lifetimes/turbofishing-invisible-lifetimes-154490.stderr new file mode 100644 index 0000000000000..88b0032cf1194 --- /dev/null +++ b/tests/ui/lifetimes/turbofishing-invisible-lifetimes-154490.stderr @@ -0,0 +1,85 @@ +error[E0107]: function takes 0 lifetime arguments but 1 lifetime argument was supplied + --> $DIR/turbofishing-invisible-lifetimes-154490.rs:53:5 + | +LL | evil_early_bound_1::<'static, T>(None); + | ^^^^^^^^^^^^^^^^^^ ------- help: remove the lifetime argument + | | + | expected 0 lifetime arguments + | +note: function defined here, with 0 lifetime parameters + --> $DIR/turbofishing-invisible-lifetimes-154490.rs:14:4 + | +LL | fn evil_early_bound_1(_: Option<::EvilAssoc<'_>>) -> &i32 { + | ^^^^^^^^^^^^^^^^^^ + +error[E0107]: function takes 1 lifetime argument but 2 lifetime arguments were supplied + --> $DIR/turbofishing-invisible-lifetimes-154490.rs:57:5 + | +LL | evil_multi_bound_3::<'static, 'static, T>(None); + | ^^^^^^^^^^^^^^^^^^ --------- help: remove the lifetime argument + | | + | expected 1 lifetime argument + | +note: function defined here, with 1 lifetime parameter: `'b` + --> $DIR/turbofishing-invisible-lifetimes-154490.rs:22:4 + | +LL | fn evil_multi_bound_3<'b, T: EvilTrait>( + | ^^^^^^^^^^^^^^^^^^ -- + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/turbofishing-invisible-lifetimes-154490.rs:59:26 + | +LL | evil_early_bound_4::<'static, T>(None); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/turbofishing-invisible-lifetimes-154490.rs:28:75 + | +LL | fn evil_early_bound_4(_: Option<::EvilAssoc<'_>>) -> i32 { + | ^^ + = note: this may change in the future; see issue #156581 for more information + +error[E0107]: associated function takes 0 lifetime arguments but 1 lifetime argument was supplied + --> $DIR/turbofishing-invisible-lifetimes-154490.rs:61:23 + | +LL | ::evil_assoc_1::<'static>(None); + | ^^^^^^^^^^^^----------- help: remove the unnecessary generics + | | + | expected 0 lifetime arguments + | +note: associated function defined here, with 0 lifetime parameters + --> $DIR/turbofishing-invisible-lifetimes-154490.rs:8:8 + | +LL | fn evil_assoc_1(_: Option>) -> &i32 { + | ^^^^^^^^^^^^ + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/turbofishing-invisible-lifetimes-154490.rs:64:22 + | +LL | elide_struct_2::<'static>(&WHATEVER); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/turbofishing-invisible-lifetimes-154490.rs:46:22 + | +LL | fn elide_struct_2(_: &i32) -> LtWrapper { + | ^ + = note: this may change in the future; see issue #156581 for more information + +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/turbofishing-invisible-lifetimes-154490.rs:68:25 + | +LL | normal_late_bound::<'static, T>(&WHATEVER); + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/turbofishing-invisible-lifetimes-154490.rs:36:22 + | +LL | fn normal_late_bound<'lb, T: EvilTrait>(_: &'lb i32 ) -> &'lb i32 { + | ^^^ + = note: this may change in the future; see issue #156581 for more information + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0107, E0794. +For more information about an error, try `rustc --explain E0107`. diff --git a/tests/ui/methods/method-call-lifetime-args-fail.stderr b/tests/ui/methods/method-call-lifetime-args-fail.stderr index b251dd4d342f4..6f660f8843834 100644 --- a/tests/ui/methods/method-call-lifetime-args-fail.stderr +++ b/tests/ui/methods/method-call-lifetime-args-fail.stderr @@ -41,6 +41,7 @@ note: the late bound lifetime parameter is introduced here | LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} | ^^ + = note: this may change in the future; see issue #156581 for more information error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:29:15 @@ -53,6 +54,7 @@ note: the late bound lifetime parameter is introduced here | LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} | ^^ + = note: this may change in the future; see issue #156581 for more information error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:31:15 @@ -65,6 +67,7 @@ note: the late bound lifetime parameter is introduced here | LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} | ^^ + = note: this may change in the future; see issue #156581 for more information error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:34:21 @@ -77,6 +80,7 @@ note: the late bound lifetime parameter is introduced here | LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } | ^^ + = note: this may change in the future; see issue #156581 for more information error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:36:21 @@ -89,6 +93,7 @@ note: the late bound lifetime parameter is introduced here | LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } | ^^ + = note: this may change in the future; see issue #156581 for more information error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:40:24 @@ -101,6 +106,7 @@ note: the late bound lifetime parameter is introduced here | LL | fn late_implicit(self, _: &u8, _: &u8) {} | ^ + = note: this may change in the future; see issue #156581 for more information error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:42:24 @@ -113,6 +119,7 @@ note: the late bound lifetime parameter is introduced here | LL | fn late_implicit(self, _: &u8, _: &u8) {} | ^ + = note: this may change in the future; see issue #156581 for more information error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:44:24 @@ -125,6 +132,7 @@ note: the late bound lifetime parameter is introduced here | LL | fn late_implicit(self, _: &u8, _: &u8) {} | ^ + = note: this may change in the future; see issue #156581 for more information error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:47:30 @@ -137,6 +145,7 @@ note: the late bound lifetime parameter is introduced here | LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } | ^ + = note: this may change in the future; see issue #156581 for more information error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:49:30 @@ -149,6 +158,7 @@ note: the late bound lifetime parameter is introduced here | LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } | ^ + = note: this may change in the future; see issue #156581 for more information error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:52:35 @@ -161,6 +171,7 @@ note: the late bound lifetime parameter is introduced here | LL | fn late_implicit_self_early<'b>(&self) -> &'b u8 { loop {} } | ^ + = note: this may change in the future; see issue #156581 for more information error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:54:35 @@ -173,6 +184,7 @@ note: the late bound lifetime parameter is introduced here | LL | fn late_implicit_self_early<'b>(&self) -> &'b u8 { loop {} } | ^ + = note: this may change in the future; see issue #156581 for more information error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:57:28 @@ -185,6 +197,7 @@ note: the late bound lifetime parameter is introduced here | LL | fn late_unused_early<'a, 'b>(self) -> &'b u8 { loop {} } | ^^ + = note: this may change in the future; see issue #156581 for more information error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:59:28 @@ -197,6 +210,7 @@ note: the late bound lifetime parameter is introduced here | LL | fn late_unused_early<'a, 'b>(self) -> &'b u8 { loop {} } | ^^ + = note: this may change in the future; see issue #156581 for more information error[E0107]: method takes 2 lifetime arguments but 1 lifetime argument was supplied --> $DIR/method-call-lifetime-args-fail.rs:63:8 diff --git a/tests/ui/methods/method-call-lifetime-args-lint-fail.stderr b/tests/ui/methods/method-call-lifetime-args-lint-fail.stderr index 394c1ac3c09ee..621e6aa142221 100644 --- a/tests/ui/methods/method-call-lifetime-args-lint-fail.stderr +++ b/tests/ui/methods/method-call-lifetime-args-lint-fail.stderr @@ -7,6 +7,7 @@ LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} LL | S.late::<'static>(&0, &0); | ^^^^^^^ | + = note: this may change in the future; see issue #156581 for more information = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 note: the lint level is defined here @@ -24,6 +25,7 @@ LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} LL | S.late::<'static, 'static>(&0, &0); | ^^^^^^^ | + = note: this may change in the future; see issue #156581 for more information = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 @@ -36,6 +38,7 @@ LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} LL | S.late::<'static, 'static, 'static>(&0, &0); | ^^^^^^^ | + = note: this may change in the future; see issue #156581 for more information = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 @@ -48,6 +51,7 @@ LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } LL | S.late_early::<'static>(&0); | ^^^^^^^ | + = note: this may change in the future; see issue #156581 for more information = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 @@ -60,6 +64,7 @@ LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } LL | S.late_early::<'static, 'static>(&0); | ^^^^^^^ | + = note: this may change in the future; see issue #156581 for more information = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 @@ -72,6 +77,7 @@ LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } LL | S.late_early::<'static, 'static, 'static>(&0); | ^^^^^^^ | + = note: this may change in the future; see issue #156581 for more information = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 @@ -84,6 +90,7 @@ LL | fn late_implicit(self, _: &u8, _: &u8) {} LL | S.late_implicit::<'static>(&0, &0); | ^^^^^^^ | + = note: this may change in the future; see issue #156581 for more information = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 @@ -96,6 +103,7 @@ LL | fn late_implicit(self, _: &u8, _: &u8) {} LL | S.late_implicit::<'static, 'static>(&0, &0); | ^^^^^^^ | + = note: this may change in the future; see issue #156581 for more information = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 @@ -108,6 +116,7 @@ LL | fn late_implicit(self, _: &u8, _: &u8) {} LL | S.late_implicit::<'static, 'static, 'static>(&0, &0); | ^^^^^^^ | + = note: this may change in the future; see issue #156581 for more information = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 @@ -120,6 +129,7 @@ LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } LL | S.late_implicit_early::<'static>(&0); | ^^^^^^^ | + = note: this may change in the future; see issue #156581 for more information = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 @@ -132,6 +142,7 @@ LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } LL | S.late_implicit_early::<'static, 'static>(&0); | ^^^^^^^ | + = note: this may change in the future; see issue #156581 for more information = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 @@ -144,6 +155,7 @@ LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } LL | S.late_implicit_early::<'static, 'static, 'static>(&0); | ^^^^^^^ | + = note: this may change in the future; see issue #156581 for more information = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 @@ -156,6 +168,7 @@ LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } LL | S::late_early::<'static>(S, &0); | ^^^^^^^ | + = note: this may change in the future; see issue #156581 for more information = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 @@ -168,6 +181,7 @@ LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } LL | S::late_implicit_early::<'static>(S, &0); | ^^^^^^^ | + = note: this may change in the future; see issue #156581 for more information = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 @@ -180,6 +194,7 @@ LL | fn f<'early, 'late, T: 'early>() {} LL | f::<'static, u8>; | ^^^^^^^ | + = note: this may change in the future; see issue #156581 for more information = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 diff --git a/tests/ui/methods/method-call-lifetime-args-lint.stderr b/tests/ui/methods/method-call-lifetime-args-lint.stderr index b4fc2d71761c7..41cae1f0d8cf3 100644 --- a/tests/ui/methods/method-call-lifetime-args-lint.stderr +++ b/tests/ui/methods/method-call-lifetime-args-lint.stderr @@ -7,6 +7,7 @@ LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} LL | S.late::<'static>(&0, &0); | ^^^^^^^ | + = note: this may change in the future; see issue #156581 for more information = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 note: the lint level is defined here @@ -24,6 +25,7 @@ LL | fn late_implicit(self, _: &u8, _: &u8) {} LL | S.late_implicit::<'static>(&0, &0); | ^^^^^^^ | + = note: this may change in the future; see issue #156581 for more information = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 diff --git a/tests/ui/methods/method-call-lifetime-args-unresolved.stderr b/tests/ui/methods/method-call-lifetime-args-unresolved.stderr index cc8bd18449ab3..8b7cda8f184f0 100644 --- a/tests/ui/methods/method-call-lifetime-args-unresolved.stderr +++ b/tests/ui/methods/method-call-lifetime-args-unresolved.stderr @@ -19,6 +19,7 @@ LL | 0.clone::<'a>(); | = note: the late bound lifetime parameter is introduced here | + = note: this may change in the future; see issue #156581 for more information = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #42868 = note: `#[warn(late_bound_lifetime_arguments)]` (part of `#[warn(future_incompatible)]`) on by default diff --git a/tests/ui/methods/method-call-lifetime-args.stderr b/tests/ui/methods/method-call-lifetime-args.stderr index b215d5832171f..8dc7b32cb3bd0 100644 --- a/tests/ui/methods/method-call-lifetime-args.stderr +++ b/tests/ui/methods/method-call-lifetime-args.stderr @@ -9,6 +9,7 @@ note: the late bound lifetime parameter is introduced here | LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} | ^^ + = note: this may change in the future; see issue #156581 for more information error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args.rs:11:24 @@ -21,6 +22,7 @@ note: the late bound lifetime parameter is introduced here | LL | fn late_implicit(self, _: &u8, _: &u8) {} | ^ + = note: this may change in the future; see issue #156581 for more information error: aborting due to 2 previous errors