]> git.proxmox.com Git - rustc.git/blame - src/test/ui/self/arbitrary-self-types-not-object-safe.curr.stderr
New upstream version 1.65.0+dfsg1
[rustc.git] / src / test / ui / self / arbitrary-self-types-not-object-safe.curr.stderr
CommitLineData
e74abb32 1error[E0038]: the trait `Foo` cannot be made into an object
60c5eb7d 2 --> $DIR/arbitrary-self-types-not-object-safe.rs:33:32
e74abb32
XL
3 |
4LL | fn foo(self: &Rc<Self>) -> usize;
29967ef6 5 | --------- help: consider changing method `foo`'s `self` parameter to be `&self`: `&Self`
e74abb32
XL
6...
7LL | let x = Rc::new(5usize) as Rc<dyn Foo>;
29967ef6
XL
8 | ^^^^^^^^^^^ `Foo` cannot be made into an object
9 |
10note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
11 --> $DIR/arbitrary-self-types-not-object-safe.rs:8:18
12 |
13LL | trait Foo {
14 | --- this trait cannot be made into an object...
15LL | fn foo(self: &Rc<Self>) -> usize;
16 | ^^^^^^^^^ ...because method `foo`'s `self` parameter cannot be dispatched on
e74abb32
XL
17
18error[E0038]: the trait `Foo` cannot be made into an object
60c5eb7d 19 --> $DIR/arbitrary-self-types-not-object-safe.rs:33:13
e74abb32
XL
20 |
21LL | fn foo(self: &Rc<Self>) -> usize;
29967ef6 22 | --------- help: consider changing method `foo`'s `self` parameter to be `&self`: `&Self`
e74abb32
XL
23...
24LL | let x = Rc::new(5usize) as Rc<dyn Foo>;
29967ef6
XL
25 | ^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
26 |
27note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
28 --> $DIR/arbitrary-self-types-not-object-safe.rs:8:18
e74abb32 29 |
29967ef6
XL
30LL | trait Foo {
31 | --- this trait cannot be made into an object...
32LL | fn foo(self: &Rc<Self>) -> usize;
33 | ^^^^^^^^^ ...because method `foo`'s `self` parameter cannot be dispatched on
f2b60f7d 34 = note: required for `Rc<usize>` to implement `CoerceUnsized<Rc<dyn Foo>>`
1b1a35ee 35 = note: required by cast to type `Rc<dyn Foo>`
e74abb32
XL
36
37error: aborting due to 2 previous errors
38
39For more information about this error, try `rustc --explain E0038`.