Skip to content

Commit d6415a9

Browse files
Rollup merge of #155702 - mejrs:itemkind_trait-fields, r=petrochenkov
Change `ItemKind::Trait` to a field variant. This changes `ItemKind::Trait` from an octuple(!!) to an enum variant with fields. Their names were chosen to match up with existing usage and minimize renaming. I'm leaning towards renaming `ident` to `name` as well; let me know if that's desired.
2 parents a4f8cea + 70cc275 commit d6415a9

16 files changed

Lines changed: 28 additions & 28 deletions

clippy_lints/src/arbitrary_source_item_ordering.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -306,16 +306,16 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
306306
cur_f = Some(field);
307307
}
308308
},
309-
ItemKind::Trait(
310-
_impl_restriction,
311-
_constness,
309+
ItemKind::Trait {
310+
impl_restriction:_,
311+
constness:_,
312312
is_auto,
313-
_safety,
314-
_ident,
315-
_generics,
316-
_generic_bounds,
317-
item_ref,
318-
) if self.enable_ordering_for_trait && *is_auto == IsAuto::No => {
313+
safety:_,
314+
ident:_,
315+
generics: _,
316+
bounds: _,
317+
items: item_ref}
318+
if self.enable_ordering_for_trait && *is_auto == IsAuto::No => {
319319
let mut cur_t: Option<(TraitItemId, Ident)> = None;
320320

321321
for &item in *item_ref {
@@ -510,7 +510,7 @@ fn convert_module_item_kind(value: &ItemKind<'_>) -> SourceItemOrderingModuleIte
510510
ItemKind::Enum(..) => Enum,
511511
ItemKind::Struct(..) => Struct,
512512
ItemKind::Union(..) => Union,
513-
ItemKind::Trait(..) => Trait,
513+
ItemKind::Trait { .. } => Trait,
514514
ItemKind::TraitAlias(..) => TraitAlias,
515515
ItemKind::Impl(..) => Impl,
516516
}

clippy_lints/src/doc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ impl<'tcx> LateLintPass<'tcx> for Documentation {
769769
{
770770
missing_headers::check(cx, item.owner_id, sig, headers, Some(body), self.check_private_items);
771771
},
772-
ItemKind::Trait(_, _, _, unsafety, ..) => match (headers.safety, unsafety) {
772+
ItemKind::Trait { safety, .. } => match (headers.safety, safety) {
773773
(false, Safety::Unsafe) => span_lint(
774774
cx,
775775
MISSING_SAFETY_DOC,

clippy_lints/src/doc/too_long_first_doc_paragraph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub(super) fn check(
3333
| ItemKind::Enum(..)
3434
| ItemKind::Struct(..)
3535
| ItemKind::Union(..)
36-
| ItemKind::Trait(..)
36+
| ItemKind::Trait { .. }
3737
| ItemKind::TraitAlias(..)
3838
)
3939
{

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::Fn { ident, .. }
529529
| ItemKind::Macro(ident, ..)
530530
| ItemKind::Static(_, ident, ..)
531-
| ItemKind::Trait(_, _, _, _, ident, ..)
531+
| ItemKind::Trait { ident, ..}
532532
| ItemKind::TraitAlias(_, ident, ..)
533533
| ItemKind::TyAlias(ident, ..)
534534
| ItemKind::Union(ident, ..)

clippy_lints/src/len_without_is_empty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ declare_lint_pass!(LenWithoutIsEmpty => [LEN_WITHOUT_IS_EMPTY]);
4444

4545
impl<'tcx> LateLintPass<'tcx> for LenWithoutIsEmpty {
4646
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
47-
if let ItemKind::Trait(_, _, _, _, ident, _, _, trait_items) = item.kind
47+
if let ItemKind::Trait { ident, items: trait_items, .. } = item.kind
4848
&& !item.span.from_expansion()
4949
{
5050
check_trait_items(cx, item, ident, trait_items);

clippy_lints/src/missing_const_for_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn {
141141
let parent = cx.tcx.hir_get_parent_item(hir_id).def_id;
142142
if parent != CRATE_DEF_ID
143143
&& let hir::Node::Item(item) = cx.tcx.hir_node_by_def_id(parent)
144-
&& let hir::ItemKind::Trait(..) = &item.kind
144+
&& let hir::ItemKind::Trait { .. } = &item.kind
145145
{
146146
return;
147147
}

clippy_lints/src/missing_doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
159159
| ItemKind::Macro(ident, ..)
160160
| ItemKind::Static(_, ident, ..)
161161
| ItemKind::Struct(ident, ..)
162-
| ItemKind::Trait(_, _, _, _, ident, ..)
162+
| ItemKind::Trait { ident, .. }
163163
| ItemKind::TraitAlias(_, ident, ..)
164164
| ItemKind::TyAlias(ident, ..)
165165
| ItemKind::Union(ident, ..) => ident.span,

clippy_lints/src/missing_inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
111111
let attrs = cx.tcx.hir_attrs(it.hir_id());
112112
check_missing_inline_attrs(cx, attrs, it.span, desc, None);
113113
},
114-
hir::ItemKind::Trait(.., trait_items) => {
114+
hir::ItemKind::Trait { items: trait_items, .. } => {
115115
// note: we need to check if the trait is exported so we can't use
116116
// `LateLintPass::check_trait_item` here.
117117
for &tit in trait_items {

clippy_lints/src/needless_pass_by_ref_mut.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> {
167167
if let Node::Item(item) = cx.tcx.parent_hir_node(hir_id)
168168
&& matches!(
169169
item.kind,
170-
ItemKind::Impl(Impl { of_trait: Some(_), .. }) | ItemKind::Trait(..)
170+
ItemKind::Impl(Impl { of_trait: Some(_), .. }) | ItemKind::Trait { .. }
171171
)
172172
{
173173
return;

clippy_lints/src/needless_pass_by_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
103103
if let Node::Item(item) = cx.tcx.parent_hir_node(hir_id)
104104
&& matches!(
105105
item.kind,
106-
ItemKind::Impl(Impl { of_trait: Some(_), .. }) | ItemKind::Trait(..)
106+
ItemKind::Impl(Impl { of_trait: Some(_), .. }) | ItemKind::Trait { .. }
107107
)
108108
{
109109
return;

0 commit comments

Comments
 (0)