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
+
1
3
trait Foo {
2
4
fn borrowed ( & self ) ;
3
5
fn borrowed_mut ( & mut self ) ;
4
-
5
6
fn owned ( self : Box < Self > ) ;
6
7
}
7
8
@@ -20,7 +21,7 @@ fn borrowed_mut_receiver(x: &mut dyn Foo) {
20
21
fn owned_receiver ( x : Box < dyn Foo > ) {
21
22
x. borrowed ( ) ;
22
23
x. borrowed_mut ( ) ; // See [1]
23
- x. managed ( ) ; //~ ERROR no method named `managed` found
24
+ x. managed ( ) ; //~ ERROR no method named `managed` found
24
25
x. owned ( ) ;
25
26
}
26
27
Original file line number Diff line number Diff line change 1
1
error[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
3
3
|
4
4
LL | fn owned(self: Box<Self>);
5
5
| --------- the method might not be found because of this arbitrary self type
@@ -13,7 +13,7 @@ LL | x.to_owned();
13
13
| +++
14
14
15
15
error[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
17
17
|
18
18
LL | fn owned(self: Box<Self>);
19
19
| --------- the method might not be found because of this arbitrary self type
@@ -22,7 +22,7 @@ LL | x.owned();
22
22
| ^^^^^ method not found in `&mut dyn Foo`
23
23
24
24
error[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
26
26
|
27
27
LL | x.managed();
28
28
| ^^^^^^^ method not found in `Box<(dyn Foo + 'static)>`
You can’t perform that action at this time.
0 commit comments