2013-08-11 13:58:48 -04:00
|
|
|
trait Foo {
|
|
|
|
fn borrowed(&self);
|
|
|
|
fn borrowed_mut(&mut self);
|
|
|
|
|
2014-07-07 23:19:35 -07:00
|
|
|
fn owned(self: Box<Self>);
|
2013-08-11 13:58:48 -04:00
|
|
|
}
|
|
|
|
|
2019-05-28 14:46:13 -04:00
|
|
|
fn borrowed_receiver(x: &dyn Foo) {
|
2013-08-11 13:58:48 -04:00
|
|
|
x.borrowed();
|
|
|
|
x.borrowed_mut(); // See [1]
|
2015-05-02 23:30:59 -06:00
|
|
|
x.owned(); //~ ERROR no method named `owned` found
|
2013-08-11 13:58:48 -04:00
|
|
|
}
|
|
|
|
|
2019-05-28 14:46:13 -04:00
|
|
|
fn borrowed_mut_receiver(x: &mut dyn Foo) {
|
2013-08-11 13:58:48 -04:00
|
|
|
x.borrowed();
|
|
|
|
x.borrowed_mut();
|
2015-05-02 23:30:59 -06:00
|
|
|
x.owned(); //~ ERROR no method named `owned` found
|
2013-08-11 13:58:48 -04:00
|
|
|
}
|
|
|
|
|
2019-05-28 14:46:13 -04:00
|
|
|
fn owned_receiver(x: Box<dyn Foo>) {
|
2013-08-11 13:58:48 -04:00
|
|
|
x.borrowed();
|
|
|
|
x.borrowed_mut(); // See [1]
|
2015-05-02 23:30:59 -06:00
|
|
|
x.managed(); //~ ERROR no method named `managed` found
|
2013-08-11 13:58:48 -04:00
|
|
|
x.owned();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|
|
|
|
|
|
|
|
// [1]: These cases are illegal, but the error is not detected
|
|
|
|
// until borrowck, so see the test borrowck-object-mutability.rs
|