File tree Expand file tree Collapse file tree 2 files changed +18
-18
lines changed Expand file tree Collapse file tree 2 files changed +18
-18
lines changed Original file line number Diff line number Diff line change 12
12
use std:: rc:: Rc ;
13
13
14
14
trait Foo {
15
- fn foo ( self : Rc < Self > ) -> usize ;
15
+ fn foo ( self : & Rc < Self > ) -> usize ;
16
16
}
17
17
18
18
trait Bar {
19
- fn foo ( self : Rc < Self > ) -> usize where Self : Sized ;
20
- fn bar ( self : Box < Self > ) -> usize ;
19
+ fn foo ( self : & Rc < Self > ) -> usize where Self : Sized ;
20
+ fn bar ( self : Rc < Self > ) -> usize ;
21
21
}
22
22
23
23
impl Foo for usize {
24
- fn foo ( self : Rc < Self > ) -> usize {
25
- * self
24
+ fn foo ( self : & Rc < Self > ) -> usize {
25
+ * * self
26
26
}
27
27
}
28
28
29
29
impl Bar for usize {
30
- fn foo ( self : Rc < Self > ) -> usize {
31
- * self
30
+ fn foo ( self : & Rc < Self > ) -> usize {
31
+ * * self
32
32
}
33
33
34
- fn bar ( self : Box < Self > ) -> usize {
34
+ fn bar ( self : Rc < Self > ) -> usize {
35
35
* self
36
36
}
37
37
}
38
38
39
39
fn make_foo ( ) {
40
- let x = Box :: new ( 5usize ) as Box < Foo > ;
40
+ let x = Rc :: new ( 5usize ) as Rc < Foo > ;
41
41
//~^ ERROR E0038
42
42
//~| ERROR E0038
43
43
}
44
44
45
45
fn make_bar ( ) {
46
- let x = Box :: new ( 5usize ) as Box < Bar > ;
46
+ let x = Rc :: new ( 5usize ) as Rc < Bar > ;
47
47
x. bar ( ) ;
48
48
}
49
49
Original file line number Diff line number Diff line change 1
1
error[E0038]: the trait `Foo` cannot be made into an object
2
- --> $DIR/arbitrary-self-types-not-object-safe.rs:40:33
2
+ --> $DIR/arbitrary-self-types-not-object-safe.rs:40:32
3
3
|
4
- LL | let x = Box ::new(5usize) as Box <Foo>;
5
- | ^ ^^^^^^^ the trait `Foo` cannot be made into an object
4
+ LL | let x = Rc ::new(5usize) as Rc <Foo>;
5
+ | ^^^^^^^ the trait `Foo` cannot be made into an object
6
6
|
7
- = note: method `foo` has a non-standard `self` type
7
+ = note: method `foo` has an uncoercible receiver type
8
8
9
9
error[E0038]: the trait `Foo` cannot be made into an object
10
10
--> $DIR/arbitrary-self-types-not-object-safe.rs:40:13
11
11
|
12
- LL | let x = Box ::new(5usize) as Box <Foo>;
13
- | ^^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object
12
+ LL | let x = Rc ::new(5usize) as Rc <Foo>;
13
+ | ^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object
14
14
|
15
- = note: method `foo` has a non-standard `self` type
16
- = note: required because of the requirements on the impl of `std::ops::CoerceUnsized<std::boxed::Box <dyn Foo>>` for `std::boxed::Box <usize>`
15
+ = note: method `foo` has an uncoercible receiver type
16
+ = note: required because of the requirements on the impl of `std::ops::CoerceUnsized<std::rc::Rc <dyn Foo>>` for `std::rc::Rc <usize>`
17
17
18
18
error: aborting due to 2 previous errors
19
19
You can’t perform that action at this time.
0 commit comments