-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.