fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1// run-rustfix 2#![allow(dead_code)] 3 4struct Events<R>(R); 5 6struct Other; 7 8pub trait Trait<T> { 9 fn handle(value: T) -> Self; 10} 11 12// Blanket impl. (If you comment this out, compiler figures out that it 13// is passing an `&mut` to a method that must be expecting an `&mut`, 14// and injects an auto-reborrow.) 15impl<T, U> Trait<U> for T where T: From<U> { 16 fn handle(_: U) -> Self { unimplemented!() } 17} 18 19impl<'a, R> Trait<&'a mut Events<R>> for Other { 20 fn handle(_: &'a mut Events<R>) -> Self { unimplemented!() } 21} 22 23fn this_compiles<'a, R>(value: &'a mut Events<R>) { 24 for _ in 0..3 { 25 Other::handle(&mut *value); 26 } 27} 28 29fn this_does_not<'a, R>(value: &'a mut Events<R>) { 30 for _ in 0..3 { 31 Other::handle(&mut *value); //~ ERROR use of moved value: `value` 32 } 33} 34 35fn main() {}