Closed
Description
Given the following code (playground):
impl dyn Unpin {}
The current output is:
error[E0118]: no nominal type found for inherent implementation
--> src/lib.rs:1:6
|
1 | impl dyn Unpin {}
| ^^^^^^^^^ impl requires a nominal type
|
= note: either implement a trait on it or create a newtype to wrap it instead
This is rather confusing. It's not immediately clear what the difference between impl dyn Unpin
and this working code is (playground):
trait A {}
impl dyn A {}
Since impl dyn A
is accepted, the user might be confused why dyn A
would be considered a nominal type when dyn Unpin
isn't. The real reason why impl dyn Unpin
is an error is because it is an impl
block for a type [edit: a dynamically dispatched auto trait] from another crate, which should be handled by E0116
.
Ideally the output should look like:
error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined
--> src/lib.rs:1:1
|
1 | impl dyn Unpin {}
| ^^^^^^^^^^^^^^^^^ impl for type defined outside of crate.
|
= note: define and implement a trait or new type instead