2017-08-10 15:52:05 -05:00
|
|
|
trait Id {
|
|
|
|
type Out;
|
|
|
|
|
|
|
|
fn id(self) -> Self::Out;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Id for &'a mut i32 {
|
|
|
|
type Out = &'a mut i32;
|
|
|
|
|
|
|
|
fn id(self) -> Self { self }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Id for &'a mut u32 {
|
|
|
|
type Out = &'a mut u32;
|
|
|
|
|
|
|
|
fn id(self) -> Self { self }
|
|
|
|
}
|
|
|
|
|
|
|
|
fn foo<T>(mut x: T) where for<'a> &'a mut T: Id
|
|
|
|
{
|
|
|
|
let x = &mut x;
|
|
|
|
let _y = x.id();
|
2019-02-15 19:43:56 -06:00
|
|
|
// Inspecting the trace should show that `_y` has a type involving a local lifetime, when it gets validated.
|
2017-08-10 15:52:05 -05:00
|
|
|
// Unfortunately, there doesn't seem to be a way to actually have a test fail if it does not have the right
|
2019-02-15 19:43:56 -06:00
|
|
|
// type. Currently, this is *not* working correctly; see <https://github.com/rust-lang/miri/issues/298>.
|
2017-08-10 15:52:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
foo(3)
|
|
|
|
}
|