blob: 414614d8d0bf0c23a972a19090fa85cb20b72a23 [file] [log] [blame]
Chih-Hung Hsieh2ccedcd2019-12-19 15:10:50 -08001error[E0038]: the trait `Bar` cannot be made into an object
2 --> $DIR/object-safety-mentions-Self.rs:24:5
3 |
Thiébaud Weksteen5bd94c12021-01-06 15:18:42 +01004LL | t
5 | ^ `Bar` cannot be made into an object
6 |
Thiébaud Weksteen5bd94c12021-01-06 15:18:42 +01007note: 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>
8 --> $DIR/object-safety-mentions-Self.rs:11:22
9 |
Matthew Maurer15a65602020-04-24 14:05:21 -070010LL | trait Bar {
11 | --- this trait cannot be made into an object...
Chih-Hung Hsieh2ccedcd2019-12-19 15:10:50 -080012LL | fn bar(&self, x: &Self);
Thiébaud Weksteen5bd94c12021-01-06 15:18:42 +010013 | ^^^^^ ...because method `bar` references the `Self` type in this parameter
Chris Wailesa1538422021-12-02 10:37:12 -080014 = help: consider moving `bar` to another trait
Chris Wailescd1aefd2023-07-13 13:36:21 -070015 = note: required for the cast from `&T` to `&dyn Bar`
Chih-Hung Hsieh2ccedcd2019-12-19 15:10:50 -080016
17error[E0038]: the trait `Baz` cannot be made into an object
18 --> $DIR/object-safety-mentions-Self.rs:30:5
19 |
Thiébaud Weksteen5bd94c12021-01-06 15:18:42 +010020LL | t
21 | ^ `Baz` cannot be made into an object
22 |
Thiébaud Weksteen5bd94c12021-01-06 15:18:42 +010023note: 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>
24 --> $DIR/object-safety-mentions-Self.rs:15:22
25 |
Matthew Maurer15a65602020-04-24 14:05:21 -070026LL | trait Baz {
27 | --- this trait cannot be made into an object...
Chih-Hung Hsieh2ccedcd2019-12-19 15:10:50 -080028LL | fn baz(&self) -> Self;
Thiébaud Weksteen5bd94c12021-01-06 15:18:42 +010029 | ^^^^ ...because method `baz` references the `Self` type in its return type
Chris Wailesa1538422021-12-02 10:37:12 -080030 = help: consider moving `baz` to another trait
Chris Wailescd1aefd2023-07-13 13:36:21 -070031 = note: required for the cast from `&T` to `&dyn Baz`
Chih-Hung Hsieh2ccedcd2019-12-19 15:10:50 -080032
33error: aborting due to 2 previous errors
34
35For more information about this error, try `rustc --explain E0038`.