-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Add note when inherent impl for a alias type defined outside of the crate #142415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined | ||
--> $DIR/insufficient-suggestion-issue-141679.rs:6:1 | ||
| | ||
LL | impl Function {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to point out the span of the type alias, and explain that the orphan checking rules apply to that type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion!
…rate Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined | ||
--> $DIR/insufficient-suggestion-issue-141679.rs:6:1 | ||
| | ||
LL | impl Function {} | ||
| ^^^^^^^^^^^^^ impl for type defined outside of crate | ||
| | ||
= note: define and implement a trait or new type instead, for more details about orphan rules, see <https://doc.rust-lang.org/reference/items/implementations.html?highlight=orphan#orphan-rules> | ||
note: `Function` does not define a new type, just alias of `Rc<Foo>` defined here | ||
--> $DIR/insufficient-suggestion-issue-141679.rs:4:1 | ||
| | ||
LL | pub type Function = Rc<Foo>; | ||
| ^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It give a link to rust reference for explaining the orphan rules. and present the span where the alias is defined.
r? compiler |
Fixes #141679
r? compiler