Code: Rust Playground
If the Deref
is removed, the code compiles. Presumably, the inclusion of the Deref
implementation on the trait object causes the lifetime bounds to change on the do_something
method. Is there documentation somewhere about why this is or how this works? Thanks
bluss
August 12, 2015, 2:56pm
2
Seems like a bug. Your deref impl is only for MyTrait + 'static
, but the implicitness of this makes it a bit hard to spot.
I think the Deref should be ignored, since it's not implemented for &MyTrait
(?)
A more general impl will work fine:
impl<'a> Deref for MyTrait + 'a {
type Target = str;
fn deref(&self) -> &Self::Target {
self.as_str()
}
}
Seems like a bug
Considering that, I opened an issue:
opened 04:55PM - 12 Aug 15 UTC
closed 05:07AM - 22 Jun 19 UTC
A-typesystem
A-lifetimes
E-needs-test
T-compiler
C-bug
From https://users.rust-lang.org/t/does-implementing-deref-affect-the-lifetime-b… ounds-of-all-other-methods/
---
Code: ~~http://is.gd/AkyE699~~ http://is.gd/AkyE69
If the Deref is removed, the code compiles. Presumably, the inclusion of the Deref implementation on the trait object causes the lifetime bounds to change on the do_something method.