Skip to content

Commit 3f5ea6b

Browse files
committed
Constify trait aliases
1 parent 07b6b32 commit 3f5ea6b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

clippy_lints/src/item_name_repetitions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ impl LateLintPass<'_> for ItemNameRepetitions {
528528
| ItemKind::Macro(ident, ..)
529529
| ItemKind::Static(_, ident, ..)
530530
| ItemKind::Trait(_, _, _, ident, ..)
531-
| ItemKind::TraitAlias(ident, ..)
531+
| ItemKind::TraitAlias(_, ident, ..)
532532
| ItemKind::TyAlias(ident, ..)
533533
| ItemKind::Union(ident, ..)
534534
| ItemKind::Use(_, UseKind::Single(ident)) => ident,

clippy_utils/src/ast_utils/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,13 +478,20 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
478478
ident: li,
479479
generics: lg,
480480
bounds: lb,
481+
constness: lc,
481482
}),
482483
TraitAlias(box ast::TraitAlias {
483484
ident: ri,
484485
generics: rg,
485486
bounds: rb,
487+
constness: rc,
486488
}),
487-
) => eq_id(*li, *ri) && eq_generics(lg, rg) && over(lb, rb, eq_generic_bound),
489+
) => {
490+
matches!(lc, ast::Const::No) == matches!(rc, ast::Const::No)
491+
&& eq_id(*li, *ri)
492+
&& eq_generics(lg, rg)
493+
&& over(lb, rb, eq_generic_bound)
494+
},
488495
(
489496
Impl(ast::Impl {
490497
generics: lg,

0 commit comments

Comments
 (0)