Skip to content

Commit 11e3ae3

Browse files
committed
Auto merge of rust-lang#143879 - fee1-dead-contrib:push-lrlpoouyqqry, r=fmease
parse `const trait Trait` r? oli-obk or anyone from project-const-traits cc `@rust-lang/project-const-traits`
2 parents a6be68a + 19f8c50 commit 11e3ae3

16 files changed

+23
-26
lines changed

clippy_lints/src/arbitrary_source_item_ordering.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
306306
cur_f = Some(field);
307307
}
308308
},
309-
ItemKind::Trait(is_auto, _safety, _ident, _generics, _generic_bounds, item_ref)
309+
ItemKind::Trait(_constness, is_auto, _safety, _ident, _generics, _generic_bounds, item_ref)
310310
if self.enable_ordering_for_trait && *is_auto == IsAuto::No =>
311311
{
312312
let mut cur_t: Option<(TraitItemId, Ident)> = None;

clippy_lints/src/doc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ impl<'tcx> LateLintPass<'tcx> for Documentation {
740740
);
741741
}
742742
},
743-
ItemKind::Trait(_, unsafety, ..) => match (headers.safety, unsafety) {
743+
ItemKind::Trait(_, _, unsafety, ..) => match (headers.safety, unsafety) {
744744
(false, Safety::Unsafe) => span_lint(
745745
cx,
746746
MISSING_SAFETY_DOC,

clippy_lints/src/len_zero.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ declare_lint_pass!(LenZero => [LEN_ZERO, LEN_WITHOUT_IS_EMPTY, COMPARISON_TO_EMP
125125

126126
impl<'tcx> LateLintPass<'tcx> for LenZero {
127127
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
128-
if let ItemKind::Trait(_, _, ident, _, _, trait_items) = item.kind
128+
if let ItemKind::Trait(_, _, _, ident, _, _, trait_items) = item.kind
129129
&& !item.span.from_expansion()
130130
{
131131
check_trait_items(cx, item, ident, trait_items);

clippy_lints/src/missing_inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
101101
let attrs = cx.tcx.hir_attrs(it.hir_id());
102102
check_missing_inline_attrs(cx, attrs, it.span, desc);
103103
},
104-
hir::ItemKind::Trait(ref _is_auto, ref _unsafe, _ident, _generics, _bounds, trait_items) => {
104+
hir::ItemKind::Trait(ref _constness, ref _is_auto, ref _unsafe, _ident, _generics, _bounds, trait_items) => {
105105
// note: we need to check if the trait is exported so we can't use
106106
// `LateLintPass::check_trait_item` here.
107107
for &tit in trait_items {

clippy_lints/src/trait_bounds.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds {
112112
// special handling for self trait bounds as these are not considered generics
113113
// ie. trait Foo: Display {}
114114
if let Item {
115-
kind: ItemKind::Trait(_, _, _, _, bounds, ..),
115+
kind: ItemKind::Trait(_, _, _, _, _, bounds, ..),
116116
..
117117
} = item
118118
{
@@ -133,7 +133,7 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds {
133133
..
134134
}) = segments.first()
135135
&& let Some(Node::Item(Item {
136-
kind: ItemKind::Trait(_, _, _, _, self_bounds, _),
136+
kind: ItemKind::Trait(_, _, _, _, _, self_bounds, _),
137137
..
138138
})) = cx.tcx.hir_get_if_local(*def_id)
139139
{

clippy_lints/src/upper_case_acronyms.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl LateLintPass<'_> for UpperCaseAcronyms {
131131
return;
132132
}
133133
match it.kind {
134-
ItemKind::TyAlias(ident, ..) | ItemKind::Struct(ident, ..) | ItemKind::Trait(_, _, ident, ..) => {
134+
ItemKind::TyAlias(ident, ..) | ItemKind::Struct(ident, ..) | ItemKind::Trait(_, _, _, ident, ..) => {
135135
check_ident(cx, &ident, it.hir_id(), self.upper_case_acronyms_aggressive);
136136
},
137137
ItemKind::Enum(ident, _, ref enumdef) => {

clippy_utils/src/ast_utils/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
444444
},
445445
(
446446
Trait(box ast::Trait {
447+
constness: lc,
447448
is_auto: la,
448449
safety: lu,
449450
ident: li,
@@ -452,6 +453,7 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
452453
items: lis,
453454
}),
454455
Trait(box ast::Trait {
456+
constness: rc,
455457
is_auto: ra,
456458
safety: ru,
457459
ident: ri,
@@ -460,7 +462,8 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
460462
items: ris,
461463
}),
462464
) => {
463-
la == ra
465+
matches!(lc, ast::Const::No) == matches!(rc, ast::Const::No)
466+
&& la == ra
464467
&& matches!(lu, Safety::Default) == matches!(ru, Safety::Default)
465468
&& eq_id(*li, *ri)
466469
&& eq_generics(lg, rg)

clippy_utils/src/check_proc_macro.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,11 @@ fn item_search_pat(item: &Item<'_>) -> (Pat, Pat) {
252252
ItemKind::Struct(_, _, VariantData::Struct { .. }) => (Pat::Str("struct"), Pat::Str("}")),
253253
ItemKind::Struct(..) => (Pat::Str("struct"), Pat::Str(";")),
254254
ItemKind::Union(..) => (Pat::Str("union"), Pat::Str("}")),
255-
ItemKind::Trait(_, Safety::Unsafe, ..)
255+
ItemKind::Trait(_, _, Safety::Unsafe, ..)
256256
| ItemKind::Impl(Impl {
257257
safety: Safety::Unsafe, ..
258258
}) => (Pat::Str("unsafe"), Pat::Str("}")),
259-
ItemKind::Trait(IsAuto::Yes, ..) => (Pat::Str("auto"), Pat::Str("}")),
259+
ItemKind::Trait(_, IsAuto::Yes, ..) => (Pat::Str("auto"), Pat::Str("}")),
260260
ItemKind::Trait(..) => (Pat::Str("trait"), Pat::Str("}")),
261261
ItemKind::Impl(_) => (Pat::Str("impl"), Pat::Str("}")),
262262
_ => return (Pat::Str(""), Pat::Str("")),

tests/ui/assign_ops.fixed

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ mod issue14871 {
8484
const ONE: Self;
8585
}
8686

87-
#[const_trait]
88-
pub trait NumberConstants {
87+
pub const trait NumberConstants {
8988
fn constant(value: usize) -> Self;
9089
}
9190

tests/ui/assign_ops.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ mod issue14871 {
8484
const ONE: Self;
8585
}
8686

87-
#[const_trait]
88-
pub trait NumberConstants {
87+
pub const trait NumberConstants {
8988
fn constant(value: usize) -> Self;
9089
}
9190

0 commit comments

Comments
 (0)