Does implementing Deref affect the lifetime bounds of all other methods?


#1

Code: 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. Is there documentation somewhere about why this is or how this works? Thanks


#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()
    }
}

#3

Seems like a bug

Considering that, I opened an issue: