For example (playground):
trait Trait {
fn bar<'a, 'b: 'a>(v: &'b &'a str);
}
impl Trait for () {
fn bar<'a, 'b>(_v: &'b &'a str) {}
}
The &'b &'a str
type is WF only if 'b: 'a
, and so the fn body has an implied bound for that, but it still does not satisfy the trait:
error[E0195]: lifetime parameters or bounds on method `bar` do not match the trait declaration
--> src/lib.rs:6:11
|
2 | fn bar<'a, 'b: 'a>(v: &'b &'a str);
| ------------ lifetimes in impl do not match this method in trait
...
6 | fn bar<'a, 'b>(_v: &'b &'a str) {}
| ^^^^^^^^ lifetimes do not match method in trait
If we write it explicitly, it works (playground):
impl Trait for () {
fn bar<'a, 'b>(_v: &'b &'a str)
where
&'b &'a str:,
{
}
}
Is this a bug? Deliberate design decision? Not decided?