diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 36707b5938f..87bf79d722b 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -1674,10 +1674,14 @@ impl<'tcx> LifetimeContext<'_, 'tcx> { ); } else if suggest_note { suggest_note = false; // Avoid displaying the same help multiple times. - err.help(&format!( - "consider introducing lifetime `{}` to the item's generics", - lifetime_ref, - )); + err.span_label( + span, + &format!( + "lifetime `{}` is missing in item created through this procedural \ + macro", + lifetime_ref, + ), + ); } } MissingLifetimeSpot::HigherRanked { span, span_type } => { diff --git a/src/test/ui/lifetimes/undeclared-lifetime-used-in-debug-macro-issue-70152.stderr b/src/test/ui/lifetimes/undeclared-lifetime-used-in-debug-macro-issue-70152.stderr index 01dc0edc61e..30142e24cd5 100644 --- a/src/test/ui/lifetimes/undeclared-lifetime-used-in-debug-macro-issue-70152.stderr +++ b/src/test/ui/lifetimes/undeclared-lifetime-used-in-debug-macro-issue-70152.stderr @@ -27,10 +27,12 @@ LL | a: &'b str, error[E0261]: use of undeclared lifetime name `'b` --> $DIR/undeclared-lifetime-used-in-debug-macro-issue-70152.rs:3:9 | +LL | #[derive(Eq, PartialEq)] + | -- lifetime `'b` is missing in item created through this procedural macro +LL | struct Test { LL | a: &'b str, | ^^ undeclared lifetime | - = help: consider introducing lifetime `'b` to the item's generics = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes error: aborting due to 3 previous errors