-
-
Notifications
You must be signed in to change notification settings - Fork 17.7k
rustc suggests to use path::_; with as _ trait re-exports #86035
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-doctestsArea: Documentation tests, run by rustdocArea: Documentation tests, run by rustdocA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.Category: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.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
Activity
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-doctestsArea: Documentation tests, run by rustdocArea: Documentation tests, run by rustdocA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.Category: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.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.
Given the following code (playground):
The current output for compiling the doctest is:
I'm not sure what the output should be. Originally I hit this issue with
tracing, which re-exports one trait (soon multiple)as _in its prelude module. They are of course reachable in another path, so that one could be prefered¹, but I realized that this issue could also crop up with a situation such as what I've constructed above, where the trait is actually unnamable. In that case, either the compiler has to suggest as*import, or it has to not emit the help item at all.¹ probably needs an annotation like
#[doc(canonical)](rust-lang/rfcs#3011)