2017-09-18 12:47:33 +02:00
|
|
|
|
|
|
|
|
2017-02-10 19:39:03 +01:00
|
|
|
#![allow(unused)]
|
2017-05-17 14:19:44 +02:00
|
|
|
#![warn(mut_from_ref)]
|
2017-02-10 19:39:03 +01:00
|
|
|
|
|
|
|
struct Foo;
|
|
|
|
|
|
|
|
impl Foo {
|
|
|
|
fn this_wont_hurt_a_bit(&self) -> &mut Foo {
|
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
trait Ouch {
|
|
|
|
fn ouch(x: &Foo) -> &mut Foo;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Ouch for Foo {
|
|
|
|
fn ouch(x: &Foo) -> &mut Foo {
|
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn fail(x: &u32) -> &mut u16 {
|
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
|
2017-02-11 00:32:12 +01:00
|
|
|
fn fail_lifetime<'a>(x: &'a u32, y: &mut u32) -> &'a mut u32 {
|
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
|
2017-02-12 15:10:25 +01:00
|
|
|
fn fail_double<'a, 'b>(x: &'a u32, y: &'a u32, z: &'b mut u32) -> &'a mut u32 {
|
2017-02-12 13:53:30 +01:00
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
|
2017-02-10 19:39:03 +01:00
|
|
|
// this is OK, because the result borrows y
|
|
|
|
fn works<'a>(x: &u32, y: &'a mut u32) -> &'a mut u32 {
|
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
|
|
|
|
// this is also OK, because the result could borrow y
|
|
|
|
fn also_works<'a>(x: &'a u32, y: &'a mut u32) -> &'a mut u32 {
|
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
//TODO
|
|
|
|
}
|