Skip to content

Commit

Permalink
Rename anon_trait_imports -> unused_trait_names
Browse files Browse the repository at this point in the history
  • Loading branch information
RuairidhWilliamson committed Sep 19, 2024
1 parent e11fa3d commit dfc5a52
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5295,7 +5295,6 @@ Released 2018-09-13
[`almost_complete_letter_range`]: https://rust-lang.github.io/rust-clippy/master/index.html#almost_complete_letter_range
[`almost_complete_range`]: https://rust-lang.github.io/rust-clippy/master/index.html#almost_complete_range
[`almost_swapped`]: https://rust-lang.github.io/rust-clippy/master/index.html#almost_swapped
[`anon_trait_imports`]: https://rust-lang.github.io/rust-clippy/master/index.html#anon_trait_imports
[`approx_constant`]: https://rust-lang.github.io/rust-clippy/master/index.html#approx_constant
[`arc_with_non_send_sync`]: https://rust-lang.github.io/rust-clippy/master/index.html#arc_with_non_send_sync
[`arithmetic_side_effects`]: https://rust-lang.github.io/rust-clippy/master/index.html#arithmetic_side_effects
Expand Down Expand Up @@ -6063,6 +6062,7 @@ Released 2018-09-13
[`unused_result_ok`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_result_ok
[`unused_rounding`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_rounding
[`unused_self`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_self
[`unused_trait_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_trait_names
[`unused_unit`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_unit
[`unusual_byte_groupings`]: https://rust-lang.github.io/rust-clippy/master/index.html#unusual_byte_groupings
[`unwrap_in_result`]: https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_in_result
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/attrs/useless_attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub(super) fn check(cx: &LateContext<'_>, item: &Item<'_>, attrs: &[Attribute])
| "module_name_repetitions"
| "single_component_path_imports"
| "disallowed_types"
| "anon_trait_imports"
| "unused_trait_names"
)
}) {
return;
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/declared_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ pub static LINTS: &[&crate::LintInfo] = &[
crate::utils::internal_lints::unsorted_clippy_utils_paths::UNSORTED_CLIPPY_UTILS_PATHS_INFO,
crate::absolute_paths::ABSOLUTE_PATHS_INFO,
crate::almost_complete_range::ALMOST_COMPLETE_RANGE_INFO,
crate::anon_trait_imports::ANON_TRAIT_IMPORTS_INFO,
crate::approx_const::APPROX_CONSTANT_INFO,
crate::arc_with_non_send_sync::ARC_WITH_NON_SEND_SYNC_INFO,
crate::as_conversions::AS_CONVERSIONS_INFO,
Expand Down Expand Up @@ -748,6 +747,7 @@ pub static LINTS: &[&crate::LintInfo] = &[
crate::unused_result_ok::UNUSED_RESULT_OK_INFO,
crate::unused_rounding::UNUSED_ROUNDING_INFO,
crate::unused_self::UNUSED_SELF_INFO,
crate::unused_trait_names::UNUSED_TRAIT_NAMES_INFO,
crate::unused_unit::UNUSED_UNIT_INFO,
crate::unwrap::PANICKING_UNWRAP_INFO,
crate::unwrap::UNNECESSARY_UNWRAP_INFO,
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ pub mod deprecated_lints;
// begin lints modules, do not remove this comment, it’s used in `update_lints`
mod absolute_paths;
mod almost_complete_range;
mod anon_trait_imports;
mod approx_const;
mod arc_with_non_send_sync;
mod as_conversions;
Expand Down Expand Up @@ -377,6 +376,7 @@ mod unused_peekable;
mod unused_result_ok;
mod unused_rounding;
mod unused_self;
mod unused_trait_names;
mod unused_unit;
mod unwrap;
mod unwrap_in_result;
Expand Down Expand Up @@ -943,6 +943,6 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
store.register_late_pass(move |_| Box::new(manual_div_ceil::ManualDivCeil::new(conf)));
store.register_late_pass(|_| Box::new(manual_is_power_of_two::ManualIsPowerOfTwo));
store.register_late_pass(|_| Box::new(non_zero_suggestions::NonZeroSuggestions));
store.register_late_pass(move |_| Box::new(anon_trait_imports::AnonTraitImports::new(conf)));
store.register_late_pass(move |_| Box::new(unused_trait_names::UnusedTraitNames::new(conf)));
// add lints here, do not remove this comment, it's used in `new_lint`
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,26 @@ declare_clippy_lint! {
/// }
/// ```
#[clippy::version = "1.82.0"]
pub ANON_TRAIT_IMPORTS,
pub UNUSED_TRAIT_NAMES,
restriction,
"use items that import a trait but only use it anonymously"
}

pub struct AnonTraitImports {
pub struct UnusedTraitNames {
msrv: Msrv,
}

impl AnonTraitImports {
impl UnusedTraitNames {
pub fn new(conf: &'static Conf) -> Self {
Self {
msrv: conf.msrv.clone(),
}
}
}

impl_lint_pass!(AnonTraitImports => [ANON_TRAIT_IMPORTS]);
impl_lint_pass!(UnusedTraitNames => [UNUSED_TRAIT_NAMES]);

impl<'tcx> LateLintPass<'tcx> for AnonTraitImports {
impl<'tcx> LateLintPass<'tcx> for UnusedTraitNames {
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
if self.msrv.meets(msrvs::UNDERSCORE_IMPORTS)
&& !in_external_macro(cx.sess(), item.span)
Expand All @@ -80,7 +80,7 @@ impl<'tcx> LateLintPass<'tcx> for AnonTraitImports {
let complete_span = last_segment.ident.span.to(item.ident.span);
span_lint_and_sugg(
cx,
ANON_TRAIT_IMPORTS,
UNUSED_TRAIT_NAMES,
complete_span,
"importing trait that is only used anonymously",
"use",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@aux-build:proc_macros.rs

#![allow(unused)]
#![warn(clippy::anon_trait_imports)]
#![warn(clippy::unused_trait_names)]
#![feature(decl_macro)]

extern crate proc_macros;
Expand Down Expand Up @@ -239,20 +239,20 @@ proc_macros::with_span!(
}
);

// This should warn the import is unused but should not trigger anon_trait_imports
// This should warn the import is unused but should not trigger unused_trait_names
#[warn(unused)]
mod unused_import {

}

#[allow(clippy::anon_trait_imports)]
#[allow(clippy::unused_trait_names)]
fn allow_lint_fn() {
use std::any::Any;

"foo".type_id();
}

#[allow(clippy::anon_trait_imports)]
#[allow(clippy::unused_trait_names)]
mod allow_lint_mod {
use std::any::Any;

Expand All @@ -262,7 +262,7 @@ mod allow_lint_mod {
}

mod allow_lint_import {
#[allow(clippy::anon_trait_imports)]
#[allow(clippy::unused_trait_names)]
use std::any::Any;

fn foo() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@aux-build:proc_macros.rs

#![allow(unused)]
#![warn(clippy::anon_trait_imports)]
#![warn(clippy::unused_trait_names)]
#![feature(decl_macro)]

extern crate proc_macros;
Expand Down Expand Up @@ -239,20 +239,20 @@ proc_macros::with_span!(
}
);

// This should warn the import is unused but should not trigger anon_trait_imports
// This should warn the import is unused but should not trigger unused_trait_names
#[warn(unused)]
mod unused_import {
use std::any::Any;
}

#[allow(clippy::anon_trait_imports)]
#[allow(clippy::unused_trait_names)]
fn allow_lint_fn() {
use std::any::Any;

"foo".type_id();
}

#[allow(clippy::anon_trait_imports)]
#[allow(clippy::unused_trait_names)]
mod allow_lint_mod {
use std::any::Any;

Expand All @@ -262,7 +262,7 @@ mod allow_lint_mod {
}

mod allow_lint_import {
#[allow(clippy::anon_trait_imports)]
#[allow(clippy::unused_trait_names)]
use std::any::Any;

fn foo() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: unused import: `std::any::Any`
--> tests/ui/anon_trait_imports.rs:245:9
--> tests/ui/unused_trait_names.rs:245:9
|
LL | use std::any::Any;
| ^^^^^^^^^^^^^
Expand All @@ -8,58 +8,58 @@ LL | use std::any::Any;
= help: to override `-D warnings` add `#[allow(unused_imports)]`

error: importing trait that is only used anonymously
--> tests/ui/anon_trait_imports.rs:12:19
--> tests/ui/unused_trait_names.rs:12:19
|
LL | use std::any::Any;
| ^^^ help: use: `Any as _`
|
= note: `-D clippy::anon-trait-imports` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::anon_trait_imports)]`
= note: `-D clippy::unused-trait-names` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::unused_trait_names)]`

error: importing trait that is only used anonymously
--> tests/ui/anon_trait_imports.rs:31:26
--> tests/ui/unused_trait_names.rs:31:26
|
LL | use std::any::{self, Any, TypeId};
| ^^^ help: use: `Any as _`

error: importing trait that is only used anonymously
--> tests/ui/anon_trait_imports.rs:43:19
--> tests/ui/unused_trait_names.rs:43:19
|
LL | use std::any::Any as MyAny;
| ^^^^^^^^^^^^ help: use: `Any as _`

error: importing trait that is only used anonymously
--> tests/ui/anon_trait_imports.rs:49:20
--> tests/ui/unused_trait_names.rs:49:20
|
LL | use std::any::{Any as MyAny, TypeId as MyTypeId};
| ^^^^^^^^^^^^ help: use: `Any as _`

error: importing trait that is only used anonymously
--> tests/ui/anon_trait_imports.rs:72:23
--> tests/ui/unused_trait_names.rs:72:23
|
LL | use std::any::Any;
| ^^^ help: use: `Any as _`

error: importing trait that is only used anonymously
--> tests/ui/anon_trait_imports.rs:113:19
--> tests/ui/unused_trait_names.rs:113:19
|
LL | use std::any::Any;
| ^^^ help: use: `Any as _`

error: importing trait that is only used anonymously
--> tests/ui/anon_trait_imports.rs:132:19
--> tests/ui/unused_trait_names.rs:132:19
|
LL | use std::any::Any;
| ^^^ help: use: `Any as _`

error: importing trait that is only used anonymously
--> tests/ui/anon_trait_imports.rs:191:34
--> tests/ui/unused_trait_names.rs:191:34
|
LL | use simple_trait::{MyStruct, MyTrait};
| ^^^^^^^ help: use: `MyTrait as _`

error: importing trait that is only used anonymously
--> tests/ui/anon_trait_imports.rs:198:27
--> tests/ui/unused_trait_names.rs:198:27
|
LL | use std::any::Any;
| ^^^ help: use: `Any as _`
Expand Down

0 comments on commit dfc5a52

Please sign in to comment.