Skip to content

Commit bf2a126

Browse files
committed
More tests
1 parent f75bcf3 commit bf2a126

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
trait Foo {
2+
fn err(&self) -> MissingType;
3+
//~^ ERROR cannot find type `MissingType` in this scope
4+
}
5+
6+
impl Foo for i32 {
7+
fn err(&self) -> MissingType {
8+
//~^ ERROR cannot find type `MissingType` in this scope
9+
0
10+
}
11+
}
12+
13+
fn coerce(x: &i32) -> &dyn Foo {
14+
//~^ ERROR `Foo` cannot be made into an object
15+
x
16+
}
17+
18+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
error[E0412]: cannot find type `MissingType` in this scope
2+
--> $DIR/erroneous_signature.rs:2:22
3+
|
4+
LL | fn err(&self) -> MissingType;
5+
| ^^^^^^^^^^^ not found in this scope
6+
7+
error[E0412]: cannot find type `MissingType` in this scope
8+
--> $DIR/erroneous_signature.rs:7:22
9+
|
10+
LL | fn err(&self) -> MissingType {
11+
| ^^^^^^^^^^^ not found in this scope
12+
13+
error[E0038]: the trait `Foo` cannot be made into an object
14+
--> $DIR/erroneous_signature.rs:13:24
15+
|
16+
LL | fn coerce(x: &i32) -> &dyn Foo {
17+
| ^^^^^^^ `Foo` cannot be made into an object
18+
|
19+
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>
20+
--> $DIR/erroneous_signature.rs:2:8
21+
|
22+
LL | trait Foo {
23+
| --- this trait cannot be made into an object...
24+
LL | fn err(&self) -> MissingType;
25+
| ^^^ ...because method `err` has errors in its signature
26+
= help: consider moving `err` to another trait
27+
= help: only type `i32` implements the trait, consider using it directly instead
28+
29+
error: aborting due to 3 previous errors
30+
31+
Some errors have detailed explanations: E0038, E0412.
32+
For more information about an error, try `rustc --explain E0038`.

0 commit comments

Comments
 (0)