Rollup merge of #88892 - estebank:trait-objects, r=petrochenkov
Move object safety suggestions to the end of the error
This commit is contained in:
commit
14eb87dd26
28 changed files with 50 additions and 46 deletions
|
|
@ -4,7 +4,6 @@ error[E0038]: the trait `Bar` cannot be made into an object
|
|||
LL | fn foo(b: &dyn Bar) {
|
||||
| ^^^^^^^ `Bar` cannot be made into an object
|
||||
|
|
||||
= help: consider moving `foo` to another trait
|
||||
note: 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>
|
||||
--> $DIR/issue-18959.rs:1:20
|
||||
|
|
||||
|
|
@ -12,6 +11,7 @@ LL | pub trait Foo { fn foo<T>(&self, ext_thing: &T); }
|
|||
| ^^^ ...because method `foo` has generic type parameters
|
||||
LL | pub trait Bar: Foo { }
|
||||
| --- this trait cannot be made into an object...
|
||||
= help: consider moving `foo` to another trait
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ error[E0038]: the trait `Bar` cannot be made into an object
|
|||
LL | let test: &mut dyn Bar = &mut thing;
|
||||
| ^^^^^^^^^^^^ `Bar` cannot be made into an object
|
||||
|
|
||||
= help: consider moving `foo` to another trait
|
||||
note: 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>
|
||||
--> $DIR/issue-19538.rs:2:8
|
||||
|
|
||||
|
|
@ -13,6 +12,7 @@ LL | fn foo<T>(&self, val: T);
|
|||
...
|
||||
LL | trait Bar: Foo { }
|
||||
| --- this trait cannot be made into an object...
|
||||
= help: consider moving `foo` to another trait
|
||||
|
||||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/issue-19538.rs:17:30
|
||||
|
|
@ -20,7 +20,6 @@ error[E0038]: the trait `Bar` cannot be made into an object
|
|||
LL | let test: &mut dyn Bar = &mut thing;
|
||||
| ^^^^^^^^^^ `Bar` cannot be made into an object
|
||||
|
|
||||
= help: consider moving `foo` to another trait
|
||||
note: 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>
|
||||
--> $DIR/issue-19538.rs:2:8
|
||||
|
|
||||
|
|
@ -29,6 +28,7 @@ LL | fn foo<T>(&self, val: T);
|
|||
...
|
||||
LL | trait Bar: Foo { }
|
||||
| --- this trait cannot be made into an object...
|
||||
= help: consider moving `foo` to another trait
|
||||
= note: required because of the requirements on the impl of `CoerceUnsized<&mut dyn Bar>` for `&mut Thing`
|
||||
= note: required by cast to type `&mut dyn Bar`
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue