Change:
In case there is an undeclared lifetime in an ADT deriving a wrong help message is emited causes the following error thx, bye
There are two things here: 1) the suggestion should try and identify spans coming from macro expansion and not suggest changes 2) in this case expands to the following: Note the param, which could avoid having any lifetimes and thing would work correctly. We can probably change the desugaring to not specify the lifetime and then we would avoid the second unnecessary duplicated error. would you happen to know if there's any clear negative in doing 2 above and if not, point me in the right direction in to make that change?
I believe that we can't remove the explicit lifetime here. This would allow for even if is only implemented for .

Discussion:
); err.span_label(lifetime_ref.span, "undeclared lifetime"); let mut suggests_in_band = false; <ins> let mut suggest_note = true; </ins> for missing in &self.missing_named_lifetime_spots { match missing { MissingLifetimeSpot::Generics(generics) => {

suggests_in_band = true; (generics.span, format!("<{}>", lifetime_ref)) }; <del> err.span_suggestion( span, &format!("consider introducing lifetime `{}` here", lifetime_ref), sugg, Applicability::MaybeIncorrect, ); </del> <ins> if !span.from_expansion() { err.span_suggestion( span, &format!("consider introducing lifetime `{}` here", lifetime_ref), sugg, Applicability::MaybeIncorrect, ); } else if suggest_note { suggest_note = false; // Avoid displaying the same help multiple times. err.span_label( span, &format!( "lifetime `{}` is missing in item created through this procedural  macro", lifetime_ref, ), ); } </ins> } MissingLifetimeSpot::HigherRanked { span, span_type } => { err.span_suggestion(

); err.note( "for more information on higher-ranked polymorphism, visit  <del> https://doc.rust-lang.org/nomicon/hrtb.html", </del> <ins> https://doc.rust-lang.org/nomicon/hrtb.html", </ins> ); } _ => {}

{ err.help( "if you want to experiment with in-band lifetime bindings,  <del> add `#![feature(in_band_lifetimes)]` to the crate attributes", </del> <ins> add `#![feature(in_band_lifetimes)]` to the crate attributes", </ins> ); } err.emit();

<ins> #[derive(Eq, PartialEq)] struct Test { a: &'b str, //~^ ERROR use of undeclared lifetime name `'b` //~| ERROR use of undeclared lifetime name `'b` } trait T { fn foo(&'static self) {} } impl T for Test { fn foo(&'b self) {} //~ ERROR use of undeclared lifetime name `'b` } fn main() {} </ins>

<ins> error[E0261]: use of undeclared lifetime name `'b` --> $DIR/undeclared-lifetime-used-in-debug-macro-issue-70152.rs:13:13 | LL |     fn foo(&'b self) {} |             ^^ undeclared lifetime | = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes help: consider introducing lifetime `'b` here | LL | impl<'b> T for Test { |     ^^^^ help: consider introducing lifetime `'b` here | LL |     fn foo<'b>(&'b self) {} |           ^^^^ error[E0261]: use of undeclared lifetime name `'b` --> $DIR/undeclared-lifetime-used-in-debug-macro-issue-70152.rs:3:9 | LL | struct Test { |            - help: consider introducing lifetime `'b` here: `<'b>` LL |     a: &'b str, |         ^^ undeclared lifetime | = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes 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: 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 For more information about this error, try `rustc --explain E0261`. </ins>