-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Suggest renaming a trait import if the names clash #32354
Comments
Seems like a nice idea. I'm taking this issue. |
Two thoughts: 1) This is not specific to traits, any import (or non-import) can be renamed in case of conflict 2) resolve already has too many overly specific errors and messages, which seemed like a nice idea and easy PR material, with no evidence of their actual helpfulness. |
@GuillaumeGomez Checking in; I think no progress has been made. Do you think you'll have a chance to work on this soon? |
No I won't. Feel free to take it. |
Mentoring instructions:The duplicated import struct is created in
|
I might take a look at this issue and see what I can do. Let me know if there are any conflicts --Colin |
@colinmarsh19 go ahead! Feel free to reach out for help here, gitter, or IRC. |
…tebank Suggest renaming import if names clash Closes rust-lang#32354. The output for the example in the issue looks like this: ``` ~/p/local-rust-dev-testing ❯❯❯ cargo +local-s1 build Compiling local-rust-dev-testing v0.1.0 (file:///home/cldfire/programming_projects/local-rust-dev-testing) error[E0252]: the name `ConstructorExtension` is defined multiple times --> src/main.rs:49:5 | 48 | use extension1::ConstructorExtension; | -------------------------------- previous import of the trait `ConstructorExtension` here 49 | use extension2::ConstructorExtension; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ConstructorExtension` reimported here | = note: `ConstructorExtension` 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 | 49 | use extension2::ConstructorExtension as OtherConstructorExtension; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... ``` This is my first PR that touches the compiler in any way, so if there's something else I need to do here (e.g. add a test), please let me know :).
You can bring in multiple traits of the same name if you rename them.
Example use case (playground code)
current error:
Suggested note: "You can rename an imported name with
as
".The text was updated successfully, but these errors were encountered: