Consider adding a lint for ambiguous re-exports, since they are unusable #107563
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-lints
Area: Lints (warnings about flaws in source code) such as unused_mut.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
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 test
probably 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.
The text was updated successfully, but these errors were encountered: