-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Resolve: refactor away the field Module::external_module_children #31317
Resolve: refactor away the field Module::external_module_children #31317
Conversation
span, | ||
E0260, | ||
"the name `{}` conflicts with an external crate \ | ||
that has been imported into this module", |
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.
Hm, if a non-crate is defined first and a crate is defined second, the error message will be incorrect.
I think both theelse
cases above would be better moved from here and handled by resolve_struct_error
and ResolutionError::DuplicateDefinition
.
The error messages will have to be tweaked though, something along the lines:
"definition of {kind} {name} conflicts with existing definition of {kind} {name}" where {kind}
is a precise item kind (including "external crate") and not just "type or module"/"value".
multispans can be used to report spans of the both conflicting items at the same time.
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.
Agreed, I'm planning on cleaning up the duplicate errors in a separate PR so that it can be reviewed and discussed independently of this refactoring (unless you would like do that instead).
Thanks for the pointer to multispans -- this looks like a good use case for them.
reviewed, lgtm |
@@ -8,7 +8,8 @@ | |||
// option. This file may not be copied, modified, or distributed | |||
// except according to those terms. | |||
|
|||
fn std() {} //~ ERROR the name `std` conflicts with an external crate | |||
fn std() {} |
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.
Why does fn std
no longer conflict? Seems like it should to me.
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.
fn std
no longer conflicts since it defines std
in the value namespace but the extern crate defines std
in the type namespace.
Right now, fn std
not does conflict with mod std { ... }
for the same reason and I see no reason to treat extern crate std
differently.
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.
Ok, seems fine, thanks for the explanation
@bors: r+ |
📌 Commit e768fa7 has been approved by |
⌛ Testing commit e768fa7 with merge 28bed3f... |
This PR refactors away `Module`'s `external_module_children` and instead puts `extern crate` declarations in `children` like other items, simplifying duplicate checking and name resolution. This PR also allows values to share a name with extern crates, which are only defined in the type namespace. Other than that, it is a pure refactoring. r? @nrc
This PR refactors away
Module
'sexternal_module_children
and instead putsextern crate
declarations inchildren
like other items, simplifying duplicate checking and name resolution.This PR also allows values to share a name with extern crates, which are only defined in the type namespace. Other than that, it is a pure refactoring.
r? @nrc