Closed
Description
Minimal Proof:
use std::borrow::Cow;
#[warn(single_use_lifetimes)]
pub fn good<'a,S>( value: S ) -> String
where S: Into<Cow<'a,str>>
{
value.into().into_owned()
}
fn main() -> () {
println!("{}",good("pass"));
}
rustc -v mcve.rs
warning: lifetime parameter `'a` only used once
--> mcve.rs:3:13
|
3 | pub fn good<'a,S>( value: S ) -> String
| ^^ this lifetime...
4 | where S: Into<Cow<'a,str>>
| -- ...is used only here
|
note: lint level defined here
--> mcve.rs:2:8
|
2 | #[warn(single_use_lifetimes)]
| ^^^^^^^^^^^^^^^^^^^^
Alas, doing what is natural ( and what people will tell you to do on IRC channels, only to find that it doesn't work, and writing:
use std::borrow::Cow;
#[warn(single_use_lifetimes)]
pub fn good<S>( value: S ) -> String
where S: Into<Cow<'_,str>>
{
value.into().into_owned()
}
fn main() -> () {
println!("{}",good("pass"));
}
Trips up E0637
error[E0637]: `'_` cannot be used here
--> mcve.rs:4:23
|
4 | where S: Into<Cow<'_,str>>
| ^^ `'_` is a reserved lifetime name
error: aborting due to previous error
I looked at all the other open bugs in this area and I saw several that looked similar( #55057 was closest ), but none were close enough to this, in particular, the error about using a reserved lifetime is particularly odd.
Other examples I saw of this understandably complained about an inferred lifetime in a return value, but having problems with it in input values is very curious.
So apologies if this is "a dupe"
rustc -V
# rustc 1.36.0-nightly (a3404557c 2019-05-03)