diff --git a/compiler/rustc_hir_analysis/src/astconv/generics.rs b/compiler/rustc_hir_analysis/src/astconv/generics.rs index 7f6518ffd7148..fbf47818239c9 100644 --- a/compiler/rustc_hir_analysis/src/astconv/generics.rs +++ b/compiler/rustc_hir_analysis/src/astconv/generics.rs @@ -6,7 +6,7 @@ use crate::astconv::{ use crate::errors::AssocTypeBindingNotAllowed; use crate::structured_errors::{GenericArgsInfo, StructuredDiagnostic, WrongNumberOfGenericArgs}; use rustc_ast::ast::ParamKindOrd; -use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorGuaranteed, MultiSpan}; +use rustc_errors::{struct_span_err, Applicability, Diagnostic, ErrorGuaranteed}; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::DefId; @@ -14,7 +14,6 @@ use rustc_hir::GenericArg; use rustc_middle::ty::{ self, subst, subst::SubstsRef, GenericParamDef, GenericParamDefKind, IsSuggestable, Ty, TyCtxt, }; -use rustc_session::lint::builtin::LATE_BOUND_LIFETIME_ARGUMENTS; use rustc_span::{symbol::kw, Span}; use smallvec::SmallVec; @@ -383,25 +382,13 @@ pub fn check_generic_arg_count_for_call( seg: &hir::PathSegment<'_>, is_method_call: IsMethodCall, ) -> GenericArgCountResult { - let empty_args = hir::GenericArgs::none(); - let gen_args = seg.args.unwrap_or(&empty_args); let gen_pos = match is_method_call { IsMethodCall::Yes => GenericArgPosition::MethodCall, IsMethodCall::No => GenericArgPosition::Value, }; let has_self = generics.parent.is_none() && generics.has_self; - check_generic_arg_count( - tcx, - span, - def_id, - seg, - generics, - gen_args, - gen_pos, - has_self, - seg.infer_args, - ) + check_generic_arg_count(tcx, span, def_id, seg, generics, gen_pos, has_self) } /// Checks that the correct number of generic arguments have been provided. @@ -413,13 +400,12 @@ pub(crate) fn check_generic_arg_count( def_id: DefId, seg: &hir::PathSegment<'_>, gen_params: &ty::Generics, - gen_args: &hir::GenericArgs<'_>, gen_pos: GenericArgPosition, has_self: bool, - infer_args: bool, ) -> GenericArgCountResult { let default_counts = gen_params.own_defaults(); let param_counts = gen_params.own_counts(); + let gen_args = seg.args(); // Subtracting from param count to ensure type params synthesized from `impl Trait` // cannot be explicitly specified. @@ -430,14 +416,13 @@ pub(crate) fn check_generic_arg_count( .count(); let named_type_param_count = param_counts.types - has_self as usize - synth_type_param_count; let infer_lifetimes = - (gen_pos != GenericArgPosition::Type || infer_args) && !gen_args.has_lifetime_params(); + (gen_pos != GenericArgPosition::Type || seg.infer_args) && !gen_args.has_lifetime_params(); if gen_pos != GenericArgPosition::Type && let Some(b) = gen_args.bindings.first() { prohibit_assoc_ty_binding(tcx, b.span); } - let explicit_late_bound = - prohibit_explicit_late_bound_lifetimes(tcx, gen_params, gen_args, gen_pos); + let explicit_late_bound = prohibit_explicit_late_bound_lifetimes(tcx, gen_params, seg, gen_pos); let mut invalid_args = vec![]; @@ -561,7 +546,7 @@ pub(crate) fn check_generic_arg_count( }; let args_correct = { - let expected_min = if infer_args { + let expected_min = if seg.infer_args { 0 } else { param_counts.consts + named_type_param_count @@ -599,10 +584,10 @@ pub fn prohibit_assoc_ty_binding(tcx: TyCtxt<'_>, span: Span) { pub(crate) fn prohibit_explicit_late_bound_lifetimes( tcx: TyCtxt<'_>, def: &ty::Generics, - args: &hir::GenericArgs<'_>, + seg: &hir::PathSegment<'_>, position: GenericArgPosition, ) -> ExplicitLateBound { - let param_counts = def.own_counts(); + let args = seg.args(); let infer_lifetimes = position != GenericArgPosition::Type && !args.has_lifetime_params(); if infer_lifetimes { @@ -611,27 +596,55 @@ pub(crate) fn prohibit_explicit_late_bound_lifetimes( if let Some(span_late) = def.has_late_bound_regions { let msg = "cannot specify lifetime arguments explicitly \ - if late bound lifetime parameters are present"; + if late bound lifetime parameters are present"; let note = "the late bound lifetime parameter is introduced here"; - let span = args.args[0].span(); - - if position == GenericArgPosition::Value - && args.num_lifetime_params() != param_counts.lifetimes - { - let mut err = tcx.sess.struct_span_err(span, msg); - err.span_note(span_late, note); - err.emit(); + let help = format!( + "remove the explicit lifetime argument{}", + rustc_errors::pluralize!(args.num_lifetime_params()) + ); + let spans: Vec<_> = args + .args + .iter() + .filter_map(|arg| match arg { + hir::GenericArg::Lifetime(l) => Some(l.ident.span), + _ => None, + }) + .collect(); + + let mut err = tcx.sess.struct_span_err(spans, msg); + err.span_note(span_late, note); + + let mut suggestions = vec![]; + if let Some(span_ext) = args.span_ext() { + if args.num_lifetime_params() == args.args.len() + && span_ext.ctxt() == seg.ident.span.ctxt() + { + // We only specify lifetime args, so suggest to remove everything. + suggestions.push((seg.ident.span.shrink_to_hi().to(span_ext), String::new())); + } else { + for [arg, next_arg] in args.args.array_windows() { + if let hir::GenericArg::Lifetime(lifetime) = arg + && let Some(arg_span) = lifetime.ident.span.find_ancestor_inside(span_ext) + && let Some(next_span_lo) = next_arg.span().shrink_to_lo().find_ancestor_inside(span_ext) + { + suggestions.push((arg_span.with_hi(next_span_lo.lo()), String::new())); + } + } + + if let Some(arg) = args.args.last() + && let hir::GenericArg::Lifetime(lifetime) = arg + && let Some(arg_span) = lifetime.ident.span.find_ancestor_inside(span_ext) + { + suggestions.push((arg_span, String::new())); + } + } + } + if !suggestions.is_empty() { + err.multipart_suggestion_verbose(help, suggestions, Applicability::MachineApplicable); } else { - let mut multispan = MultiSpan::from_span(span); - multispan.push_span_label(span_late, note); - tcx.struct_span_lint_hir( - LATE_BOUND_LIFETIME_ARGUMENTS, - args.args[0].hir_id(), - multispan, - msg, - |lint| lint, - ); + err.help(help); } + err.emit(); ExplicitLateBound::Yes } else { diff --git a/compiler/rustc_hir_analysis/src/astconv/mod.rs b/compiler/rustc_hir_analysis/src/astconv/mod.rs index a15cf454df72f..fdbba290576f4 100644 --- a/compiler/rustc_hir_analysis/src/astconv/mod.rs +++ b/compiler/rustc_hir_analysis/src/astconv/mod.rs @@ -288,8 +288,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { def_id, &[], item_segment, - item_segment.args(), - item_segment.infer_args, None, ty::BoundConstness::NotConst, ); @@ -332,14 +330,12 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { /// type itself: `['a]`. The returned `SubstsRef` concatenates these two /// lists: `[Vec, u8, 'a]`. #[instrument(level = "debug", skip(self, span), ret)] - fn create_substs_for_ast_path<'a>( + fn create_substs_for_ast_path( &self, span: Span, def_id: DefId, parent_substs: &[subst::GenericArg<'tcx>], seg: &hir::PathSegment<'_>, - generic_args: &'a hir::GenericArgs<'_>, - infer_args: bool, self_ty: Option>, constness: ty::BoundConstness, ) -> (SubstsRef<'tcx>, GenericArgCountResult) { @@ -370,10 +366,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { def_id, seg, generics, - generic_args, GenericArgPosition::Type, self_ty.is_some(), - infer_args, ); // Skip processing if type has no generic parameters. @@ -540,9 +534,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { astconv: self, def_id, span, - generic_args, + generic_args: seg.args(), inferred_params: vec![], - infer_args, + infer_args: seg.infer_args, }; let substs = create_substs_for_generic_args( tcx, @@ -623,8 +617,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { item_def_id, parent_substs, item_segment, - item_segment.args(), - item_segment.infer_args, None, ty::BoundConstness::NotConst, ); @@ -671,8 +663,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { trait_ref_span: Span, trait_def_id: DefId, trait_segment: &hir::PathSegment<'_>, - args: &GenericArgs<'_>, - infer_args: bool, self_ty: Ty<'tcx>, ) -> GenericArgCountResult { let (substs, arg_count) = self.create_substs_for_ast_path( @@ -680,8 +670,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { trait_def_id, &[], trait_segment, - args, - infer_args, Some(self_ty), constness, ); @@ -690,7 +678,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { let bound_vars = tcx.late_bound_vars(hir_id); debug!(?bound_vars); - let assoc_bindings = self.create_assoc_bindings_for_generic_args(args); + let assoc_bindings = self.create_assoc_bindings_for_generic_args(trait_segment.args()); let poly_trait_ref = ty::Binder::bind_with_vars(tcx.mk_trait_ref(trait_def_id, substs), bound_vars); @@ -751,8 +739,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { let trait_ref_span = trait_ref.path.span; let trait_def_id = trait_ref.trait_def_id().unwrap_or_else(|| FatalError.raise()); let trait_segment = trait_ref.path.segments.last().unwrap(); - let args = trait_segment.args(); - let infer_args = trait_segment.infer_args; self.prohibit_generics(trait_ref.path.segments.split_last().unwrap().1.iter(), |_| {}); self.complain_about_internal_fn_trait(span, trait_def_id, trait_segment, false); @@ -767,8 +753,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { trait_ref_span, trait_def_id, trait_segment, - args, - infer_args, self_ty, ) } @@ -787,8 +771,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { let speculative = false; let trait_ref_span = span; let trait_def_id = self.tcx().require_lang_item(lang_item, Some(span)); - let trait_segment = &hir::PathSegment::invalid(); - let infer_args = false; + let trait_segment = &hir::PathSegment { + ident: Ident::empty(), + hir_id: hir::HirId::INVALID, + res: Res::Err, + args: Some(args), + infer_args: false, + }; self.instantiate_poly_trait_ref_inner( hir_id, @@ -800,8 +789,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { trait_ref_span, trait_def_id, trait_segment, - args, - infer_args, self_ty, ); } @@ -846,8 +833,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { trait_def_id, &[], trait_segment, - trait_segment.args(), - trait_segment.infer_args, Some(self_ty), constness, ) @@ -3074,8 +3059,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { def_id, &[], &hir::PathSegment::invalid(), - &GenericArgs::none(), - true, None, ty::BoundConstness::NotConst, ); diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index 33c132fd5349b..d236297093663 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -57,6 +57,7 @@ This API is completely unstable and subject to change. #![allow(rustc::potential_query_instability)] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] +#![feature(array_windows)] #![feature(box_patterns)] #![feature(control_flow_enum)] #![feature(drain_filter)] diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 35dc533e56c24..4ce5e15d67fb0 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -504,6 +504,11 @@ fn register_builtins(store: &mut LintStore) { "converted into hard error, see issue #82523 \ for more information", ); + store.register_removed( + "late_bound_lifetime_arguments", + "converted into hard error, see issue #42868 \ + for more information", + ); } fn register_internals(store: &mut LintStore) { diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 46ec1a2dca1f7..cd4df7e6c10ec 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -1350,47 +1350,6 @@ declare_lint! { }; } -declare_lint! { - /// The `late_bound_lifetime_arguments` lint detects generic lifetime - /// arguments in path segments with late bound lifetime parameters. - /// - /// ### Example - /// - /// ```rust - /// struct S; - /// - /// impl S { - /// fn late(self, _: &u8, _: &u8) {} - /// } - /// - /// fn main() { - /// S.late::<'static>(&0, &0); - /// } - /// ``` - /// - /// {{produces}} - /// - /// ### Explanation - /// - /// It is not clear how to provide arguments for early-bound lifetime - /// parameters if they are intermixed with late-bound parameters in the - /// same list. For now, providing any explicit arguments will trigger this - /// lint if late-bound parameters are present, so in the future a solution - /// can be adopted without hitting backward compatibility issues. This is - /// a [future-incompatible] lint to transition this to a hard error in the - /// future. See [issue #42868] for more details, along with a description - /// of the difference between early and late-bound parameters. - /// - /// [issue #42868]: https://github.com/rust-lang/rust/issues/42868 - /// [future-incompatible]: ../index.md#future-incompatible-lints - pub LATE_BOUND_LIFETIME_ARGUMENTS, - Warn, - "detects generic lifetime arguments in path segments with late bound lifetime parameters", - @future_incompatible = FutureIncompatibleInfo { - reference: "issue #42868 ", - }; -} - declare_lint! { /// The `order_dependent_trait_objects` lint detects a trait coherency /// violation that would allow creating two trait impls for the same @@ -3266,7 +3225,6 @@ declare_lint_pass! { CONST_ITEM_MUTATION, PATTERNS_IN_FNS_WITHOUT_BODY, MISSING_FRAGMENT_SPECIFIER, - LATE_BOUND_LIFETIME_ARGUMENTS, ORDER_DEPENDENT_TRAIT_OBJECTS, COHERENCE_LEAK_CHECK, DEPRECATED, diff --git a/tests/ui/const-generics/const-arg-in-const-arg.full.stderr b/tests/ui/const-generics/const-arg-in-const-arg.full.stderr index 8672e79b3e8c8..f5f32d8a27f32 100644 --- a/tests/ui/const-generics/const-arg-in-const-arg.full.stderr +++ b/tests/ui/const-generics/const-arg-in-const-arg.full.stderr @@ -9,6 +9,11 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ +help: remove the explicit lifetime argument + | +LL - let _: [u8; faz::<'a>(&())]; +LL + let _: [u8; faz(&())]; + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:21:23 @@ -21,6 +26,11 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ +help: remove the explicit lifetime argument + | +LL - let _: [u8; faz::<'b>(&())]; +LL + let _: [u8; faz(&())]; + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:41:24 @@ -33,6 +43,11 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ +help: remove the explicit lifetime argument + | +LL - let _: Foo<{ faz::<'a>(&()) }>; +LL + let _: Foo<{ faz(&()) }>; + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:44:24 @@ -45,6 +60,11 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ +help: remove the explicit lifetime argument + | +LL - let _: Foo<{ faz::<'b>(&()) }>; +LL + let _: Foo<{ faz(&()) }>; + | error: unconstrained generic constant --> $DIR/const-arg-in-const-arg.rs:13:12 @@ -105,6 +125,11 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ +help: remove the explicit lifetime argument + | +LL - let _ = [0; faz::<'a>(&())]; +LL + let _ = [0; faz(&())]; + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:33:23 @@ -117,6 +142,11 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ +help: remove the explicit lifetime argument + | +LL - let _ = [0; faz::<'b>(&())]; +LL + let _ = [0; faz(&())]; + | error: unconstrained generic constant --> $DIR/const-arg-in-const-arg.rs:47:19 @@ -145,6 +175,11 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ +help: remove the explicit lifetime argument + | +LL - let _ = Foo::<{ faz::<'a>(&()) }>; +LL + let _ = Foo::<{ faz(&()) }>; + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:55:27 @@ -157,6 +192,11 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ +help: remove the explicit lifetime argument + | +LL - let _ = Foo::<{ faz::<'b>(&()) }>; +LL + let _ = Foo::<{ faz(&()) }>; + | error: aborting due to 16 previous errors 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 f1353aa99437d..d77d5ccec0040 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 @@ -227,6 +227,11 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ +help: remove the explicit lifetime argument + | +LL - let _: [u8; faz::<'a>(&())]; +LL + let _: [u8; faz(&())]; + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:21:23 @@ -239,6 +244,11 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ +help: remove the explicit lifetime argument + | +LL - let _: [u8; faz::<'b>(&())]; +LL + let _: [u8; faz(&())]; + | error[E0747]: unresolved item provided when a constant was expected --> $DIR/const-arg-in-const-arg.rs:38:24 @@ -262,6 +272,11 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ +help: remove the explicit lifetime argument + | +LL - let _: Foo<{ faz::<'a>(&()) }>; +LL + let _: Foo<{ faz(&()) }>; + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:44:24 @@ -274,6 +289,11 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ +help: remove the explicit lifetime argument + | +LL - let _: Foo<{ faz::<'b>(&()) }>; +LL + let _: Foo<{ faz(&()) }>; + | error: constant expression depends on a generic parameter --> $DIR/const-arg-in-const-arg.rs:25:17 @@ -305,6 +325,11 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ +help: remove the explicit lifetime argument + | +LL - let _ = [0; faz::<'a>(&())]; +LL + let _ = [0; faz(&())]; + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:33:23 @@ -317,6 +342,11 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ +help: remove the explicit lifetime argument + | +LL - let _ = [0; faz::<'b>(&())]; +LL + let _ = [0; faz(&())]; + | error[E0747]: unresolved item provided when a constant was expected --> $DIR/const-arg-in-const-arg.rs:49:27 @@ -340,6 +370,11 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ +help: remove the explicit lifetime argument + | +LL - let _ = Foo::<{ faz::<'a>(&()) }>; +LL + let _ = Foo::<{ faz(&()) }>; + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:55:27 @@ -352,6 +387,11 @@ note: the late bound lifetime parameter is introduced here | LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ +help: remove the explicit lifetime argument + | +LL - let _ = Foo::<{ faz::<'b>(&()) }>; +LL + let _ = Foo::<{ faz(&()) }>; + | error: aborting due to 36 previous errors diff --git a/tests/ui/const-generics/issues/issue-83466.rs b/tests/ui/const-generics/issues/issue-83466.rs index 73c9301011d58..79a109da4b46a 100644 --- a/tests/ui/const-generics/issues/issue-83466.rs +++ b/tests/ui/const-generics/issues/issue-83466.rs @@ -9,9 +9,8 @@ impl S { } fn dont_crash<'a, U>() { S.func::<'a, 10_u32>() - //~^ WARNING cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - //~^^ WARNING this was previously accepted by - //~^^^ ERROR constant provided when a type was expected [E0747] + //~^ ERROR cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + //~| ERROR constant provided when a type was expected [E0747] } fn main() {} diff --git a/tests/ui/const-generics/issues/issue-83466.stderr b/tests/ui/const-generics/issues/issue-83466.stderr index bcfd706398966..231adb7850780 100644 --- a/tests/ui/const-generics/issues/issue-83466.stderr +++ b/tests/ui/const-generics/issues/issue-83466.stderr @@ -1,15 +1,19 @@ -warning: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/issue-83466.rs:11:14 | -LL | fn func<'a, U>(self) -> U { - | -- the late bound lifetime parameter is introduced here -... LL | S.func::<'a, 10_u32>() | ^^ | - = 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)]` on by default +note: the late bound lifetime parameter is introduced here + --> $DIR/issue-83466.rs:6:13 + | +LL | fn func<'a, U>(self) -> U { + | ^^ +help: remove the explicit lifetime argument + | +LL - S.func::<'a, 10_u32>() +LL + S.func::<10_u32>() + | error[E0747]: constant provided when a type was expected --> $DIR/issue-83466.rs:11:18 @@ -17,6 +21,6 @@ error[E0747]: constant provided when a type was expected LL | S.func::<'a, 10_u32>() | ^^^^^^ -error: aborting due to previous error; 1 warning emitted +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0747`. diff --git a/tests/ui/issues/issue-60622.rs b/tests/ui/issues/issue-60622.rs index 7b9443eee5013..ce6e1c50392cb 100644 --- a/tests/ui/issues/issue-60622.rs +++ b/tests/ui/issues/issue-60622.rs @@ -10,7 +10,6 @@ fn run_wild(b: &Borked) { b.a::<'_, T>(); //~^ ERROR cannot specify lifetime arguments explicitly if late bound lifetime parameters are present //~| ERROR method takes 0 generic arguments but 1 generic argument - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! } fn main() {} diff --git a/tests/ui/issues/issue-60622.stderr b/tests/ui/issues/issue-60622.stderr index 43da2773940e5..69f0abe3d809d 100644 --- a/tests/ui/issues/issue-60622.stderr +++ b/tests/ui/issues/issue-60622.stderr @@ -1,20 +1,19 @@ error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/issue-60622.rs:10:11 | -LL | fn a(&self) {} - | - the late bound lifetime parameter is introduced here -... LL | b.a::<'_, T>(); | ^^ | - = 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 - --> $DIR/issue-60622.rs:1:9 +note: the late bound lifetime parameter is introduced here + --> $DIR/issue-60622.rs:6:10 + | +LL | fn a(&self) {} + | ^ +help: remove the explicit lifetime argument + | +LL - b.a::<'_, T>(); +LL + b.a::(); | -LL | #![deny(warnings)] - | ^^^^^^^^ - = note: `#[deny(late_bound_lifetime_arguments)]` implied by `#[deny(warnings)]` error[E0107]: method takes 0 generic arguments but 1 generic argument was supplied --> $DIR/issue-60622.rs:10:7 diff --git a/tests/ui/issues/issue-72278.rs b/tests/ui/issues/issue-72278.rs index 92fd1f73a937f..7685bf29c910c 100644 --- a/tests/ui/issues/issue-72278.rs +++ b/tests/ui/issues/issue-72278.rs @@ -1,5 +1,3 @@ -// run-pass - #![allow(unused)] struct S; @@ -12,8 +10,7 @@ impl S { fn dont_crash<'a, U>() -> U { S.func::<'a, U>() - //~^ WARN cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted + //~^ ERROR cannot specify lifetime arguments explicitly } fn main() {} diff --git a/tests/ui/issues/issue-72278.stderr b/tests/ui/issues/issue-72278.stderr index 5468837a30591..fb80fe6fda2e9 100644 --- a/tests/ui/issues/issue-72278.stderr +++ b/tests/ui/issues/issue-72278.stderr @@ -1,15 +1,19 @@ -warning: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/issue-72278.rs:14:14 +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/issue-72278.rs:12:14 | -LL | fn func<'a, U>(&'a self) -> U { - | -- the late bound lifetime parameter is introduced here -... LL | S.func::<'a, U>() | ^^ | - = 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)]` on by default +note: the late bound lifetime parameter is introduced here + --> $DIR/issue-72278.rs:6:13 + | +LL | fn func<'a, U>(&'a self) -> U { + | ^^ +help: remove the explicit lifetime argument + | +LL - S.func::<'a, U>() +LL + S.func::() + | -warning: 1 warning emitted +error: aborting due to previous error diff --git a/tests/ui/methods/method-call-lifetime-args-fail.fixed b/tests/ui/methods/method-call-lifetime-args-fail.fixed new file mode 100644 index 0000000000000..483d864dd95b1 --- /dev/null +++ b/tests/ui/methods/method-call-lifetime-args-fail.fixed @@ -0,0 +1,75 @@ +// run-rustfix +#![allow(dead_code)] + +struct S; + +impl S { + fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} + fn late_implicit(self, _: &u8, _: &u8) {} + fn early<'a, 'b>(self) -> (&'a u8, &'b u8) { loop {} } + fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } + fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } + fn late_implicit_self_early<'b>(&self) -> &'b u8 { loop {} } + fn late_unused_early<'a, 'b>(self) -> &'b u8 { loop {} } + fn life_and_type<'a, T>(self) -> &'a T { loop {} } +} + +fn method_call() { + S.early(); // OK + S.early::<'static, 'static>(); + //~^ ERROR method takes 2 lifetime arguments but 1 lifetime argument + S.early::<'static, 'static, >(); + //~^ ERROR method takes 2 lifetime arguments but 3 lifetime arguments were supplied + let _: &u8 = S.life_and_type::<'static>(); + S.life_and_type::(); + S.life_and_type::<'static, u8>(); +} + +fn ufcs() { + S::late(S, &0, &0); // OK + S::late(S, &0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late(S, &0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late(S, &0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_early(S, &0); // OK + S::late_early(S, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_early(S, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + + S::late_implicit(S, &0, &0); // OK + S::late_implicit(S, &0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_implicit(S, &0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_implicit(S, &0, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_implicit_early(S, &0); // OK + S::late_implicit_early(S, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_implicit_early(S, &0); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_implicit_self_early(&S); // OK + S::late_implicit_self_early(&S); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_implicit_self_early(&S); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_unused_early(S); // OK + S::late_unused_early(S); + //~^ ERROR cannot specify lifetime arguments explicitly + S::late_unused_early(S); + //~^ ERROR cannot specify lifetime arguments explicitly + + S::early(S); // OK + S::early::<'static, 'static>(S); + //~^ ERROR method takes 2 lifetime arguments but 1 lifetime argument + S::early::<'static, 'static, >(S); + //~^ ERROR method takes 2 lifetime arguments but 3 lifetime arguments were supplied + let _: &u8 = S::life_and_type::<'static>(S); + S::life_and_type::(S); + S::life_and_type::<'static, u8>(S); +} + +fn main() {} diff --git a/tests/ui/methods/method-call-lifetime-args-fail.rs b/tests/ui/methods/method-call-lifetime-args-fail.rs index 1f13de094bbf8..3867007c886d2 100644 --- a/tests/ui/methods/method-call-lifetime-args-fail.rs +++ b/tests/ui/methods/method-call-lifetime-args-fail.rs @@ -1,3 +1,6 @@ +// run-rustfix +#![allow(dead_code)] + struct S; impl S { diff --git a/tests/ui/methods/method-call-lifetime-args-fail.stderr b/tests/ui/methods/method-call-lifetime-args-fail.stderr index 34526256f9975..f8eff125451ec 100644 --- a/tests/ui/methods/method-call-lifetime-args-fail.stderr +++ b/tests/ui/methods/method-call-lifetime-args-fail.stderr @@ -1,5 +1,5 @@ error[E0107]: method takes 2 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/method-call-lifetime-args-fail.rs:16:7 + --> $DIR/method-call-lifetime-args-fail.rs:19:7 | LL | S.early::<'static>(); | ^^^^^ ------- supplied 1 lifetime argument @@ -7,7 +7,7 @@ LL | S.early::<'static>(); | expected 2 lifetime arguments | note: method defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/method-call-lifetime-args-fail.rs:6:8 + --> $DIR/method-call-lifetime-args-fail.rs:9:8 | LL | fn early<'a, 'b>(self) -> (&'a u8, &'b u8) { loop {} } | ^^^^^ -- -- @@ -17,7 +17,7 @@ LL | S.early::<'static, 'static>(); | +++++++++ error[E0107]: method takes 2 lifetime arguments but 3 lifetime arguments were supplied - --> $DIR/method-call-lifetime-args-fail.rs:18:7 + --> $DIR/method-call-lifetime-args-fail.rs:21:7 | LL | S.early::<'static, 'static, 'static>(); | ^^^^^ ------- help: remove this lifetime argument @@ -25,181 +25,251 @@ LL | S.early::<'static, 'static, 'static>(); | expected 2 lifetime arguments | note: method defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/method-call-lifetime-args-fail.rs:6:8 + --> $DIR/method-call-lifetime-args-fail.rs:9:8 | LL | fn early<'a, 'b>(self) -> (&'a u8, &'b u8) { loop {} } | ^^^^^ -- -- error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-fail.rs:27:15 + --> $DIR/method-call-lifetime-args-fail.rs:30:15 | LL | S::late::<'static>(S, &0, &0); | ^^^^^^^ | note: the late bound lifetime parameter is introduced here - --> $DIR/method-call-lifetime-args-fail.rs:4:13 + --> $DIR/method-call-lifetime-args-fail.rs:7:13 | LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} | ^^ +help: remove the explicit lifetime argument + | +LL - S::late::<'static>(S, &0, &0); +LL + S::late(S, &0, &0); + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-fail.rs:29:15 + --> $DIR/method-call-lifetime-args-fail.rs:32:15 | LL | S::late::<'static, 'static>(S, &0, &0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ | note: the late bound lifetime parameter is introduced here - --> $DIR/method-call-lifetime-args-fail.rs:4:13 + --> $DIR/method-call-lifetime-args-fail.rs:7:13 | LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} | ^^ +help: remove the explicit lifetime arguments + | +LL - S::late::<'static, 'static>(S, &0, &0); +LL + S::late(S, &0, &0); + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-fail.rs:31:15 + --> $DIR/method-call-lifetime-args-fail.rs:34:15 | LL | S::late::<'static, 'static, 'static>(S, &0, &0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ ^^^^^^^ | note: the late bound lifetime parameter is introduced here - --> $DIR/method-call-lifetime-args-fail.rs:4:13 + --> $DIR/method-call-lifetime-args-fail.rs:7:13 | LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} | ^^ +help: remove the explicit lifetime arguments + | +LL - S::late::<'static, 'static, 'static>(S, &0, &0); +LL + S::late(S, &0, &0); + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-fail.rs:34:21 + --> $DIR/method-call-lifetime-args-fail.rs:37:21 | LL | S::late_early::<'static, 'static>(S, &0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ | note: the late bound lifetime parameter is introduced here - --> $DIR/method-call-lifetime-args-fail.rs:7:19 + --> $DIR/method-call-lifetime-args-fail.rs:10:19 | LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } | ^^ +help: remove the explicit lifetime arguments + | +LL - S::late_early::<'static, 'static>(S, &0); +LL + S::late_early(S, &0); + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-fail.rs:36:21 + --> $DIR/method-call-lifetime-args-fail.rs:39:21 | LL | S::late_early::<'static, 'static, 'static>(S, &0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ ^^^^^^^ | note: the late bound lifetime parameter is introduced here - --> $DIR/method-call-lifetime-args-fail.rs:7:19 + --> $DIR/method-call-lifetime-args-fail.rs:10:19 | LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } | ^^ +help: remove the explicit lifetime arguments + | +LL - S::late_early::<'static, 'static, 'static>(S, &0); +LL + S::late_early(S, &0); + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-fail.rs:40:24 + --> $DIR/method-call-lifetime-args-fail.rs:43:24 | LL | S::late_implicit::<'static>(S, &0, &0); | ^^^^^^^ | note: the late bound lifetime parameter is introduced here - --> $DIR/method-call-lifetime-args-fail.rs:5:31 + --> $DIR/method-call-lifetime-args-fail.rs:8:31 | LL | fn late_implicit(self, _: &u8, _: &u8) {} | ^ +help: remove the explicit lifetime argument + | +LL - S::late_implicit::<'static>(S, &0, &0); +LL + S::late_implicit(S, &0, &0); + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-fail.rs:42:24 + --> $DIR/method-call-lifetime-args-fail.rs:45:24 | LL | S::late_implicit::<'static, 'static>(S, &0, &0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ | note: the late bound lifetime parameter is introduced here - --> $DIR/method-call-lifetime-args-fail.rs:5:31 + --> $DIR/method-call-lifetime-args-fail.rs:8:31 | LL | fn late_implicit(self, _: &u8, _: &u8) {} | ^ +help: remove the explicit lifetime arguments + | +LL - S::late_implicit::<'static, 'static>(S, &0, &0); +LL + S::late_implicit(S, &0, &0); + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-fail.rs:44:24 + --> $DIR/method-call-lifetime-args-fail.rs:47:24 | LL | S::late_implicit::<'static, 'static, 'static>(S, &0, &0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ ^^^^^^^ | note: the late bound lifetime parameter is introduced here - --> $DIR/method-call-lifetime-args-fail.rs:5:31 + --> $DIR/method-call-lifetime-args-fail.rs:8:31 | LL | fn late_implicit(self, _: &u8, _: &u8) {} | ^ +help: remove the explicit lifetime arguments + | +LL - S::late_implicit::<'static, 'static, 'static>(S, &0, &0); +LL + S::late_implicit(S, &0, &0); + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-fail.rs:47:30 + --> $DIR/method-call-lifetime-args-fail.rs:50:30 | LL | S::late_implicit_early::<'static, 'static>(S, &0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ | note: the late bound lifetime parameter is introduced here - --> $DIR/method-call-lifetime-args-fail.rs:8:41 + --> $DIR/method-call-lifetime-args-fail.rs:11:41 | LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } | ^ +help: remove the explicit lifetime arguments + | +LL - S::late_implicit_early::<'static, 'static>(S, &0); +LL + S::late_implicit_early(S, &0); + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-fail.rs:49:30 + --> $DIR/method-call-lifetime-args-fail.rs:52:30 | LL | S::late_implicit_early::<'static, 'static, 'static>(S, &0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ ^^^^^^^ | note: the late bound lifetime parameter is introduced here - --> $DIR/method-call-lifetime-args-fail.rs:8:41 + --> $DIR/method-call-lifetime-args-fail.rs:11:41 | LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } | ^ +help: remove the explicit lifetime arguments + | +LL - S::late_implicit_early::<'static, 'static, 'static>(S, &0); +LL + S::late_implicit_early(S, &0); + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-fail.rs:52:35 + --> $DIR/method-call-lifetime-args-fail.rs:55:35 | LL | S::late_implicit_self_early::<'static, 'static>(&S); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ | note: the late bound lifetime parameter is introduced here - --> $DIR/method-call-lifetime-args-fail.rs:9:37 + --> $DIR/method-call-lifetime-args-fail.rs:12:37 | LL | fn late_implicit_self_early<'b>(&self) -> &'b u8 { loop {} } | ^ +help: remove the explicit lifetime arguments + | +LL - S::late_implicit_self_early::<'static, 'static>(&S); +LL + S::late_implicit_self_early(&S); + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-fail.rs:54:35 + --> $DIR/method-call-lifetime-args-fail.rs:57:35 | LL | S::late_implicit_self_early::<'static, 'static, 'static>(&S); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ ^^^^^^^ | note: the late bound lifetime parameter is introduced here - --> $DIR/method-call-lifetime-args-fail.rs:9:37 + --> $DIR/method-call-lifetime-args-fail.rs:12:37 | LL | fn late_implicit_self_early<'b>(&self) -> &'b u8 { loop {} } | ^ +help: remove the explicit lifetime arguments + | +LL - S::late_implicit_self_early::<'static, 'static, 'static>(&S); +LL + S::late_implicit_self_early(&S); + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-fail.rs:57:28 + --> $DIR/method-call-lifetime-args-fail.rs:60:28 | LL | S::late_unused_early::<'static, 'static>(S); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ | note: the late bound lifetime parameter is introduced here - --> $DIR/method-call-lifetime-args-fail.rs:10:26 + --> $DIR/method-call-lifetime-args-fail.rs:13:26 | LL | fn late_unused_early<'a, 'b>(self) -> &'b u8 { loop {} } | ^^ +help: remove the explicit lifetime arguments + | +LL - S::late_unused_early::<'static, 'static>(S); +LL + S::late_unused_early(S); + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-fail.rs:59:28 + --> $DIR/method-call-lifetime-args-fail.rs:62:28 | LL | S::late_unused_early::<'static, 'static, 'static>(S); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ ^^^^^^^ | note: the late bound lifetime parameter is introduced here - --> $DIR/method-call-lifetime-args-fail.rs:10:26 + --> $DIR/method-call-lifetime-args-fail.rs:13:26 | LL | fn late_unused_early<'a, 'b>(self) -> &'b u8 { loop {} } | ^^ +help: remove the explicit lifetime arguments + | +LL - S::late_unused_early::<'static, 'static, 'static>(S); +LL + S::late_unused_early(S); + | error[E0107]: method takes 2 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/method-call-lifetime-args-fail.rs:63:8 + --> $DIR/method-call-lifetime-args-fail.rs:66:8 | LL | S::early::<'static>(S); | ^^^^^ ------- supplied 1 lifetime argument @@ -207,7 +277,7 @@ LL | S::early::<'static>(S); | expected 2 lifetime arguments | note: method defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/method-call-lifetime-args-fail.rs:6:8 + --> $DIR/method-call-lifetime-args-fail.rs:9:8 | LL | fn early<'a, 'b>(self) -> (&'a u8, &'b u8) { loop {} } | ^^^^^ -- -- @@ -217,7 +287,7 @@ LL | S::early::<'static, 'static>(S); | +++++++++ error[E0107]: method takes 2 lifetime arguments but 3 lifetime arguments were supplied - --> $DIR/method-call-lifetime-args-fail.rs:65:8 + --> $DIR/method-call-lifetime-args-fail.rs:68:8 | LL | S::early::<'static, 'static, 'static>(S); | ^^^^^ ------- help: remove this lifetime argument @@ -225,7 +295,7 @@ LL | S::early::<'static, 'static, 'static>(S); | expected 2 lifetime arguments | note: method defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/method-call-lifetime-args-fail.rs:6:8 + --> $DIR/method-call-lifetime-args-fail.rs:9:8 | LL | fn early<'a, 'b>(self) -> (&'a u8, &'b u8) { loop {} } | ^^^^^ -- -- diff --git a/tests/ui/methods/method-call-lifetime-args-lint-fail.rs b/tests/ui/methods/method-call-lifetime-args-lint-fail.rs index 23893911eabd9..db8d1953cfa36 100644 --- a/tests/ui/methods/method-call-lifetime-args-lint-fail.rs +++ b/tests/ui/methods/method-call-lifetime-args-lint-fail.rs @@ -1,4 +1,3 @@ -#![deny(late_bound_lifetime_arguments)] #![allow(unused)] struct S; @@ -22,44 +21,32 @@ fn method_call() { S.late(&0, &0); // OK S.late::<'static>(&0, &0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S.late::<'static, 'static>(&0, &0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S.late::<'static, 'static, 'static>(&0, &0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S.late_early(&0); // OK S.late_early::<'static>(&0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S.late_early::<'static, 'static>(&0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S.late_early::<'static, 'static, 'static>(&0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S.late_implicit(&0, &0); // OK S.late_implicit::<'static>(&0, &0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S.late_implicit::<'static, 'static>(&0, &0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S.late_implicit::<'static, 'static, 'static>(&0, &0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S.late_implicit_early(&0); // OK S.late_implicit_early::<'static>(&0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S.late_implicit_early::<'static, 'static>(&0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S.late_implicit_early::<'static, 'static, 'static>(&0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S::early_tricky_explicit::<'static>(loop {}, loop {}); // OK S::early_tricky_implicit::<'static>(loop {}, loop {}); // OK @@ -68,11 +55,9 @@ fn method_call() { fn ufcs() { S::late_early::<'static>(S, &0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S::late_implicit_early::<'static>(S, &0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted } fn lint_not_inference_error() { @@ -81,7 +66,6 @@ fn lint_not_inference_error() { // Make sure `u8` is substituted and not replaced with an inference variable f::<'static, u8>; //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted } fn main() {} 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..ee6cdfc350e0c 100644 --- a/tests/ui/methods/method-call-lifetime-args-lint-fail.stderr +++ b/tests/ui/methods/method-call-lifetime-args-lint-fail.stderr @@ -1,187 +1,257 @@ error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:23:14 + --> $DIR/method-call-lifetime-args-lint-fail.rs:22:14 | -LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} - | -- the late bound lifetime parameter is introduced here -... LL | S.late::<'static>(&0, &0); | ^^^^^^^ | - = 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 - --> $DIR/method-call-lifetime-args-lint-fail.rs:1:9 +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:6:13 + | +LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} + | ^^ +help: remove the explicit lifetime argument + | +LL - S.late::<'static>(&0, &0); +LL + S.late(&0, &0); | -LL | #![deny(late_bound_lifetime_arguments)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:26:14 + --> $DIR/method-call-lifetime-args-lint-fail.rs:24:14 | -LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} - | -- the late bound lifetime parameter is introduced here -... LL | S.late::<'static, 'static>(&0, &0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:6:13 + | +LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} + | ^^ +help: remove the explicit lifetime arguments + | +LL - S.late::<'static, 'static>(&0, &0); +LL + S.late(&0, &0); | - = 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 error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:29:14 + --> $DIR/method-call-lifetime-args-lint-fail.rs:26:14 | -LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} - | -- the late bound lifetime parameter is introduced here -... LL | S.late::<'static, 'static, 'static>(&0, &0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:6:13 + | +LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} + | ^^ +help: remove the explicit lifetime arguments + | +LL - S.late::<'static, 'static, 'static>(&0, &0); +LL + S.late(&0, &0); | - = 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 error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:33:20 + --> $DIR/method-call-lifetime-args-lint-fail.rs:29:20 | -LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } - | -- the late bound lifetime parameter is introduced here -... LL | S.late_early::<'static>(&0); | ^^^^^^^ | - = 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 late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:8:19 + | +LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } + | ^^ +help: remove the explicit lifetime argument + | +LL - S.late_early::<'static>(&0); +LL + S.late_early(&0); + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:36:20 + --> $DIR/method-call-lifetime-args-lint-fail.rs:31:20 | -LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } - | -- the late bound lifetime parameter is introduced here -... LL | S.late_early::<'static, 'static>(&0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:8:19 + | +LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } + | ^^ +help: remove the explicit lifetime arguments + | +LL - S.late_early::<'static, 'static>(&0); +LL + S.late_early(&0); | - = 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 error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:39:20 + --> $DIR/method-call-lifetime-args-lint-fail.rs:33:20 | -LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } - | -- the late bound lifetime parameter is introduced here -... LL | S.late_early::<'static, 'static, 'static>(&0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:8:19 + | +LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } + | ^^ +help: remove the explicit lifetime arguments + | +LL - S.late_early::<'static, 'static, 'static>(&0); +LL + S.late_early(&0); | - = 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 error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:44:23 + --> $DIR/method-call-lifetime-args-lint-fail.rs:37:23 | -LL | fn late_implicit(self, _: &u8, _: &u8) {} - | - the late bound lifetime parameter is introduced here -... LL | S.late_implicit::<'static>(&0, &0); | ^^^^^^^ | - = 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 late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:7:31 + | +LL | fn late_implicit(self, _: &u8, _: &u8) {} + | ^ +help: remove the explicit lifetime argument + | +LL - S.late_implicit::<'static>(&0, &0); +LL + S.late_implicit(&0, &0); + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:47:23 + --> $DIR/method-call-lifetime-args-lint-fail.rs:39:23 | -LL | fn late_implicit(self, _: &u8, _: &u8) {} - | - the late bound lifetime parameter is introduced here -... LL | S.late_implicit::<'static, 'static>(&0, &0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:7:31 + | +LL | fn late_implicit(self, _: &u8, _: &u8) {} + | ^ +help: remove the explicit lifetime arguments + | +LL - S.late_implicit::<'static, 'static>(&0, &0); +LL + S.late_implicit(&0, &0); | - = 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 error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:50:23 + --> $DIR/method-call-lifetime-args-lint-fail.rs:41:23 | -LL | fn late_implicit(self, _: &u8, _: &u8) {} - | - the late bound lifetime parameter is introduced here -... LL | S.late_implicit::<'static, 'static, 'static>(&0, &0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:7:31 + | +LL | fn late_implicit(self, _: &u8, _: &u8) {} + | ^ +help: remove the explicit lifetime arguments + | +LL - S.late_implicit::<'static, 'static, 'static>(&0, &0); +LL + S.late_implicit(&0, &0); | - = 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 error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:54:29 + --> $DIR/method-call-lifetime-args-lint-fail.rs:44:29 | -LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } - | - the late bound lifetime parameter is introduced here -... LL | S.late_implicit_early::<'static>(&0); | ^^^^^^^ | - = 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 late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:9:41 + | +LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } + | ^ +help: remove the explicit lifetime argument + | +LL - S.late_implicit_early::<'static>(&0); +LL + S.late_implicit_early(&0); + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:57:29 + --> $DIR/method-call-lifetime-args-lint-fail.rs:46:29 | -LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } - | - the late bound lifetime parameter is introduced here -... LL | S.late_implicit_early::<'static, 'static>(&0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:9:41 + | +LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } + | ^ +help: remove the explicit lifetime arguments + | +LL - S.late_implicit_early::<'static, 'static>(&0); +LL + S.late_implicit_early(&0); | - = 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 error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:60:29 + --> $DIR/method-call-lifetime-args-lint-fail.rs:48:29 | -LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } - | - the late bound lifetime parameter is introduced here -... LL | S.late_implicit_early::<'static, 'static, 'static>(&0); - | ^^^^^^^ + | ^^^^^^^ ^^^^^^^ ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:9:41 + | +LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } + | ^ +help: remove the explicit lifetime arguments + | +LL - S.late_implicit_early::<'static, 'static, 'static>(&0); +LL + S.late_implicit_early(&0); | - = 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 error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:69:21 + --> $DIR/method-call-lifetime-args-lint-fail.rs:56:21 | -LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } - | -- the late bound lifetime parameter is introduced here -... LL | S::late_early::<'static>(S, &0); | ^^^^^^^ | - = 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 late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:8:19 + | +LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } + | ^^ +help: remove the explicit lifetime argument + | +LL - S::late_early::<'static>(S, &0); +LL + S::late_early(S, &0); + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:73:30 + --> $DIR/method-call-lifetime-args-lint-fail.rs:59:30 | -LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } - | - the late bound lifetime parameter is introduced here -... LL | S::late_implicit_early::<'static>(S, &0); | ^^^^^^^ | - = 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 late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:9:41 + | +LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } + | ^ +help: remove the explicit lifetime argument + | +LL - S::late_implicit_early::<'static>(S, &0); +LL + S::late_implicit_early(S, &0); + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint-fail.rs:82:9 + --> $DIR/method-call-lifetime-args-lint-fail.rs:67:9 | -LL | fn f<'early, 'late, T: 'early>() {} - | ----- the late bound lifetime parameter is introduced here -... LL | f::<'static, u8>; | ^^^^^^^ | - = 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 late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint-fail.rs:64:18 + | +LL | fn f<'early, 'late, T: 'early>() {} + | ^^^^^ +help: remove the explicit lifetime argument + | +LL - f::<'static, u8>; +LL + f::; + | error: aborting due to 15 previous errors diff --git a/tests/ui/methods/method-call-lifetime-args-lint.rs b/tests/ui/methods/method-call-lifetime-args-lint.rs index 14729e1e27e3c..a9907efeafaa1 100644 --- a/tests/ui/methods/method-call-lifetime-args-lint.rs +++ b/tests/ui/methods/method-call-lifetime-args-lint.rs @@ -1,4 +1,3 @@ -#![deny(late_bound_lifetime_arguments)] #![allow(unused)] struct S; @@ -11,11 +10,9 @@ impl S { fn method_call() { S.late::<'static>(&0, &0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted S.late_implicit::<'static>(&0, &0); //~^ ERROR cannot specify lifetime arguments explicitly - //~| WARN this was previously accepted } fn main() {} diff --git a/tests/ui/methods/method-call-lifetime-args-lint.stderr b/tests/ui/methods/method-call-lifetime-args-lint.stderr index b4fc2d71761c7..1424c7d1497c5 100644 --- a/tests/ui/methods/method-call-lifetime-args-lint.stderr +++ b/tests/ui/methods/method-call-lifetime-args-lint.stderr @@ -1,31 +1,36 @@ error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint.rs:12:14 + --> $DIR/method-call-lifetime-args-lint.rs:11:14 | -LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} - | -- the late bound lifetime parameter is introduced here -... LL | S.late::<'static>(&0, &0); | ^^^^^^^ | - = 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 - --> $DIR/method-call-lifetime-args-lint.rs:1:9 +note: the late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint.rs:6:13 + | +LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} + | ^^ +help: remove the explicit lifetime argument + | +LL - S.late::<'static>(&0, &0); +LL + S.late(&0, &0); | -LL | #![deny(late_bound_lifetime_arguments)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present - --> $DIR/method-call-lifetime-args-lint.rs:16:23 + --> $DIR/method-call-lifetime-args-lint.rs:14:23 | -LL | fn late_implicit(self, _: &u8, _: &u8) {} - | - the late bound lifetime parameter is introduced here -... LL | S.late_implicit::<'static>(&0, &0); | ^^^^^^^ | - = 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 late bound lifetime parameter is introduced here + --> $DIR/method-call-lifetime-args-lint.rs:7:31 + | +LL | fn late_implicit(self, _: &u8, _: &u8) {} + | ^ +help: remove the explicit lifetime argument + | +LL - S.late_implicit::<'static>(&0, &0); +LL + S.late_implicit(&0, &0); + | error: aborting due to 2 previous errors diff --git a/tests/ui/methods/method-call-lifetime-args-unresolved.rs b/tests/ui/methods/method-call-lifetime-args-unresolved.rs index ba7231070a0f4..51901ecfcc384 100644 --- a/tests/ui/methods/method-call-lifetime-args-unresolved.rs +++ b/tests/ui/methods/method-call-lifetime-args-unresolved.rs @@ -1,6 +1,5 @@ fn main() { 0.clone::<'a>(); //~^ ERROR use of undeclared lifetime name `'a` - //~| WARN cannot specify lifetime arguments explicitly if late bound - //~| WARN this was previously accepted by the compiler + //~| ERROR cannot specify lifetime arguments explicitly if late bound } diff --git a/tests/ui/methods/method-call-lifetime-args-unresolved.stderr b/tests/ui/methods/method-call-lifetime-args-unresolved.stderr index 25ad360b329aa..02983f50f2356 100644 --- a/tests/ui/methods/method-call-lifetime-args-unresolved.stderr +++ b/tests/ui/methods/method-call-lifetime-args-unresolved.stderr @@ -6,19 +6,20 @@ LL | fn main() { LL | 0.clone::<'a>(); | ^^ undeclared lifetime -warning: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-unresolved.rs:2:15 | LL | 0.clone::<'a>(); | ^^ + | +note: the late bound lifetime parameter is introduced here --> $SRC_DIR/core/src/clone.rs:LL:COL +help: remove the explicit lifetime argument | - = note: the late bound lifetime parameter is introduced here +LL - 0.clone::<'a>(); +LL + 0.clone(); | - = 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)]` on by default -error: aborting due to previous error; 1 warning emitted +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0261`. diff --git a/tests/ui/methods/method-call-lifetime-args.stderr b/tests/ui/methods/method-call-lifetime-args.stderr index 64ae79e9bb2b7..991dd8b7a22b9 100644 --- a/tests/ui/methods/method-call-lifetime-args.stderr +++ b/tests/ui/methods/method-call-lifetime-args.stderr @@ -9,6 +9,11 @@ note: the late bound lifetime parameter is introduced here | LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} | ^^ +help: remove the explicit lifetime argument + | +LL - S::late::<'static>(S, &0, &0); +LL + S::late(S, &0, &0); + | error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args.rs:11:24 @@ -21,6 +26,11 @@ note: the late bound lifetime parameter is introduced here | LL | fn late_implicit(self, _: &u8, _: &u8) {} | ^ +help: remove the explicit lifetime argument + | +LL - S::late_implicit::<'static>(S, &0, &0); +LL + S::late_implicit(S, &0, &0); + | error: aborting due to 2 previous errors