Skip to content

Commit

Permalink
useless_attribute: allow hidden_glob_reexports
Browse files Browse the repository at this point in the history
  • Loading branch information
9999years committed May 2, 2024
1 parent e9761bd commit 96e69d9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clippy_lints/src/attrs/useless_attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ pub(super) fn check(cx: &LateContext<'_>, item: &Item<'_>, attrs: &[Attribute])
|| is_word(lint, sym!(unused))
|| is_word(lint, sym!(unused_import_braces))
|| is_word(lint, sym!(unused_braces))
|| is_word(lint, sym!(dead_code))
|| is_word(lint, sym::dead_code)
|| is_word(lint, sym!(hidden_glob_reexports))
|| extract_clippy_lint(lint).map_or(false, |s| {
matches!(
s.as_str(),
Expand Down
21 changes: 21 additions & 0 deletions tests/ui/useless_attribute.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,24 @@ fn main() {
// Regression test for https://github.com/rust-lang/rust-clippy/issues/4467
#[allow(dead_code)]
use std::collections as puppy_doggy;

// Regression test for https://github.com/rust-lang/rust-clippy/issues/11595
pub mod hidden_glob_reexports {
#![allow(unreachable_pub)]

mod my_prelude {
pub struct MyCoolTypeInternal;
pub use MyCoolTypeInternal as MyCoolType;
}

mod my_uncool_type {
pub(crate) struct MyUncoolType;
}

// This exports `MyCoolType`.
pub use my_prelude::*;

// This hides `my_prelude::MyCoolType`.
#[allow(hidden_glob_reexports)]
use my_uncool_type::MyUncoolType as MyCoolType;
}
21 changes: 21 additions & 0 deletions tests/ui/useless_attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,24 @@ fn main() {
// Regression test for https://github.com/rust-lang/rust-clippy/issues/4467
#[allow(dead_code)]
use std::collections as puppy_doggy;

// Regression test for https://github.com/rust-lang/rust-clippy/issues/11595
pub mod hidden_glob_reexports {
#![allow(unreachable_pub)]

mod my_prelude {
pub struct MyCoolTypeInternal;
pub use MyCoolTypeInternal as MyCoolType;
}

mod my_uncool_type {
pub(crate) struct MyUncoolType;
}

// This exports `MyCoolType`.
pub use my_prelude::*;

// This hides `my_prelude::MyCoolType`.
#[allow(hidden_glob_reexports)]
use my_uncool_type::MyUncoolType as MyCoolType;
}

0 comments on commit 96e69d9

Please sign in to comment.