rust/tests/ui/single-use-lifetime/issue-117965.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

19 lines
353 B
Rust
Raw Normal View History

2024-01-19 15:22:52 -06:00
#![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() {}