diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index 4229a0723ce49..5ebf950358c4f 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -74,20 +74,6 @@ pub(super) struct DescribePlaceOpt { pub(super) struct IncludingTupleField(pub(super) bool); -pub(crate) enum BufferedDiag<'diag> { - Error(Diag<'diag>), - NonError(Diag<'diag, ()>), -} - -impl<'diag> BufferedDiag<'diag> { - fn sort_span(&self) -> Span { - match self { - BufferedDiag::Error(diag) => diag.sort_span, - BufferedDiag::NonError(diag) => diag.sort_span, - } - } -} - #[derive(Default)] pub(crate) struct BorrowckDiagnosticsBuffer<'diag, 'tcx> { /// This field keeps track of move errors that are to be reported for given move indices. @@ -108,16 +94,13 @@ pub(crate) struct BorrowckDiagnosticsBuffer<'diag, 'tcx> { buffered_mut_errors: FxIndexMap, usize)>, - /// Buffer of diagnostics to be reported. A mixture of error and non-error diagnostics. - buffered_diags: Vec>, + /// Buffer of diagnostics to be reported. + buffered_diags: Vec>, } impl<'diag, 'tcx> BorrowckDiagnosticsBuffer<'diag, 'tcx> { - pub(crate) fn buffer_non_error(&mut self, diag: Diag<'diag, ()>) { - self.buffered_diags.push(BufferedDiag::NonError(diag)); - } pub(crate) fn buffer_error(&mut self, diag: Diag<'diag>) { - self.buffered_diags.push(BufferedDiag::Error(diag)); + self.buffered_diags.push(diag); } pub(crate) fn emit_errors(&mut self) { @@ -134,14 +117,9 @@ impl<'diag, 'tcx> BorrowckDiagnosticsBuffer<'diag, 'tcx> { } if !self.buffered_diags.is_empty() { - self.buffered_diags.sort_by_key(|buffered_diag| buffered_diag.sort_span()); - for buffered_diag in self.buffered_diags.drain(..) { - match buffered_diag { - BufferedDiag::Error(diag) => { - diag.emit(); - } - BufferedDiag::NonError(diag) => diag.emit(), - } + self.buffered_diags.sort_by_key(|diag| diag.sort_span); + for diag in self.buffered_diags.drain(..) { + diag.emit(); } } } @@ -152,10 +130,6 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> { self.diags_buffer.buffer_error(diag.with_dcx(self.dcx())); } - pub(crate) fn buffer_non_error(&mut self, diag: Diag<'_, ()>) { - self.diags_buffer.buffer_non_error(diag.with_dcx(self.dcx())); - } - pub(crate) fn buffer_move_error( &mut self, move_out_indices: Vec, diff --git a/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs b/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs index b1e16717466b5..75c666f49a2f7 100644 --- a/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs +++ b/compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs @@ -14,9 +14,6 @@ use crate::MirBorrowckCtxt; /// The different things we could suggest. enum SuggestedConstraint { - /// Outlives(a, [b, c, d, ...]) => 'a: 'b + 'c + 'd + ... - Outlives(RegionName, SmallVec<[RegionName; 2]>), - /// 'a = 'b Equal(RegionName, RegionName), @@ -106,11 +103,10 @@ impl OutlivesSuggestionBuilder { continue; } - // There are three types of suggestions we can make: - // 1) Suggest a bound: 'a: 'b - // 2) Suggest replacing 'a with 'static. If any of `outlived` is `'static`, then we + // There are two types of suggestions we can make: + // 1) Suggest replacing 'a with 'static. If any of `outlived` is `'static`, then we // should just replace 'a with 'static. - // 3) Suggest unifying 'a with 'b if we have both 'a: 'b and 'b: 'a + // 2) Suggest unifying 'a with 'b if we have both 'a: 'b and 'b: 'a if outlived .iter() @@ -121,7 +117,7 @@ impl OutlivesSuggestionBuilder { // We want to isolate out all lifetimes that should be unified and print out // separate messages for them. - let (unified, other): (Vec<_>, Vec<_>) = outlived.into_iter().partition( + let unified = outlived.into_iter().filter( // Do we have both 'fr: 'r and 'r: 'fr? |(r, _)| { self.constraints_to_add @@ -130,17 +126,12 @@ impl OutlivesSuggestionBuilder { }, ); - for (r, bound) in unified.into_iter() { + for (r, bound) in unified { if !unified_already.contains(fr) { suggested.push(SuggestedConstraint::Equal(fr_name, bound)); unified_already.insert(r); } } - - if !other.is_empty() { - let other = other.iter().map(|(_, rname)| *rname).collect::>(); - suggested.push(SuggestedConstraint::Outlives(fr_name, other)) - } } } @@ -202,54 +193,36 @@ impl OutlivesSuggestionBuilder { return; } - // If there is exactly one suggestable constraints, then just suggest it. Otherwise, emit a - // list of diagnostics. - let mut diag = if let [constraint] = suggested.as_slice() { - mbcx.dcx().struct_help(match constraint { - SuggestedConstraint::Outlives(a, bs) => { - let bs: SmallVec<[String; 2]> = bs.iter().map(|r| r.to_string()).collect(); - format!("add bound `{a}: {}`", bs.join(" + ")) - } - + // Emit an error with a list of one or more help suggestions. This is a weird error because + // it's just there to provide somewhere to put the help suggestions that describe how to + // fix the one or more borrow errors already reported within the item. + let tcx = mbcx.infcx.tcx; + let def_id = mbcx.mir_def_id(); + let span = tcx.def_ident_span(def_id).unwrap_or_else(|| tcx.def_span(def_id)); + let mut diag = tcx + .dcx() + .struct_err("one or more lifetime errors were found in this item") + .with_span(span); + + // Add suggestions. + for constraint in suggested { + match constraint { SuggestedConstraint::Equal(a, b) => { - format!("`{a}` and `{b}` must be the same: replace one with the other") + diag.help(format!( + "`{a}` and `{b}` must be the same: replace one with the other", + )); } - SuggestedConstraint::Static(a) => format!("replace `{a}` with `'static`"), - }) - } else { - // Create a new diagnostic. - let mut diag = mbcx - .infcx - .tcx - .dcx() - .struct_help("the following changes may resolve your lifetime errors"); - - // Add suggestions. - for constraint in suggested { - match constraint { - SuggestedConstraint::Outlives(a, bs) => { - let bs: SmallVec<[String; 2]> = bs.iter().map(|r| r.to_string()).collect(); - diag.help(format!("add bound `{a}: {}`", bs.join(" + "))); - } - SuggestedConstraint::Equal(a, b) => { - diag.help(format!( - "`{a}` and `{b}` must be the same: replace one with the other", - )); - } - SuggestedConstraint::Static(a) => { - diag.help(format!("replace `{a}` with `'static`")); - } + SuggestedConstraint::Static(a) => { + diag.help(format!("replace `{a}` with `'static`")); } } - - diag - }; + } // We want this message to appear after other messages on the mir def. let mir_span = mbcx.body.span; diag.sort_span = mir_span.shrink_to_hi(); // Buffer the diagnostic - mbcx.buffer_non_error(diag); + mbcx.buffer_error(diag); } } diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 9ca0344058d7f..e1fd8344e73fd 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -1148,11 +1148,6 @@ impl<'a> DiagCtxtHandle<'a> { self.create_note(note).emit() } - #[track_caller] - pub fn struct_help(self, msg: impl Into) -> Diag<'a, ()> { - Diag::new(self, Help, msg) - } - #[track_caller] pub fn struct_failure_note(self, msg: impl Into) -> Diag<'a, ()> { Diag::new(self, FailureNote, msg) @@ -1572,7 +1567,7 @@ impl DelayedDiagInner { /// | ForceWarning | - | () | yes | lint-only /// | Warning | - | () | yes | yes /// | Note | - | () | rare | - -/// | Help | - | () | rare | - +/// | Help | - | () | don't use | - /// | FailureNote | - | () | rare | - /// | Allow | - | () | yes | lint-only /// | Expect | - | () | yes | lint-only @@ -1607,14 +1602,18 @@ pub enum Level { /// Will be skipped if `can_emit_warnings` is false. Warning, - /// A message giving additional context. + /// A rarely-used level for output that isn't an error or a warning. Note, /// A message suggesting how to fix something. + /// + /// FIXME(nnethercote) Do not use this! Currently only exists to support `proc_macro::Help`, + /// part of the unstable `proc_macro_diagnostic` feature (see #54140). Should be removed + /// because help messages are fine as subdiagnostics but are silly as top-level diagnostics. Help, - /// Similar to `Note`, but used in cases where compilation has failed. When printed for human - /// consumption, it doesn't have any kind of `note:` label. + /// Similar to `Note`, but even rarer. Lacks the a trailing blank line that all other + /// diagnostics have. Also, when printed for human consumption it doesn't have a `note:` label. FailureNote, /// Only used for lints. @@ -1666,13 +1665,13 @@ pub enum Sublevel { /// See `Level::Warning`. Warning, - /// See `Level::Note`. + /// A message giving additional context. Note, /// A note that is only emitted once. OnceNote, - /// See `Level::Help`. + /// A message suggesting how to fix something. Help, /// A help that is only emitted once. diff --git a/tests/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.rs b/tests/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.rs index 069bf56004461..9646e45c55cdb 100644 --- a/tests/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.rs +++ b/tests/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.rs @@ -13,7 +13,7 @@ fn foo<'a, I : for<'x> Foo<&'x isize>>( let y: I::A = x; } -fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>( +fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>( //~ ERROR one or more lifetime errors x: >::A, y: >::A, cond: bool) diff --git a/tests/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.stderr b/tests/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.stderr index 42d83fca6ca83..15567a9143a18 100644 --- a/tests/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.stderr +++ b/tests/ui/associated-types/associated-types-project-from-hrtb-in-fn-body.stderr @@ -24,7 +24,13 @@ LL | let z: I::A = if cond { x } else { y }; | = help: consider adding the following bound: `'a: 'b` -help: `'a` and `'b` must be the same: replace one with the other +error: one or more lifetime errors were found in this item + --> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:16:4 + | +LL | fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>( + | ^^^ + | + = help: `'a` and `'b` must be the same: replace one with the other -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.stderr b/tests/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.stderr index 2ecee1341abd3..1cfdde9ff1057 100644 --- a/tests/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.stderr +++ b/tests/ui/associated-types/cache/project-fn-ret-contravariant.krisskross.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/project-fn-ret-contravariant.rs:46:4 + --> $DIR/project-fn-ret-contravariant.rs:47:4 | LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { | -- -- lifetime `'b` defined here @@ -12,7 +12,7 @@ LL | (a, b) = help: consider adding the following bound: `'a: 'b` error: lifetime may not live long enough - --> $DIR/project-fn-ret-contravariant.rs:46:4 + --> $DIR/project-fn-ret-contravariant.rs:47:4 | LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { | -- -- lifetime `'b` defined here @@ -24,7 +24,13 @@ LL | (a, b) | = help: consider adding the following bound: `'b: 'a` -help: `'a` and `'b` must be the same: replace one with the other +error: one or more lifetime errors were found in this item + --> $DIR/project-fn-ret-contravariant.rs:43:4 + | +LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { + | ^^^^^^^^^ + | + = help: `'a` and `'b` must be the same: replace one with the other -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/associated-types/cache/project-fn-ret-contravariant.rs b/tests/ui/associated-types/cache/project-fn-ret-contravariant.rs index 6763155790086..44a03a9df639e 100644 --- a/tests/ui/associated-types/cache/project-fn-ret-contravariant.rs +++ b/tests/ui/associated-types/cache/project-fn-ret-contravariant.rs @@ -41,6 +41,7 @@ fn baz<'a,'b>(x: &'a u32) -> &'static u32 { #[cfg(krisskross)] // two instantiations, mixing and matching: BAD fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) { + //[krisskross]~^ ERROR one or more lifetime errors let a = bar(foo, y); let b = bar(foo, x); (a, b) //[krisskross]~ ERROR lifetime may not live long enough diff --git a/tests/ui/associated-types/cache/project-fn-ret-invariant.krisskross.stderr b/tests/ui/associated-types/cache/project-fn-ret-invariant.krisskross.stderr index ada12c7ee91d0..86189e9493247 100644 --- a/tests/ui/associated-types/cache/project-fn-ret-invariant.krisskross.stderr +++ b/tests/ui/associated-types/cache/project-fn-ret-invariant.krisskross.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/project-fn-ret-invariant.rs:59:5 + --> $DIR/project-fn-ret-invariant.rs:61:5 | LL | fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { | -- -- lifetime `'b` defined here @@ -15,7 +15,7 @@ LL | (a, b) = help: see for more information about variance error: lifetime may not live long enough - --> $DIR/project-fn-ret-invariant.rs:59:5 + --> $DIR/project-fn-ret-invariant.rs:61:5 | LL | fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { | -- -- lifetime `'b` defined here @@ -30,7 +30,13 @@ LL | (a, b) = note: the struct `Type<'a>` is invariant over the parameter `'a` = help: see for more information about variance -help: `'a` and `'b` must be the same: replace one with the other +error: one or more lifetime errors were found in this item + --> $DIR/project-fn-ret-invariant.rs:57:4 + | +LL | fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { + | ^^^^^^^^^ + | + = help: `'a` and `'b` must be the same: replace one with the other -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/associated-types/cache/project-fn-ret-invariant.oneuse.stderr b/tests/ui/associated-types/cache/project-fn-ret-invariant.oneuse.stderr index 3ef6b85c407af..ad17002821d71 100644 --- a/tests/ui/associated-types/cache/project-fn-ret-invariant.oneuse.stderr +++ b/tests/ui/associated-types/cache/project-fn-ret-invariant.oneuse.stderr @@ -1,11 +1,11 @@ error: lifetime may not live long enough - --> $DIR/project-fn-ret-invariant.rs:40:13 + --> $DIR/project-fn-ret-invariant.rs:41:13 | LL | fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here -LL | let f = foo; // <-- No consistent type can be inferred for `f` here. +... LL | let a = bar(f, x); | ^^^^^^^^^ argument requires that `'b` must outlive `'a` | @@ -15,7 +15,7 @@ LL | let a = bar(f, x); = help: see for more information about variance error: lifetime may not live long enough - --> $DIR/project-fn-ret-invariant.rs:42:13 + --> $DIR/project-fn-ret-invariant.rs:43:13 | LL | fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { | -- -- lifetime `'b` defined here @@ -30,7 +30,13 @@ LL | let b = bar(f, y); = note: the struct `Type<'a>` is invariant over the parameter `'a` = help: see for more information about variance -help: `'a` and `'b` must be the same: replace one with the other +error: one or more lifetime errors were found in this item + --> $DIR/project-fn-ret-invariant.rs:38:4 + | +LL | fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { + | ^^^ + | + = help: `'a` and `'b` must be the same: replace one with the other -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/associated-types/cache/project-fn-ret-invariant.rs b/tests/ui/associated-types/cache/project-fn-ret-invariant.rs index 4ac642c0e04b5..b1883f45b16f5 100644 --- a/tests/ui/associated-types/cache/project-fn-ret-invariant.rs +++ b/tests/ui/associated-types/cache/project-fn-ret-invariant.rs @@ -36,6 +36,7 @@ fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { #[cfg(oneuse)] // one instantiation: BAD fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { + //[oneuse]~^ ERROR one or more lifetime errors let f = foo; // <-- No consistent type can be inferred for `f` here. let a = bar(f, x); //[oneuse]~^ ERROR lifetime may not live long enough @@ -54,6 +55,7 @@ fn baz<'a, 'b>(x: Type<'a>) -> Type<'static> { #[cfg(krisskross)] // two instantiations, mixing and matching: BAD fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) { + //[krisskross]~^ ERROR one or more lifetime errors let a = bar(foo, y); let b = bar(foo, x); (a, b) diff --git a/tests/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr b/tests/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr index b8100f6dfaec0..547bde2e5a0a9 100644 --- a/tests/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr +++ b/tests/ui/associated-types/cache/project-fn-ret-invariant.transmute.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/project-fn-ret-invariant.rs:52:5 + --> $DIR/project-fn-ret-invariant.rs:53:5 | LL | fn baz<'a, 'b>(x: Type<'a>) -> Type<'static> { | -- lifetime `'a` defined here diff --git a/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.rs b/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.rs index ce94ba657b86f..71fca8858c78b 100644 --- a/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.rs +++ b/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.rs @@ -3,7 +3,7 @@ trait Trait<'a> {} -fn change_lt<'a, 'b>(x: *mut dyn Trait<'a>) -> *mut dyn Trait<'b> { +fn change_lt<'a, 'b>(x: *mut dyn Trait<'a>) -> *mut dyn Trait<'b> { //~ ERROR one or more x as _ //~ error: lifetime may not live long enough //~| error: lifetime may not live long enough } @@ -26,14 +26,14 @@ trait Assocked { type Assoc: ?Sized; } -fn change_assoc_0<'a, 'b>( +fn change_assoc_0<'a, 'b>( //~ ERROR one or more lifetime errors x: *mut dyn Assocked, ) -> *mut dyn Assocked { x as _ //~ error: lifetime may not live long enough //~| error: lifetime may not live long enough } -fn change_assoc_1<'a, 'b>( +fn change_assoc_1<'a, 'b>( //~ ERROR one or more lifetime errors x: *mut dyn Assocked>, ) -> *mut dyn Assocked> { x as _ //~ error: lifetime may not live long enough diff --git a/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.stderr b/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.stderr index f2c060e4b279b..74a92f459aa62 100644 --- a/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.stderr +++ b/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.stderr @@ -42,7 +42,13 @@ LL | x as _ = note: this was previously accepted by the compiler but was changed recently = help: see for more information -help: `'b` and `'a` must be the same: replace one with the other +error: one or more lifetime errors were found in this item + --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:6:4 + | +LL | fn change_lt<'a, 'b>(x: *mut dyn Trait<'a>) -> *mut dyn Trait<'b> { + | ^^^^^^^^^ + | + = help: `'b` and `'a` must be the same: replace one with the other error: lifetime may not live long enough --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:12:5 @@ -156,9 +162,13 @@ LL | x as _ = note: this was previously accepted by the compiler but was changed recently = help: see for more information -help: `'b` and `'a` must be the same: replace one with the other +error: one or more lifetime errors were found in this item + --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:29:4 | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +LL | fn change_assoc_0<'a, 'b>( + | ^^^^^^^^^^^^^^ + | + = help: `'b` and `'a` must be the same: replace one with the other error: lifetime may not live long enough --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:39:5 @@ -206,9 +216,13 @@ LL | x as _ = note: this was previously accepted by the compiler but was changed recently = help: see for more information -help: `'b` and `'a` must be the same: replace one with the other +error: one or more lifetime errors were found in this item + --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:36:4 + | +LL | fn change_assoc_1<'a, 'b>( + | ^^^^^^^^^^^^^^ | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = help: `'b` and `'a` must be the same: replace one with the other error[E0521]: borrowed data escapes outside of function --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:46:5 @@ -233,7 +247,7 @@ LL | require_static(ptr as _) = note: this was previously accepted by the compiler but was changed recently = help: see for more information -error: aborting due to 11 previous errors +error: aborting due to 14 previous errors Some errors have detailed explanations: E0308, E0521. For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/field_representing_types/invariant.next.stderr b/tests/ui/field_representing_types/invariant.next.stderr index 6a622a8e5dd11..c9e0b03040d85 100644 --- a/tests/ui/field_representing_types/invariant.next.stderr +++ b/tests/ui/field_representing_types/invariant.next.stderr @@ -1,10 +1,11 @@ error: lifetime may not live long enough - --> $DIR/invariant.rs:15:5 + --> $DIR/invariant.rs:16:5 | LL | fn assert_invariant<'a, 'b>(x: field_of!(Struct<'a>, field), y: field_of!(Struct<'b>, field)) { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here +LL | LL | consume(x, y); | ^^^^^^^^^^^^^ argument requires that `'a` must outlive `'b` | @@ -14,12 +15,13 @@ LL | consume(x, y); = help: see for more information about variance error: lifetime may not live long enough - --> $DIR/invariant.rs:15:5 + --> $DIR/invariant.rs:16:5 | LL | fn assert_invariant<'a, 'b>(x: field_of!(Struct<'a>, field), y: field_of!(Struct<'b>, field)) { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here +LL | LL | consume(x, y); | ^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a` | @@ -28,7 +30,13 @@ LL | consume(x, y); = note: the struct `FieldRepresentingType` is invariant over the parameter `T` = help: see for more information about variance -help: `'a` and `'b` must be the same: replace one with the other +error: one or more lifetime errors were found in this item + --> $DIR/invariant.rs:14:4 + | +LL | fn assert_invariant<'a, 'b>(x: field_of!(Struct<'a>, field), y: field_of!(Struct<'b>, field)) { + | ^^^^^^^^^^^^^^^^ + | + = help: `'a` and `'b` must be the same: replace one with the other -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/field_representing_types/invariant.old.stderr b/tests/ui/field_representing_types/invariant.old.stderr index 6a622a8e5dd11..c9e0b03040d85 100644 --- a/tests/ui/field_representing_types/invariant.old.stderr +++ b/tests/ui/field_representing_types/invariant.old.stderr @@ -1,10 +1,11 @@ error: lifetime may not live long enough - --> $DIR/invariant.rs:15:5 + --> $DIR/invariant.rs:16:5 | LL | fn assert_invariant<'a, 'b>(x: field_of!(Struct<'a>, field), y: field_of!(Struct<'b>, field)) { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here +LL | LL | consume(x, y); | ^^^^^^^^^^^^^ argument requires that `'a` must outlive `'b` | @@ -14,12 +15,13 @@ LL | consume(x, y); = help: see for more information about variance error: lifetime may not live long enough - --> $DIR/invariant.rs:15:5 + --> $DIR/invariant.rs:16:5 | LL | fn assert_invariant<'a, 'b>(x: field_of!(Struct<'a>, field), y: field_of!(Struct<'b>, field)) { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here +LL | LL | consume(x, y); | ^^^^^^^^^^^^^ argument requires that `'b` must outlive `'a` | @@ -28,7 +30,13 @@ LL | consume(x, y); = note: the struct `FieldRepresentingType` is invariant over the parameter `T` = help: see for more information about variance -help: `'a` and `'b` must be the same: replace one with the other +error: one or more lifetime errors were found in this item + --> $DIR/invariant.rs:14:4 + | +LL | fn assert_invariant<'a, 'b>(x: field_of!(Struct<'a>, field), y: field_of!(Struct<'b>, field)) { + | ^^^^^^^^^^^^^^^^ + | + = help: `'a` and `'b` must be the same: replace one with the other -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/field_representing_types/invariant.rs b/tests/ui/field_representing_types/invariant.rs index 16a45e63c79c5..b9b42b2f29105 100644 --- a/tests/ui/field_representing_types/invariant.rs +++ b/tests/ui/field_representing_types/invariant.rs @@ -12,6 +12,7 @@ pub struct Struct<'a> { fn consume<'a>(_: field_of!(Struct<'a>, field), _: field_of!(Struct<'a>, field)) {} fn assert_invariant<'a, 'b>(x: field_of!(Struct<'a>, field), y: field_of!(Struct<'b>, field)) { + //~^ ERROR one or more lifetime errors consume(x, y); //~^ ERROR: lifetime may not live long enough //~^^ ERROR: lifetime may not live long enough diff --git a/tests/ui/fn/fn_def_coercion.rs b/tests/ui/fn/fn_def_coercion.rs index 31c8fa41de17c..40a3d6aa9722b 100644 --- a/tests/ui/fn/fn_def_coercion.rs +++ b/tests/ui/fn/fn_def_coercion.rs @@ -6,7 +6,7 @@ fn foo(t: T) -> T { t } -fn f<'a, 'b, 'c: 'a + 'b>(a: &'a (), b: &'b (), c: &'c ()) { +fn f<'a, 'b, 'c: 'a + 'b>(a: &'a (), b: &'b (), c: &'c ()) { //~ ERROR one or more let mut x = foo::<&'a ()>; //~ ERROR: lifetime may not live long enough x = foo::<&'b ()>; //~ ERROR: lifetime may not live long enough x = foo::<&'c ()>; @@ -25,7 +25,7 @@ fn h<'a, 'b, 'c: 'a + 'b>(a: &'a (), b: &'b (), c: &'c ()) { let _: &'a () = x(c); } -fn i<'a, 'b, 'c: 'a + 'b>(a: &'a (), b: &'b (), c: &'c ()) { +fn i<'a, 'b, 'c: 'a + 'b>(a: &'a (), b: &'b (), c: &'c ()) { //~ ERROR one or more let mut x = foo::<&'c ()>; x = foo::<&'b ()>; //~ ERROR lifetime may not live long enough x = foo::<&'a ()>; //~ ERROR lifetime may not live long enough @@ -34,7 +34,7 @@ fn i<'a, 'b, 'c: 'a + 'b>(a: &'a (), b: &'b (), c: &'c ()) { x(c); } -fn j<'a, 'b, 'c: 'a + 'b>(a: &'a (), b: &'b (), c: &'c ()) { +fn j<'a, 'b, 'c: 'a + 'b>(a: &'a (), b: &'b (), c: &'c ()) { //~ ERROR one or more let x = match true { true => foo::<&'b ()>, //~ ERROR lifetime may not live long enough false => foo::<&'a ()>, //~ ERROR lifetime may not live long enough diff --git a/tests/ui/fn/fn_def_coercion.stderr b/tests/ui/fn/fn_def_coercion.stderr index 85e234c839341..3428a118b51a2 100644 --- a/tests/ui/fn/fn_def_coercion.stderr +++ b/tests/ui/fn/fn_def_coercion.stderr @@ -29,7 +29,13 @@ LL | x = foo::<&'b ()>; = note: the function `foo` is invariant over the parameter `T` = help: see for more information about variance -help: `'a` and `'b` must be the same: replace one with the other +error: one or more lifetime errors were found in this item + --> $DIR/fn_def_coercion.rs:9:4 + | +LL | fn f<'a, 'b, 'c: 'a + 'b>(a: &'a (), b: &'b (), c: &'c ()) { + | ^ + | + = help: `'a` and `'b` must be the same: replace one with the other error: lifetime may not live long enough --> $DIR/fn_def_coercion.rs:20:12 @@ -76,9 +82,13 @@ LL | x = foo::<&'a ()>; = note: the function `foo` is invariant over the parameter `T` = help: see for more information about variance -help: `'a` and `'b` must be the same: replace one with the other +error: one or more lifetime errors were found in this item + --> $DIR/fn_def_coercion.rs:28:4 + | +LL | fn i<'a, 'b, 'c: 'a + 'b>(a: &'a (), b: &'b (), c: &'c ()) { + | ^ | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = help: `'a` and `'b` must be the same: replace one with the other error: lifetime may not live long enough --> $DIR/fn_def_coercion.rs:39:17 @@ -112,9 +122,13 @@ LL | false => foo::<&'a ()>, = note: the function `foo` is invariant over the parameter `T` = help: see for more information about variance -help: `'a` and `'b` must be the same: replace one with the other +error: one or more lifetime errors were found in this item + --> $DIR/fn_def_coercion.rs:37:4 | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +LL | fn j<'a, 'b, 'c: 'a + 'b>(a: &'a (), b: &'b (), c: &'c ()) { + | ^ + | + = help: `'a` and `'b` must be the same: replace one with the other error: lifetime may not live long enough --> $DIR/fn_def_coercion.rs:49:17 @@ -148,10 +162,5 @@ LL | false => foo::<&'a ()>, = note: the function `foo` is invariant over the parameter `T` = help: see for more information about variance -help: the following changes may resolve your lifetime errors - | - = help: add bound `'a: 'c` - = help: add bound `'b: 'a` - -error: aborting due to 9 previous errors +error: aborting due to 12 previous errors diff --git a/tests/ui/impl-trait/precise-capturing/rpitit.rs b/tests/ui/impl-trait/precise-capturing/rpitit.rs index 91c52817d8573..7d17a3a936ae5 100644 --- a/tests/ui/impl-trait/precise-capturing/rpitit.rs +++ b/tests/ui/impl-trait/precise-capturing/rpitit.rs @@ -9,7 +9,7 @@ trait TraitLt<'a: 'a> { fn hello() -> impl Sized + use; //~^ ERROR `impl Trait` captures lifetime parameter, but it is not mentioned in `use<...>` precise captures list } -fn trait_lt<'a, 'b, T: for<'r> TraitLt<'r>> () { +fn trait_lt<'a, 'b, T: for<'r> TraitLt<'r>> () { //~ ERROR one or more lifetime errors eq_types( //~^ ERROR lifetime may not live long enough //~| ERROR lifetime may not live long enough diff --git a/tests/ui/impl-trait/precise-capturing/rpitit.stderr b/tests/ui/impl-trait/precise-capturing/rpitit.stderr index ff461e81079b8..f294a2d34e355 100644 --- a/tests/ui/impl-trait/precise-capturing/rpitit.stderr +++ b/tests/ui/impl-trait/precise-capturing/rpitit.stderr @@ -40,7 +40,13 @@ LL | | ); | = help: consider adding the following bound: `'b: 'a` -help: `'a` and `'b` must be the same: replace one with the other +error: one or more lifetime errors were found in this item + --> $DIR/rpitit.rs:12:4 + | +LL | fn trait_lt<'a, 'b, T: for<'r> TraitLt<'r>> () { + | ^^^^^^^^ + | + = help: `'a` and `'b` must be the same: replace one with the other -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors diff --git a/tests/ui/implied-bounds/normalization-preserve-equality.borrowck_current.stderr b/tests/ui/implied-bounds/normalization-preserve-equality.borrowck_current.stderr index 008de7a7afc63..1401cd89f28d8 100644 --- a/tests/ui/implied-bounds/normalization-preserve-equality.borrowck_current.stderr +++ b/tests/ui/implied-bounds/normalization-preserve-equality.borrowck_current.stderr @@ -22,7 +22,13 @@ LL | fn test_borrowck<'a, 'b>(_: ( as Trait>::Ty, Equal<'a, 'b>)) | = help: consider adding the following bound: `'b: 'a` -help: `'a` and `'b` must be the same: replace one with the other +error: one or more lifetime errors were found in this item + --> $DIR/normalization-preserve-equality.rs:34:4 + | +LL | fn test_borrowck<'a, 'b>(_: ( as Trait>::Ty, Equal<'a, 'b>)) { + | ^^^^^^^^^^^^^ + | + = help: `'a` and `'b` must be the same: replace one with the other -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/lub-glb/empty-binders-err.stderr b/tests/ui/lub-glb/empty-binders-err.stderr index f86f22d5e40bf..68b62c87e85b9 100644 --- a/tests/ui/lub-glb/empty-binders-err.stderr +++ b/tests/ui/lub-glb/empty-binders-err.stderr @@ -24,11 +24,6 @@ LL | let _: &'upper () = match v { | = help: consider adding the following bound: `'b: 'upper` -help: the following changes may resolve your lifetime errors - | - = help: add bound `'a: 'upper` - = help: add bound `'b: 'upper` - error: lifetime may not live long enough --> $DIR/empty-binders-err.rs:35:12 | diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-both-lower-bounds.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-both-lower-bounds.stderr index af7ea253cc52a..38c1d9c5efc9a 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-both-lower-bounds.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-both-lower-bounds.stderr @@ -70,10 +70,5 @@ LL | | ); = note: the struct `Cell` is invariant over the parameter `T` = help: see for more information about variance -help: the following changes may resolve your lifetime errors - | - = help: add bound `'a: 'c` - = help: add bound `'b: 'c` - error: aborting due to 2 previous errors diff --git a/tests/ui/nll/outlives-suggestion-more.rs b/tests/ui/nll/outlives-suggestion-more.rs index 2e1359fe5d496..2f49ad6b85d35 100644 --- a/tests/ui/nll/outlives-suggestion-more.rs +++ b/tests/ui/nll/outlives-suggestion-more.rs @@ -7,13 +7,13 @@ fn foo1<'a, 'b, 'c, 'd>(x: &'a usize, y: &'b usize) -> (&'c usize, &'d usize) { } // Should suggest: 'a: 'c and use 'static instead of 'b -fn foo2<'a, 'b, 'c>(x: &'a usize, y: &'b usize) -> (&'c usize, &'static usize) { +fn foo2<'a, 'b, 'c>(x: &'a usize, y: &'b usize) -> (&'c usize, &'static usize) { //~ ERROR one or (x, y) //~ERROR lifetime may not live long enough //~^ERROR lifetime may not live long enough } // Should suggest: 'a and 'b are the same and use 'static instead of 'c -fn foo3<'a, 'b, 'c, 'd, 'e>( +fn foo3<'a, 'b, 'c, 'd, 'e>( //~ ERROR one or more lifetime errors x: &'a usize, y: &'b usize, z: &'c usize, diff --git a/tests/ui/nll/outlives-suggestion-more.stderr b/tests/ui/nll/outlives-suggestion-more.stderr index c8c604b5b4c78..0b79395113bf1 100644 --- a/tests/ui/nll/outlives-suggestion-more.stderr +++ b/tests/ui/nll/outlives-suggestion-more.stderr @@ -22,11 +22,6 @@ LL | (x, y) | = help: consider adding the following bound: `'b: 'd` -help: the following changes may resolve your lifetime errors - | - = help: add bound `'a: 'c` - = help: add bound `'b: 'd` - error: lifetime may not live long enough --> $DIR/outlives-suggestion-more.rs:11:5 | @@ -47,9 +42,12 @@ LL | fn foo2<'a, 'b, 'c>(x: &'a usize, y: &'b usize) -> (&'c usize, &'static usi LL | (x, y) | ^^^^^^ returning this value requires that `'b` must outlive `'static` -help: the following changes may resolve your lifetime errors +error: one or more lifetime errors were found in this item + --> $DIR/outlives-suggestion-more.rs:10:4 + | +LL | fn foo2<'a, 'b, 'c>(x: &'a usize, y: &'b usize) -> (&'c usize, &'static usize) { + | ^^^^ | - = help: add bound `'a: 'c` = help: replace `'b` with `'static` error: lifetime may not live long enough @@ -87,10 +85,14 @@ LL | fn foo3<'a, 'b, 'c, 'd, 'e>( LL | (x, y, z) | ^^^^^^^^^ returning this value requires that `'c` must outlive `'static` -help: the following changes may resolve your lifetime errors +error: one or more lifetime errors were found in this item + --> $DIR/outlives-suggestion-more.rs:16:4 + | +LL | fn foo3<'a, 'b, 'c, 'd, 'e>( + | ^^^^ | = help: `'a` and `'b` must be the same: replace one with the other = help: replace `'c` with `'static` -error: aborting due to 7 previous errors +error: aborting due to 9 previous errors diff --git a/tests/ui/nll/outlives-suggestion-simple.rs b/tests/ui/nll/outlives-suggestion-simple.rs index 2a5c31e3a6468..81d8d3dba9933 100644 --- a/tests/ui/nll/outlives-suggestion-simple.rs +++ b/tests/ui/nll/outlives-suggestion-simple.rs @@ -8,7 +8,7 @@ fn foo2<'a>(x: &'a usize) -> &'static usize { x //~ERROR lifetime may not live long enough } -fn foo3<'a, 'b>(x: &'a usize, y: &'b usize) -> (&'b usize, &'a usize) { +fn foo3<'a, 'b>(x: &'a usize, y: &'b usize) -> (&'b usize, &'a usize) { //~ ERROR one or more (x, y) //~ERROR lifetime may not live long enough //~^ERROR lifetime may not live long enough } diff --git a/tests/ui/nll/outlives-suggestion-simple.stderr b/tests/ui/nll/outlives-suggestion-simple.stderr index 669532005b292..36e4d8b43c6d6 100644 --- a/tests/ui/nll/outlives-suggestion-simple.stderr +++ b/tests/ui/nll/outlives-suggestion-simple.stderr @@ -42,7 +42,13 @@ LL | (x, y) | = help: consider adding the following bound: `'b: 'a` -help: `'a` and `'b` must be the same: replace one with the other +error: one or more lifetime errors were found in this item + --> $DIR/outlives-suggestion-simple.rs:11:4 + | +LL | fn foo3<'a, 'b>(x: &'a usize, y: &'b usize) -> (&'b usize, &'a usize) { + | ^^^^ + | + = help: `'a` and `'b` must be the same: replace one with the other error: lifetime may not live long enough --> $DIR/outlives-suggestion-simple.rs:20:5 @@ -104,5 +110,5 @@ LL | Bar2::new(&self) = note: the struct `Foo2<'a>` is invariant over the parameter `'a` = help: see for more information about variance -error: aborting due to 9 previous errors +error: aborting due to 10 previous errors diff --git a/tests/ui/nll/polonius/flow-sensitive-invariance.nll.stderr b/tests/ui/nll/polonius/flow-sensitive-invariance.nll.stderr index 5756148f4eb2a..6283042e16f33 100644 --- a/tests/ui/nll/polonius/flow-sensitive-invariance.nll.stderr +++ b/tests/ui/nll/polonius/flow-sensitive-invariance.nll.stderr @@ -1,11 +1,11 @@ error: lifetime may not live long enough - --> $DIR/flow-sensitive-invariance.rs:20:17 + --> $DIR/flow-sensitive-invariance.rs:22:17 | LL | fn use_it<'a, 'b>(choice: bool) -> Result, Invariant<'b>> { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here -LL | let returned_value = create_invariant(); +... LL | if choice { Ok(returned_value) } else { Err(returned_value) } | ^^^^^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` | @@ -15,13 +15,13 @@ LL | if choice { Ok(returned_value) } else { Err(returned_value) } = help: see for more information about variance error: lifetime may not live long enough - --> $DIR/flow-sensitive-invariance.rs:20:45 + --> $DIR/flow-sensitive-invariance.rs:22:45 | LL | fn use_it<'a, 'b>(choice: bool) -> Result, Invariant<'b>> { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here -LL | let returned_value = create_invariant(); +... LL | if choice { Ok(returned_value) } else { Err(returned_value) } | ^^^^^^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` | @@ -30,7 +30,13 @@ LL | if choice { Ok(returned_value) } else { Err(returned_value) } = note: the struct `Invariant<'l>` is invariant over the parameter `'l` = help: see for more information about variance -help: `'a` and `'b` must be the same: replace one with the other +error: one or more lifetime errors were found in this item + --> $DIR/flow-sensitive-invariance.rs:18:4 + | +LL | fn use_it<'a, 'b>(choice: bool) -> Result, Invariant<'b>> { + | ^^^^^^ + | + = help: `'a` and `'b` must be the same: replace one with the other -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/nll/polonius/flow-sensitive-invariance.polonius.stderr b/tests/ui/nll/polonius/flow-sensitive-invariance.polonius.stderr index 5756148f4eb2a..6283042e16f33 100644 --- a/tests/ui/nll/polonius/flow-sensitive-invariance.polonius.stderr +++ b/tests/ui/nll/polonius/flow-sensitive-invariance.polonius.stderr @@ -1,11 +1,11 @@ error: lifetime may not live long enough - --> $DIR/flow-sensitive-invariance.rs:20:17 + --> $DIR/flow-sensitive-invariance.rs:22:17 | LL | fn use_it<'a, 'b>(choice: bool) -> Result, Invariant<'b>> { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here -LL | let returned_value = create_invariant(); +... LL | if choice { Ok(returned_value) } else { Err(returned_value) } | ^^^^^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` | @@ -15,13 +15,13 @@ LL | if choice { Ok(returned_value) } else { Err(returned_value) } = help: see for more information about variance error: lifetime may not live long enough - --> $DIR/flow-sensitive-invariance.rs:20:45 + --> $DIR/flow-sensitive-invariance.rs:22:45 | LL | fn use_it<'a, 'b>(choice: bool) -> Result, Invariant<'b>> { | -- -- lifetime `'b` defined here | | | lifetime `'a` defined here -LL | let returned_value = create_invariant(); +... LL | if choice { Ok(returned_value) } else { Err(returned_value) } | ^^^^^^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a` | @@ -30,7 +30,13 @@ LL | if choice { Ok(returned_value) } else { Err(returned_value) } = note: the struct `Invariant<'l>` is invariant over the parameter `'l` = help: see for more information about variance -help: `'a` and `'b` must be the same: replace one with the other +error: one or more lifetime errors were found in this item + --> $DIR/flow-sensitive-invariance.rs:18:4 + | +LL | fn use_it<'a, 'b>(choice: bool) -> Result, Invariant<'b>> { + | ^^^^^^ + | + = help: `'a` and `'b` must be the same: replace one with the other -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/nll/polonius/flow-sensitive-invariance.rs b/tests/ui/nll/polonius/flow-sensitive-invariance.rs index c5571f131da3b..cb7cb51189d18 100644 --- a/tests/ui/nll/polonius/flow-sensitive-invariance.rs +++ b/tests/ui/nll/polonius/flow-sensitive-invariance.rs @@ -16,6 +16,8 @@ fn create_invariant<'l>() -> Invariant<'l> { } fn use_it<'a, 'b>(choice: bool) -> Result, Invariant<'b>> { + //[nll]~^ ERROR one or more lifetime errors + //[polonius]~^^ ERROR one or more lifetime errors let returned_value = create_invariant(); if choice { Ok(returned_value) } else { Err(returned_value) } //[nll]~^ ERROR lifetime may not live long enough diff --git a/tests/ui/nll/type-check-pointer-coercions.rs b/tests/ui/nll/type-check-pointer-coercions.rs index 66da57248f98f..6eceebeda39ac 100644 --- a/tests/ui/nll/type-check-pointer-coercions.rs +++ b/tests/ui/nll/type-check-pointer-coercions.rs @@ -6,7 +6,7 @@ fn unique_to_const<'a, 'b>(x: &mut &'a i32) -> *const &'b i32 { x //~ ERROR } -fn unique_to_mut<'a, 'b>(x: &mut &'a i32) -> *mut &'b i32 { +fn unique_to_mut<'a, 'b>(x: &mut &'a i32) -> *mut &'b i32 { //~ ERROR one or more lifetime errors // Two errors because *mut is invariant x //~ ERROR //~| ERROR diff --git a/tests/ui/nll/type-check-pointer-coercions.stderr b/tests/ui/nll/type-check-pointer-coercions.stderr index ef2d928786fca..042bbb456f2ef 100644 --- a/tests/ui/nll/type-check-pointer-coercions.stderr +++ b/tests/ui/nll/type-check-pointer-coercions.stderr @@ -54,7 +54,13 @@ LL | x = note: mutable pointers are invariant over their type parameter = help: see for more information about variance -help: `'b` and `'a` must be the same: replace one with the other +error: one or more lifetime errors were found in this item + --> $DIR/type-check-pointer-coercions.rs:9:4 + | +LL | fn unique_to_mut<'a, 'b>(x: &mut &'a i32) -> *mut &'b i32 { + | ^^^^^^^^^^^^^ + | + = help: `'b` and `'a` must be the same: replace one with the other error: lifetime may not live long enough --> $DIR/type-check-pointer-coercions.rs:16:5 @@ -107,5 +113,5 @@ LL | y | = help: consider adding the following bound: `'a: 'b` -error: aborting due to 8 previous errors +error: aborting due to 9 previous errors diff --git a/tests/ui/nll/type-check-pointer-comparisons.rs b/tests/ui/nll/type-check-pointer-comparisons.rs index 7b0ffeaef0e21..da417688baa80 100644 --- a/tests/ui/nll/type-check-pointer-comparisons.rs +++ b/tests/ui/nll/type-check-pointer-comparisons.rs @@ -1,18 +1,18 @@ // Check that we assert that pointers have a common subtype for comparisons -fn compare_const<'a, 'b>(x: *const &mut &'a i32, y: *const &mut &'b i32) { +fn compare_const<'a, 'b>(x: *const &mut &'a i32, y: *const &mut &'b i32) { //~ ERROR one or more x == y; //~^ ERROR lifetime may not live long enough //~| ERROR lifetime may not live long enough } -fn compare_mut<'a, 'b>(x: *mut &'a i32, y: *mut &'b i32) { +fn compare_mut<'a, 'b>(x: *mut &'a i32, y: *mut &'b i32) { //~ ERROR one or more x == y; //~^ ERROR lifetime may not live long enough //~| ERROR lifetime may not live long enough } -fn compare_fn_ptr<'a, 'b, 'c>(f: fn(&'c mut &'a i32), g: fn(&'c mut &'b i32)) { +fn compare_fn_ptr<'a, 'b, 'c>(f: fn(&'c mut &'a i32), g: fn(&'c mut &'b i32)) { //~ ERROR one or f == g; //~^ ERROR lifetime may not live long enough //~| ERROR lifetime may not live long enough diff --git a/tests/ui/nll/type-check-pointer-comparisons.stderr b/tests/ui/nll/type-check-pointer-comparisons.stderr index e362dfb3c6e7a..50ed9bc3cd3fa 100644 --- a/tests/ui/nll/type-check-pointer-comparisons.stderr +++ b/tests/ui/nll/type-check-pointer-comparisons.stderr @@ -28,7 +28,13 @@ LL | x == y; = note: mutable references are invariant over their type parameter = help: see for more information about variance -help: `'a` and `'b` must be the same: replace one with the other +error: one or more lifetime errors were found in this item + --> $DIR/type-check-pointer-comparisons.rs:3:4 + | +LL | fn compare_const<'a, 'b>(x: *const &mut &'a i32, y: *const &mut &'b i32) { + | ^^^^^^^^^^^^^ + | + = help: `'a` and `'b` must be the same: replace one with the other error: lifetime may not live long enough --> $DIR/type-check-pointer-comparisons.rs:10:5 @@ -60,9 +66,13 @@ LL | x == y; = note: mutable pointers are invariant over their type parameter = help: see for more information about variance -help: `'a` and `'b` must be the same: replace one with the other +error: one or more lifetime errors were found in this item + --> $DIR/type-check-pointer-comparisons.rs:9:4 | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +LL | fn compare_mut<'a, 'b>(x: *mut &'a i32, y: *mut &'b i32) { + | ^^^^^^^^^^^ + | + = help: `'a` and `'b` must be the same: replace one with the other error: lifetime may not live long enough --> $DIR/type-check-pointer-comparisons.rs:16:5 @@ -94,9 +104,13 @@ LL | f == g; = note: mutable references are invariant over their type parameter = help: see for more information about variance -help: `'a` and `'b` must be the same: replace one with the other +error: one or more lifetime errors were found in this item + --> $DIR/type-check-pointer-comparisons.rs:15:4 + | +LL | fn compare_fn_ptr<'a, 'b, 'c>(f: fn(&'c mut &'a i32), g: fn(&'c mut &'b i32)) { + | ^^^^^^^^^^^^^^ | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = help: `'a` and `'b` must be the same: replace one with the other -error: aborting due to 6 previous errors +error: aborting due to 9 previous errors diff --git a/tests/ui/nll/user-annotations/normalization-2.rs b/tests/ui/nll/user-annotations/normalization-2.rs index dddba2265c613..63ac7a7a2c02c 100644 --- a/tests/ui/nll/user-annotations/normalization-2.rs +++ b/tests/ui/nll/user-annotations/normalization-2.rs @@ -44,14 +44,14 @@ fn test_local<'a>() { //~^ ERROR lifetime may not live long enough } -fn test_closure_sig<'a, 'b>() { +fn test_closure_sig<'a, 'b>() { //~ ERROR one or more lifetime errors were found |_: Ty<'a>| {}; //~^ ERROR lifetime may not live long enough || -> Option> { None }; //~^ ERROR lifetime may not live long enough } -fn test_path<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h>() { +fn test_path<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h>() { //~ ERROR one or more lifetime errors were found >::method::>; //~^ ERROR lifetime may not live long enough >::method::>; @@ -78,14 +78,14 @@ fn test_path<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h>() { //~^ ERROR lifetime may not live long enough } -fn test_call<'a, 'b, 'c>() { +fn test_call<'a, 'b, 'c>() { //~ ERROR one or more lifetime errors were found >::method::>(); //~^ ERROR lifetime may not live long enough >::method::>(); //~^ ERROR lifetime may not live long enough } -fn test_variants<'a, 'b, 'c>() { +fn test_variants<'a, 'b, 'c>() { //~ ERROR one or more lifetime errors were found >::Struct {}; //~^ ERROR lifetime may not live long enough >::Tuple(); @@ -94,14 +94,14 @@ fn test_variants<'a, 'b, 'c>() { //~^ ERROR lifetime may not live long enough } -fn test_method_call<'a, 'b>(x: MyTy<()>) { +fn test_method_call<'a, 'b>(x: MyTy<()>) { //~ ERROR one or more lifetime errors were found x.method2::>(); //~^ ERROR lifetime may not live long enough x.trait_method::>(); //~^ ERROR lifetime may not live long enough } -fn test_struct_path<'a, 'b, 'c, 'd>() { +fn test_struct_path<'a, 'b, 'c, 'd>() { //~ ERROR one or more lifetime errors were found struct Struct { x: Option, } trait Project { @@ -126,7 +126,7 @@ fn test_struct_path<'a, 'b, 'c, 'd>() { //~^ ERROR lifetime may not live long enough } -fn test_pattern<'a, 'b, 'c, 'd, 'e, 'f>() { +fn test_pattern<'a, 'b, 'c, 'd, 'e, 'f>() { //~ ERROR one or more lifetime errors were found use MyTy::*; match MyTy::Unit { Struct::> {..} => {}, diff --git a/tests/ui/nll/user-annotations/normalization-2.stderr b/tests/ui/nll/user-annotations/normalization-2.stderr index dcf049a7a61a0..d8e679cc29137 100644 --- a/tests/ui/nll/user-annotations/normalization-2.stderr +++ b/tests/ui/nll/user-annotations/normalization-2.stderr @@ -23,7 +23,11 @@ LL | fn test_closure_sig<'a, 'b>() { LL | || -> Option> { None }; | ^^^^^^^^^^^^^^ requires that `'b` must outlive `'static` -help: the following changes may resolve your lifetime errors +error: one or more lifetime errors were found in this item + --> $DIR/normalization-2.rs:47:4 + | +LL | fn test_closure_sig<'a, 'b>() { + | ^^^^^^^^^^^^^^^^ | = help: replace `'a` with `'static` = help: replace `'b` with `'static` @@ -99,7 +103,11 @@ LL | fn test_path<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h>() { LL | MyTy::>::Unit; | ^^^^^^^^^^^^^^^^^^^^ requires that `'h` must outlive `'static` -help: the following changes may resolve your lifetime errors +error: one or more lifetime errors were found in this item + --> $DIR/normalization-2.rs:54:4 + | +LL | fn test_path<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h>() { + | ^^^^^^^^^ | = help: replace `'a` with `'static` = help: replace `'b` with `'static` @@ -127,11 +135,14 @@ LL | fn test_call<'a, 'b, 'c>() { LL | >::method::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'b` must outlive `'static` -help: the following changes may resolve your lifetime errors +error: one or more lifetime errors were found in this item + --> $DIR/normalization-2.rs:81:4 + | +LL | fn test_call<'a, 'b, 'c>() { + | ^^^^^^^^^ | = help: replace `'a` with `'static` = help: replace `'b` with `'static` - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: lifetime may not live long enough --> $DIR/normalization-2.rs:89:5 @@ -159,7 +170,11 @@ LL | fn test_variants<'a, 'b, 'c>() { LL | >::Unit; | ^^^^^^^^^^^^^^ requires that `'c` must outlive `'static` -help: the following changes may resolve your lifetime errors +error: one or more lifetime errors were found in this item + --> $DIR/normalization-2.rs:88:4 + | +LL | fn test_variants<'a, 'b, 'c>() { + | ^^^^^^^^^^^^^ | = help: replace `'a` with `'static` = help: replace `'b` with `'static` @@ -182,11 +197,14 @@ LL | fn test_method_call<'a, 'b>(x: MyTy<()>) { LL | x.trait_method::>(); | ^^^^^^^^^^^^ requires that `'b` must outlive `'static` -help: the following changes may resolve your lifetime errors +error: one or more lifetime errors were found in this item + --> $DIR/normalization-2.rs:97:4 + | +LL | fn test_method_call<'a, 'b>(x: MyTy<()>) { + | ^^^^^^^^^^^^^^^^ | = help: replace `'a` with `'static` = help: replace `'b` with `'static` - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: lifetime may not live long enough --> $DIR/normalization-2.rs:117:5 @@ -224,7 +242,11 @@ LL | fn test_struct_path<'a, 'b, 'c, 'd>() { LL | as Project>::Struct { x: None, }; // with SelfTy | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'d` must outlive `'static` -help: the following changes may resolve your lifetime errors +error: one or more lifetime errors were found in this item + --> $DIR/normalization-2.rs:104:4 + | +LL | fn test_struct_path<'a, 'b, 'c, 'd>() { + | ^^^^^^^^^^^^^^^^ | = help: replace `'a` with `'static` = help: replace `'b` with `'static` @@ -285,7 +307,11 @@ LL | fn test_pattern<'a, 'b, 'c, 'd, 'e, 'f>() { LL | >::Unit => {}, | ^^^^^^^^^^^^^^ requires that `'f` must outlive `'static` -help: the following changes may resolve your lifetime errors +error: one or more lifetime errors were found in this item + --> $DIR/normalization-2.rs:129:4 + | +LL | fn test_pattern<'a, 'b, 'c, 'd, 'e, 'f>() { + | ^^^^^^^^^^^^ | = help: replace `'a` with `'static` = help: replace `'b` with `'static` @@ -294,5 +320,5 @@ help: the following changes may resolve your lifetime errors = help: replace `'e` with `'static` = help: replace `'f` with `'static` -error: aborting due to 28 previous errors +error: aborting due to 35 previous errors diff --git a/tests/ui/regions/regions-infer-not-param.rs b/tests/ui/regions/regions-infer-not-param.rs index c3766bce18a2c..381163e565040 100644 --- a/tests/ui/regions/regions-infer-not-param.rs +++ b/tests/ui/regions/regions-infer-not-param.rs @@ -17,7 +17,7 @@ fn take_direct<'a,'b>(p: Direct<'a>) -> Direct<'b> { p } fn take_indirect1(p: Indirect1) -> Indirect1 { p } -fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } +fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } //~ ERROR one or more lifetime //~^ ERROR lifetime may not live long enough //~| ERROR lifetime may not live long enough diff --git a/tests/ui/regions/regions-infer-not-param.stderr b/tests/ui/regions/regions-infer-not-param.stderr index d12f07a772880..74b2638c1c681 100644 --- a/tests/ui/regions/regions-infer-not-param.stderr +++ b/tests/ui/regions/regions-infer-not-param.stderr @@ -34,7 +34,13 @@ LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } = note: the struct `Indirect2<'a>` is invariant over the parameter `'a` = help: see for more information about variance -help: `'b` and `'a` must be the same: replace one with the other +error: one or more lifetime errors were found in this item + --> $DIR/regions-infer-not-param.rs:20:4 + | +LL | fn take_indirect2<'a,'b>(p: Indirect2<'a>) -> Indirect2<'b> { p } + | ^^^^^^^^^^^^^^ + | + = help: `'b` and `'a` must be the same: replace one with the other -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors