Add warn-by-default lint for local binding shadowing exported glob re-export item
This commit is contained in:
parent
1a5f8bce74
commit
b9606589c4
12 changed files with 207 additions and 27 deletions
|
@ -3272,6 +3272,43 @@ declare_lint! {
|
|||
"ambiguous glob re-exports",
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
/// The `hidden_glob_reexports` lint detects cases where glob re-export items are shadowed by
|
||||
/// private items.
|
||||
///
|
||||
/// ### Example
|
||||
///
|
||||
/// ```rust,compile_fail
|
||||
/// #![deny(hidden_glob_reexports)]
|
||||
///
|
||||
/// pub mod upstream {
|
||||
/// mod inner { pub struct Foo {}; pub struct Bar {}; }
|
||||
/// pub use self::inner::*;
|
||||
/// struct Foo {} // private item shadows `inner::Foo`
|
||||
/// }
|
||||
///
|
||||
/// // mod downstream {
|
||||
/// // fn test() {
|
||||
/// // let _ = crate::upstream::Foo; // inaccessible
|
||||
/// // }
|
||||
/// // }
|
||||
///
|
||||
/// pub fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// {{produces}}
|
||||
///
|
||||
/// ### Explanation
|
||||
///
|
||||
/// This was previously accepted without any errors or warnings but it could silently break a
|
||||
/// crate's downstream user code. If the `struct Foo` was added, `dep::inner::Foo` would
|
||||
/// silently become inaccessible and trigger a "`struct `Foo` is private`" visibility error at
|
||||
/// the downstream use site.
|
||||
pub HIDDEN_GLOB_REEXPORTS,
|
||||
Warn,
|
||||
"name introduced by a private item shadows a name introduced by a public glob re-export",
|
||||
}
|
||||
|
||||
declare_lint_pass! {
|
||||
/// Does nothing as a lint pass, but registers some `Lint`s
|
||||
/// that are used by other parts of the compiler.
|
||||
|
@ -3304,6 +3341,7 @@ declare_lint_pass! {
|
|||
FORBIDDEN_LINT_GROUPS,
|
||||
FUNCTION_ITEM_REFERENCES,
|
||||
FUZZY_PROVENANCE_CASTS,
|
||||
HIDDEN_GLOB_REEXPORTS,
|
||||
ILL_FORMED_ATTRIBUTE_INPUT,
|
||||
ILLEGAL_FLOATING_POINT_LITERAL_PATTERN,
|
||||
IMPLIED_BOUNDS_ENTAILMENT,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue