You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error message for duplicate names suggests invalid Rust #45829
Consider the following library (with hello and aleph externs provided):
extern crate hello;
extern crate aleph as hello;
rustc will reasonably identify a problem:
error[E0259]: the name `hello` is defined multiple times
--> lib.rs:2:1
|
1 | extern crate hello;
| ------------------- previous import of the extern crate `hello` here
2 | extern crate aleph as hello;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `hello` reimported here
|
= note: `hello` must be defined only once in the type namespace of this module
but will then go on to suggest a rather unhelpful solution that isn't even valid Rust code:
help: You can use `as` to change the binding name of the import
|
2 | extern crate aleph as hello; as Otherhello
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#45660 should verify wether the crate has already been renamed before providing the help. I believe this can be done by checking wether the NameBinding.kind::<Import> fields target and source are the same.
error[E0252]: the name `A` is defined multiple times
--> src/main.rs:8:14
|
8 | use foo::{A, B as A};
| - ^^^^^^ `A` reimported here
| |
| previous import of the type `A` here
|
= note: `A` must be defined only once in the type namespace of this module
help: You can use `as` to change the binding name of the import
|
8 | use foo::{A, B as A as OtherA};
| ^^^^^^^^^^^^^^^^
Activity
estebank commentedon Nov 7, 2017
Related to #45799.
#45660 should verify wether the crate has already been renamed before providing the help. I believe this can be done by checking wether the
NameBinding.kind::<Import>fieldstargetandsourceare the same.Cldfire commentedon Nov 8, 2017
@Twey, thanks for noticing that and filing an issue 😄
And @estebank, thanks for the instructions. I'll add a commit that fixes this as a part of #45820 when I get the chance.
EDIT: Looks like you've got it handled 👍
Rollup merge of rust-lang#45856 - estebank:issue-45829, r=nikomatsakis
emilyalbini commentedon Sep 17, 2018
This also happens with
uses:estebank commentedon Sep 17, 2018
@pietroalbini thanks for fishing this out! The fix for
usewill likely be very similar to #45856.mockersf commentedon Oct 16, 2018
Hello ! I took a shot at this.
I noticed that rust no longer suggests a new name for an
extern crateimport that has already been renamed.This is because the suggestion is behind this check (https://github.com/rust-lang/rust/blob/master/src/librustc_resolve/lib.rs#L4788):
I didn't change that in #55113 in case it was done willingly, but that should be easy to change.
estebank commentedon Oct 16, 2018
@mockersf commented on the PR. If you can apply the fix to
externstatements as well, go ahead :)Auto merge of #55113 - mockersf:master, r=estebank