-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
trait Foo { | ||
fn err(&self) -> MissingType; | ||
//~^ ERROR cannot find type `MissingType` in this scope | ||
} | ||
|
||
impl Foo for i32 { | ||
fn err(&self) -> MissingType { | ||
//~^ ERROR cannot find type `MissingType` in this scope | ||
0 | ||
} | ||
} | ||
|
||
fn coerce(x: &i32) -> &dyn Foo { | ||
//~^ ERROR `Foo` cannot be made into an object | ||
x | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
error[E0412]: cannot find type `MissingType` in this scope | ||
--> $DIR/erroneous_signature.rs:2:22 | ||
| | ||
LL | fn err(&self) -> MissingType; | ||
| ^^^^^^^^^^^ not found in this scope | ||
|
||
error[E0412]: cannot find type `MissingType` in this scope | ||
--> $DIR/erroneous_signature.rs:7:22 | ||
| | ||
LL | fn err(&self) -> MissingType { | ||
| ^^^^^^^^^^^ not found in this scope | ||
|
||
error[E0038]: the trait `Foo` cannot be made into an object | ||
--> $DIR/erroneous_signature.rs:13:24 | ||
| | ||
LL | fn coerce(x: &i32) -> &dyn Foo { | ||
| ^^^^^^^ `Foo` cannot be made into an object | ||
| | ||
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/erroneous_signature.rs:2:8 | ||
| | ||
LL | trait Foo { | ||
| --- this trait cannot be made into an object... | ||
LL | fn err(&self) -> MissingType; | ||
| ^^^ ...because method `err` has errors in its signature | ||
= help: consider moving `err` to another trait | ||
= help: only type `i32` implements the trait, consider using it directly instead | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0038, E0412. | ||
For more information about an error, try `rustc --explain E0038`. |