Files
rust/tests/ui/self/elision/ignore-non-reference-lifetimes.rs
Jake Goulding 5530744318 Reword mismatched-lifetime-syntaxes text based on feedback
Key changes include:

- Removal of the word "syntax" from the lint message. More accurately,
  it could have been something like "syntax group" or "syntax
  category", but avoiding it completely is easier.
- The primary lint message now reflects exactly which mismatch is
  occurring, instead of trying to be general. A new `help` line is
  general across the mismatch kinds.
- Suggestions have been reduced to be more minimal, no longer also
  changing non-idiomatic but unrelated aspects.
- Suggestion text no longer mentions changes when those changes don't
  occur in that specific suggestion.
2025-07-14 09:52:58 -04:00

25 lines
682 B
Rust

//@ check-pass
struct Foo<'a>(&'a str);
impl<'b> Foo<'b> {
fn a<'a>(self: Self, a: &'a str) -> &str {
//~^ WARNING eliding a lifetime that's named elsewhere is confusing
a
}
fn b<'a>(self: Foo<'b>, a: &'a str) -> &str {
//~^ WARNING eliding a lifetime that's named elsewhere is confusing
a
}
}
struct Foo2<'a>(&'a u32);
impl<'a> Foo2<'a> {
fn foo(self: &Self) -> &u32 { self.0 } // ok
fn bar(self: &Foo2<'a>) -> &u32 { self.0 } // ok (do not look into `Foo`)
fn baz2(self: Self, arg: &u32) -> &u32 { arg } // use lt from `arg`
fn baz3(self: Foo2<'a>, arg: &u32) -> &u32 { arg } // use lt from `arg`
}
fn main() {}