You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rollup merge of rust-lang#104593 - compiler-errors:rpitit-object-safety-spans, r=fee1-dead
Improve spans for RPITIT object-safety errors
No reason why we can't point at the `impl Trait` that causes the object-safety violation.
Also [drive-by: Add is_async fn to hir::IsAsync](rust-lang@c4165f3), which touches clippy too.
warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
2
+
--> $DIR/object-safety.rs:3:12
3
+
|
4
+
LL | #![feature(async_fn_in_trait)]
5
+
| ^^^^^^^^^^^^^^^^^
6
+
|
7
+
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
8
+
= note: `#[warn(incomplete_features)]` on by default
9
+
10
+
error[E0038]: the trait `Foo` cannot be made into an object
11
+
--> $DIR/object-safety.rs:11:12
12
+
|
13
+
LL | let x: &dyn Foo = todo!();
14
+
| ^^^^^^^^ `Foo` cannot be made into an object
15
+
|
16
+
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>
17
+
--> $DIR/object-safety.rs:7:14
18
+
|
19
+
LL | trait Foo {
20
+
| --- this trait cannot be made into an object...
21
+
LL | async fn foo(&self);
22
+
| ^^^ ...because method `foo` is `async`
23
+
= help: consider moving `foo` to another trait
24
+
25
+
error: aborting due to previous error; 1 warning emitted
26
+
27
+
For more information about this error, try `rustc --explain E0038`.
Copy file name to clipboardExpand all lines: src/test/ui/impl-trait/in-trait/object-safety.stderr
+6-6
Original file line number
Diff line number
Diff line change
@@ -5,12 +5,12 @@ LL | let i = Box::new(42_u32) as Box<dyn Foo>;
5
5
| ^^^^^^^^^^^^ `Foo` cannot be made into an object
6
6
|
7
7
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>
8
-
--> $DIR/object-safety.rs:7:8
8
+
--> $DIR/object-safety.rs:7:22
9
9
|
10
10
LL | trait Foo {
11
11
| --- this trait cannot be made into an object...
12
12
LL | fn baz(&self) -> impl Debug;
13
-
| ^^^ ...because method `baz` references an `impl Trait` type in its return type
13
+
| ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type
14
14
= help: consider moving `baz` to another trait
15
15
16
16
error[E0038]: the trait `Foo` cannot be made into an object
@@ -20,12 +20,12 @@ LL | let s = i.baz();
20
20
| ^^^^^^^ `Foo` cannot be made into an object
21
21
|
22
22
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>
23
-
--> $DIR/object-safety.rs:7:8
23
+
--> $DIR/object-safety.rs:7:22
24
24
|
25
25
LL | trait Foo {
26
26
| --- this trait cannot be made into an object...
27
27
LL | fn baz(&self) -> impl Debug;
28
-
| ^^^ ...because method `baz` references an `impl Trait` type in its return type
28
+
| ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type
29
29
= help: consider moving `baz` to another trait
30
30
31
31
error[E0038]: the trait `Foo` cannot be made into an object
@@ -35,12 +35,12 @@ LL | let i = Box::new(42_u32) as Box<dyn Foo>;
35
35
| ^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
36
36
|
37
37
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>
38
-
--> $DIR/object-safety.rs:7:8
38
+
--> $DIR/object-safety.rs:7:22
39
39
|
40
40
LL | trait Foo {
41
41
| --- this trait cannot be made into an object...
42
42
LL | fn baz(&self) -> impl Debug;
43
-
| ^^^ ...because method `baz` references an `impl Trait` type in its return type
43
+
| ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type
44
44
= help: consider moving `baz` to another trait
45
45
= note: required for `Box<u32>` to implement `CoerceUnsized<Box<dyn Foo>>`
0 commit comments