File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed
Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change 1+ //! Method availability rules for trait objects depend on receiver type.
2+
13trait Foo {
24 fn borrowed ( & self ) ;
35 fn borrowed_mut ( & mut self ) ;
4-
56 fn owned ( self : Box < Self > ) ;
67}
78
@@ -20,7 +21,7 @@ fn borrowed_mut_receiver(x: &mut dyn Foo) {
2021fn owned_receiver ( x : Box < dyn Foo > ) {
2122 x. borrowed ( ) ;
2223 x. borrowed_mut ( ) ; // See [1]
23- x. managed ( ) ; //~ ERROR no method named `managed` found
24+ x. managed ( ) ; //~ ERROR no method named `managed` found
2425 x. owned ( ) ;
2526}
2627
Original file line number Diff line number Diff line change 11error[E0599]: no method named `owned` found for reference `&dyn Foo` in the current scope
2- --> $DIR/object-pointer-types .rs:11 :7
2+ --> $DIR/trait- object-method-receiver-rules .rs:12 :7
33 |
44LL | fn owned(self: Box<Self>);
55 | --------- the method might not be found because of this arbitrary self type
@@ -13,7 +13,7 @@ LL | x.to_owned();
1313 | +++
1414
1515error[E0599]: no method named `owned` found for mutable reference `&mut dyn Foo` in the current scope
16- --> $DIR/object-pointer-types .rs:17 :7
16+ --> $DIR/trait- object-method-receiver-rules .rs:18 :7
1717 |
1818LL | fn owned(self: Box<Self>);
1919 | --------- the method might not be found because of this arbitrary self type
@@ -22,7 +22,7 @@ LL | x.owned();
2222 | ^^^^^ method not found in `&mut dyn Foo`
2323
2424error[E0599]: no method named `managed` found for struct `Box<(dyn Foo + 'static)>` in the current scope
25- --> $DIR/object-pointer-types .rs:23 :7
25+ --> $DIR/trait- object-method-receiver-rules .rs:24 :7
2626 |
2727LL | x.managed();
2828 | ^^^^^^^ method not found in `Box<(dyn Foo + 'static)>`
You can’t perform that action at this time.
0 commit comments