Wording changes to object unsafe trait errors
Stemming from the thread at https://twitter.com/indygreg/status/1223279056398929920
This commit is contained in:
parent
3ca1c5d5b5
commit
413bfa4b98
51 changed files with 332 additions and 91 deletions
|
|
@ -7,11 +7,15 @@ LL | let trait_obj: &dyn SomeTrait = SomeTrait;
|
|||
error[E0038]: the trait `SomeTrait` cannot be made into an object
|
||||
--> $DIR/E0033-teach.rs:8:20
|
||||
|
|
||||
LL | trait SomeTrait {
|
||||
| --------- this trait cannot be made into an object...
|
||||
LL | fn foo();
|
||||
| --- associated function `foo` has no `self` parameter
|
||||
| --- ...because associated function `foo` has no `self` parameter
|
||||
...
|
||||
LL | let trait_obj: &dyn SomeTrait = SomeTrait;
|
||||
| ^^^^^^^^^^^^^^ the trait `SomeTrait` cannot be made into an object
|
||||
|
|
||||
= help: consider turning `foo` into a method by giving it a `&self` argument or constraining it with `where Self: Sized`
|
||||
|
||||
error[E0033]: type `&dyn SomeTrait` cannot be dereferenced
|
||||
--> $DIR/E0033-teach.rs:12:9
|
||||
|
|
|
|||
|
|
@ -7,11 +7,15 @@ LL | let trait_obj: &dyn SomeTrait = SomeTrait;
|
|||
error[E0038]: the trait `SomeTrait` cannot be made into an object
|
||||
--> $DIR/E0033.rs:6:20
|
||||
|
|
||||
LL | trait SomeTrait {
|
||||
| --------- this trait cannot be made into an object...
|
||||
LL | fn foo();
|
||||
| --- associated function `foo` has no `self` parameter
|
||||
| --- ...because associated function `foo` has no `self` parameter
|
||||
...
|
||||
LL | let trait_obj: &dyn SomeTrait = SomeTrait;
|
||||
| ^^^^^^^^^^^^^^ the trait `SomeTrait` cannot be made into an object
|
||||
|
|
||||
= help: consider turning `foo` into a method by giving it a `&self` argument or constraining it with `where Self: Sized`
|
||||
|
||||
error[E0033]: type `&dyn SomeTrait` cannot be dereferenced
|
||||
--> $DIR/E0033.rs:10:9
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
error[E0038]: the trait `Trait` cannot be made into an object
|
||||
--> $DIR/E0038.rs:5:16
|
||||
|
|
||||
LL | trait Trait {
|
||||
| ----- this trait cannot be made into an object...
|
||||
LL | fn foo(&self) -> Self;
|
||||
| --- method `foo` references the `Self` type in its parameters or return type
|
||||
| --- ...because method `foo` references the `Self` type in its parameters or return type
|
||||
...
|
||||
LL | fn call_foo(x: Box<dyn Trait>) {
|
||||
| ^^^^^^^^^^^^^^ the trait `Trait` cannot be made into an object
|
||||
|
|
||||
= help: consider moving `foo` to another trait
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue