add test issue-117965
This commit is contained in:
parent
88189a71e4
commit
0943a6b188
2 changed files with 39 additions and 0 deletions
18
tests/ui/single-use-lifetime/issue-117965.rs
Normal file
18
tests/ui/single-use-lifetime/issue-117965.rs
Normal file
|
@ -0,0 +1,18 @@
|
|||
#![deny(single_use_lifetimes)]
|
||||
|
||||
pub enum Data<'a> {
|
||||
Borrowed(&'a str),
|
||||
Owned(String),
|
||||
}
|
||||
|
||||
impl<'a> Data<'a> {
|
||||
pub fn get<'b: 'a>(&'b self) -> &'a str {
|
||||
//~^ ERROR lifetime parameter `'b` only used once
|
||||
match &self {
|
||||
Self::Borrowed(val) => val,
|
||||
Self::Owned(val) => &val,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
21
tests/ui/single-use-lifetime/issue-117965.stderr
Normal file
21
tests/ui/single-use-lifetime/issue-117965.stderr
Normal file
|
@ -0,0 +1,21 @@
|
|||
error: lifetime parameter `'b` only used once
|
||||
--> $DIR/issue-117965.rs:9:16
|
||||
|
|
||||
LL | pub fn get<'b: 'a>(&'b self) -> &'a str {
|
||||
| ^^ -- ...is used only here
|
||||
| |
|
||||
| this lifetime...
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/issue-117965.rs:1:9
|
||||
|
|
||||
LL | #![deny(single_use_lifetimes)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
help: elide the single-use lifetime
|
||||
|
|
||||
LL - pub fn get<'b: 'a>(&'b self) -> &'a str {
|
||||
LL + pub fn get(&self) -> &'a str {
|
||||
|
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
Loading…
Add table
Reference in a new issue