Skip to content

Commit 96e69d9

Browse files
committed
useless_attribute: allow hidden_glob_reexports
Closes rust-lang/rust-clippy#11595
1 parent e9761bd commit 96e69d9

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

clippy_lints/src/attrs/useless_attribute.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ pub(super) fn check(cx: &LateContext<'_>, item: &Item<'_>, attrs: &[Attribute])
2626
|| is_word(lint, sym!(unused))
2727
|| is_word(lint, sym!(unused_import_braces))
2828
|| is_word(lint, sym!(unused_braces))
29-
|| is_word(lint, sym!(dead_code))
29+
|| is_word(lint, sym::dead_code)
30+
|| is_word(lint, sym!(hidden_glob_reexports))
3031
|| extract_clippy_lint(lint).map_or(false, |s| {
3132
matches!(
3233
s.as_str(),

tests/ui/useless_attribute.fixed

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,24 @@ fn main() {
9696
// Regression test for https://github.com/rust-lang/rust-clippy/issues/4467
9797
#[allow(dead_code)]
9898
use std::collections as puppy_doggy;
99+
100+
// Regression test for https://github.com/rust-lang/rust-clippy/issues/11595
101+
pub mod hidden_glob_reexports {
102+
#![allow(unreachable_pub)]
103+
104+
mod my_prelude {
105+
pub struct MyCoolTypeInternal;
106+
pub use MyCoolTypeInternal as MyCoolType;
107+
}
108+
109+
mod my_uncool_type {
110+
pub(crate) struct MyUncoolType;
111+
}
112+
113+
// This exports `MyCoolType`.
114+
pub use my_prelude::*;
115+
116+
// This hides `my_prelude::MyCoolType`.
117+
#[allow(hidden_glob_reexports)]
118+
use my_uncool_type::MyUncoolType as MyCoolType;
119+
}

tests/ui/useless_attribute.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,24 @@ fn main() {
9696
// Regression test for https://github.com/rust-lang/rust-clippy/issues/4467
9797
#[allow(dead_code)]
9898
use std::collections as puppy_doggy;
99+
100+
// Regression test for https://github.com/rust-lang/rust-clippy/issues/11595
101+
pub mod hidden_glob_reexports {
102+
#![allow(unreachable_pub)]
103+
104+
mod my_prelude {
105+
pub struct MyCoolTypeInternal;
106+
pub use MyCoolTypeInternal as MyCoolType;
107+
}
108+
109+
mod my_uncool_type {
110+
pub(crate) struct MyUncoolType;
111+
}
112+
113+
// This exports `MyCoolType`.
114+
pub use my_prelude::*;
115+
116+
// This hides `my_prelude::MyCoolType`.
117+
#[allow(hidden_glob_reexports)]
118+
use my_uncool_type::MyUncoolType as MyCoolType;
119+
}

0 commit comments

Comments
 (0)