error: `impl` item signature doesn't match `trait` item signature
--> src/lib.rs:9:5
|
9 | fn as_ref(&self) -> &dyn SomeTrait {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&Outer) -> &dyn SomeTrait`
|
= note: expected `fn(&Outer) -> &(dyn SomeTrait + 'static)`
found `fn(&Outer) -> &dyn SomeTrait`
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
In addition to the above -- Recall that owned values always satisfy 'static because it's impossible to observe them outside their scope. Therefore, (dyn SomeTrait + 'static) is a completely valid description of Outer.inner, and by extension, &'a (dyn SomeTrait + 'static) is a completely valid description of (&'a self).inner.