File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
tests/ui/single-use-lifetime Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ #![ deny( single_use_lifetimes) ]
2+
3+ pub enum Data < ' a > {
4+ Borrowed ( & ' a str ) ,
5+ Owned ( String ) ,
6+ }
7+
8+ impl < ' a > Data < ' a > {
9+ pub fn get < ' b : ' a > ( & ' b self ) -> & ' a str {
10+ //~^ ERROR lifetime parameter `'b` only used once
11+ match & self {
12+ Self :: Borrowed ( val) => val,
13+ Self :: Owned ( val) => & val,
14+ }
15+ }
16+ }
17+
18+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error: lifetime parameter `'b` only used once
2+ --> $DIR/issue-117965.rs:9:16
3+ |
4+ LL | pub fn get<'b: 'a>(&'b self) -> &'a str {
5+ | ^^ -- ...is used only here
6+ | |
7+ | this lifetime...
8+ |
9+ note: the lint level is defined here
10+ --> $DIR/issue-117965.rs:1:9
11+ |
12+ LL | #![deny(single_use_lifetimes)]
13+ | ^^^^^^^^^^^^^^^^^^^^
14+ help: elide the single-use lifetime
15+ |
16+ LL - pub fn get<'b: 'a>(&'b self) -> &'a str {
17+ LL + pub fn get(&self) -> &'a str {
18+ |
19+
20+ error: aborting due to 1 previous error
21+
You can’t perform that action at this time.
0 commit comments