-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Consider adding a lint for ambiguous re-exports, since they are unusable #107563
Copy link
Copy link
Closed
Closed
Copy link
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.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.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.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.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Code
Current output
compiles without errors, warnings, or clippy lints
Desired output
Rationale and extra context
It makes sense to defer ambiguous import errors until the ambiguous import is used. However, the same policy currently applies to ambiguous re-exports: they do not error at the time they are created, and instead error only when they are attempted to be used. But an ambiguous re-export is almost certainly unintentional and an error, as it is completely unusable.
Mistakes like in the example code above have excellent odds of being discovered only when they break downstream: there's currently no error, lint, or warning from any tool, and most crates don't write test that use the re-exported names of items so
cargo testprobably won't find the problem either.A bit more discussion (including a playground link) here: https://hachyderm.io/@predrag/109786028398707576
Other cases
No response
Anything else?
I wasn't sure if this should be a rustc lint, a clippy lint, or something else. I decided to start here but I wouldn't mind moving this to the clippy issue tracker if that's the better place for this lint.