File: ignore-non-reference-lifetimes.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (24 lines) | stat: -rw-r--r-- 626 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//@ check-pass

struct Foo<'a>(&'a str);

impl<'b> Foo<'b> {
    fn a<'a>(self: Self, a: &'a str) -> &str {
        //~^ WARNING elided lifetime has a name
        a
    }
    fn b<'a>(self: Foo<'b>, a: &'a str) -> &str {
        //~^ WARNING elided lifetime has a name
        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() {}