Open
Description
Code
use std::rc::Rc;
pub struct Foo;
pub type Function = Rc<Foo>;
impl Function {
}
Current output
error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined
--> src/lib.rs:6:1
|
6 | impl Function {
| ^^^^^^^^^^^^^ impl for type defined outside of crate
|
= note: define and implement a trait or new type instead
Desired output
error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined
--> src/lib.rs:6:1
|
6 | impl Function {
| ^^^^^^^^^^^^^ impl for type defined outside of crate
|
= note: define and implement a trait or new type instead (`pub struct Function(Rc<Foo>);`)
= note: `type` does not define a new type, only a type alias
= note: `Function` is actually `Rc<Foo>`, a type not defined in the current crate
Rationale and extra context
To a beginner, it looks as if Function
was a new type, so the error message should be a bit more explanatory why it is not.
Other cases
Rust Version
1.89.0-nightly
(2025-05-27 45f256d9d7cffb66185c)
Anything else?
@rustbot label D-terse