Skip to content

Commit 8d61c72

Browse files
Fix fallout from rust-lang/rust#68204
`{ast,hir}::ItemKind::Impl` use named fields now
1 parent 6bd0580 commit 8d61c72

23 files changed

+36
-36
lines changed

clippy_lints/src/copy_iterator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ declare_lint_pass!(CopyIterator => [COPY_ITERATOR]);
3333

3434
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CopyIterator {
3535
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
36-
if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.kind {
36+
if let ItemKind::Impl { of_trait: Some(ref trait_ref) } = item.kind {
3737
let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id(item.hir_id));
3838

3939
if is_copy(cx, ty) && match_path(&trait_ref.path, &paths::ITERATOR) {

clippy_lints/src/derive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ declare_lint_pass!(Derive => [EXPL_IMPL_CLONE_ON_COPY, DERIVE_HASH_XOR_EQ]);
6666

6767
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Derive {
6868
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
69-
if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.kind {
69+
if let ItemKind::Impl { of_trait: Some(ref trait_ref), .. } = item.kind {
7070
let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id(item.hir_id));
7171
let is_automatically_derived = is_automatically_derived(&*item.attrs);
7272

clippy_lints/src/doc.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DocMarkdown {
159159
lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers);
160160
}
161161
},
162-
hir::ItemKind::Impl(_, _, _, _, ref trait_ref, ..) => {
163-
self.in_trait_impl = trait_ref.is_some();
162+
hir::ItemKind::Impl { ref of_trait, .. } => {
163+
self.in_trait_impl = of_trait.is_some();
164164
},
165165
_ => {},
166166
}
167167
}
168168

169169
fn check_item_post(&mut self, _cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item<'_>) {
170-
if let hir::ItemKind::Impl(..) = item.kind {
170+
if let hir::ItemKind::Impl { .. } = item.kind {
171171
self.in_trait_impl = false;
172172
}
173173
}

clippy_lints/src/fallible_impl_from.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for FallibleImplFrom {
3636
// check for `impl From<???> for ..`
3737
let impl_def_id = cx.tcx.hir().local_def_id(item.hir_id);
3838
if_chain! {
39-
if let hir::ItemKind::Impl(.., impl_items) = item.kind;
39+
if let hir::ItemKind::Impl { items, .. } = item.kind;
4040
if let Some(impl_trait_ref) = cx.tcx.impl_trait_ref(impl_def_id);
4141
if match_def_path(cx, impl_trait_ref.def_id, &FROM_TRAIT);
4242
then {
43-
lint_impl_body(cx, item.span, impl_items);
43+
lint_impl_body(cx, item.span, items);
4444
}
4545
}
4646
}

clippy_lints/src/functions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
196196
hir_id: hir::HirId,
197197
) {
198198
let is_impl = if let Some(hir::Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) {
199-
matches!(item.kind, hir::ItemKind::Impl(_, _, _, _, Some(_), _, _))
199+
matches!(item.kind, hir::ItemKind::Impl { of_trait: Some(_), .. })
200200
} else {
201201
false
202202
};

clippy_lints/src/inherent_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl_lint_pass!(MultipleInherentImpl => [MULTIPLE_INHERENT_IMPL]);
4949

5050
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MultipleInherentImpl {
5151
fn check_item(&mut self, _: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
52-
if let ItemKind::Impl(_, _, _, ref generics, None, _, _) = item.kind {
52+
if let ItemKind::Impl { ref generics, of_trait: None, .. } = item.kind {
5353
// Remember for each inherent implementation encoutered its span and generics
5454
// but filter out implementations that have generic params (type or lifetime)
5555
// or are derived from a macro

clippy_lints/src/len_zero.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LenZero {
7878

7979
match item.kind {
8080
ItemKind::Trait(_, _, _, _, ref trait_items) => check_trait_items(cx, item, trait_items),
81-
ItemKind::Impl(_, _, _, _, None, _, ref impl_items) => check_impl_items(cx, item, impl_items),
81+
ItemKind::Impl { of_trait: None, ref items, .. } => check_impl_items(cx, item, items),
8282
_ => (),
8383
}
8484
}

clippy_lints/src/methods/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Methods {
13351335
if_chain! {
13361336
if let hir::ImplItemKind::Method(ref sig, id) = impl_item.kind;
13371337
if let Some(first_arg) = iter_input_pats(&sig.decl, cx.tcx.hir().body(id)).next();
1338-
if let hir::ItemKind::Impl(_, _, _, _, None, _, _) = item.kind;
1338+
if let hir::ItemKind::Impl { of_trait: None, .. } = item.kind;
13391339

13401340
let method_def_id = cx.tcx.hir().local_def_id(impl_item.hir_id);
13411341
let method_sig = cx.tcx.fn_sig(method_def_id);

clippy_lints/src/missing_doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
154154
hir::ItemKind::ExternCrate(..)
155155
| hir::ItemKind::ForeignMod(..)
156156
| hir::ItemKind::GlobalAsm(..)
157-
| hir::ItemKind::Impl(..)
157+
| hir::ItemKind::Impl { .. }
158158
| hir::ItemKind::Use(..) => return,
159159
};
160160

clippy_lints/src/missing_inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
124124
| hir::ItemKind::OpaqueTy(..)
125125
| hir::ItemKind::ExternCrate(..)
126126
| hir::ItemKind::ForeignMod(..)
127-
| hir::ItemKind::Impl(..)
127+
| hir::ItemKind::Impl { .. }
128128
| hir::ItemKind::Use(..) => {},
129129
};
130130
}

clippy_lints/src/needless_pass_by_value.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
9191

9292
// Exclude non-inherent impls
9393
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) {
94-
if matches!(item.kind, ItemKind::Impl(_, _, _, _, Some(_), _, _) |
94+
if matches!(item.kind, ItemKind::Impl { of_trait: Some(_), .. } |
9595
ItemKind::Trait(..))
9696
{
9797
return;

clippy_lints/src/new_without_default.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl_lint_pass!(NewWithoutDefault => [NEW_WITHOUT_DEFAULT]);
9494

9595
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
9696
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item<'_>) {
97-
if let hir::ItemKind::Impl(_, _, _, _, None, _, items) = item.kind {
97+
if let hir::ItemKind::Impl { of_trait: None, items, .. } = item.kind {
9898
for assoc_item in items {
9999
if let hir::AssocItemKind::Method { has_self: false } = assoc_item.kind {
100100
let impl_item = cx.tcx.hir().impl_item(assoc_item.id);

clippy_lints/src/non_copy_const.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCopyConst {
168168
let item_hir_id = cx.tcx.hir().get_parent_node(impl_item.hir_id);
169169
let item = cx.tcx.hir().expect_item(item_hir_id);
170170
// Ensure the impl is an inherent impl.
171-
if let ItemKind::Impl(_, _, _, _, None, _, _) = item.kind {
171+
if let ItemKind::Impl { None, .. } = item.kind {
172172
let ty = hir_ty_to_ty(cx.tcx, hir_ty);
173173
verify_ty_bound(
174174
cx,

clippy_lints/src/partialeq_ne_impl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ declare_lint_pass!(PartialEqNeImpl => [PARTIALEQ_NE_IMPL]);
3333
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PartialEqNeImpl {
3434
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
3535
if_chain! {
36-
if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, impl_items) = item.kind;
36+
if let ItemKind::Impl { of_trait: Some(ref trait_ref), items, .. } = item.kind;
3737
if !is_automatically_derived(&*item.attrs);
3838
if let Some(eq_trait) = cx.tcx.lang_items().eq_trait();
3939
if trait_ref.path.res.def_id() == eq_trait;
4040
then {
41-
for impl_item in impl_items {
41+
for impl_item in items {
4242
if impl_item.ident.name == sym!(ne) {
4343
span_lint_hir(
4444
cx,

clippy_lints/src/ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Ptr {
110110
if let ImplItemKind::Method(ref sig, body_id) = item.kind {
111111
let parent_item = cx.tcx.hir().get_parent_item(item.hir_id);
112112
if let Some(Node::Item(it)) = cx.tcx.hir().find(parent_item) {
113-
if let ItemKind::Impl(_, _, _, _, Some(_), _, _) = it.kind {
113+
if let ItemKind::Impl { of_trait: Some(_), .. } = it.kind {
114114
return; // ignore trait impls
115115
}
116116
}

clippy_lints/src/serde_api.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ declare_lint_pass!(SerdeAPI => [SERDE_API_MISUSE]);
2222

2323
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SerdeAPI {
2424
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
25-
if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, items) = item.kind {
25+
if let ItemKind::Impl { of_trait: Some(ref trait_ref), items, .. } = item.kind {
2626
let did = trait_ref.path.res.def_id();
2727
if let Some(visit_did) = get_trait_def_id(cx, &paths::SERDE_DE_VISITOR) {
2828
if did == visit_did {

clippy_lints/src/trivially_copy_pass_by_ref.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef {
167167

168168
// Exclude non-inherent impls
169169
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) {
170-
if matches!(item.kind, ItemKind::Impl(_, _, _, _, Some(_), _, _) |
170+
if matches!(item.kind, ItemKind::Impl { of_trait: Some(_), .. } |
171171
ItemKind::Trait(..))
172172
{
173173
return;

clippy_lints/src/types.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Types {
181181
) {
182182
// Skip trait implementations; see issue #605.
183183
if let Some(hir::Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_item(id)) {
184-
if let ItemKind::Impl(_, _, _, _, Some(..), _, _) = item.kind {
184+
if let ItemKind::Impl { of_trait: Some(_), .. } = item.kind {
185185
return;
186186
}
187187
}
@@ -2106,9 +2106,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImplicitHasher {
21062106
}
21072107

21082108
match item.kind {
2109-
ItemKind::Impl(_, _, _, ref generics, _, ref ty, ref items) => {
2109+
ItemKind::Impl { ref generics, ref self_ty, ref items } => {
21102110
let mut vis = ImplicitHasherTypeVisitor::new(cx);
2111-
vis.visit_ty(ty);
2111+
vis.visit_ty(self_ty);
21122112

21132113
for target in &vis.found {
21142114
if differing_macro_contexts(item.span, target.span()) {

clippy_lints/src/unused_self.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedSelf {
4444
if item.span.from_expansion() {
4545
return;
4646
}
47-
if let ItemKind::Impl(_, _, _, _, None, _, impl_item_refs) = item.kind {
48-
for impl_item_ref in impl_item_refs {
47+
if let ItemKind::Impl { of_trait: None, items, .. } = item.kind {
48+
for impl_item_ref in items {
4949
if_chain! {
5050
if let ImplItemRef {
5151
kind: AssocItemKind::Method { has_self: true },

clippy_lints/src/use_self.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseSelf {
173173
return;
174174
}
175175
if_chain! {
176-
if let ItemKind::Impl(.., ref item_type, refs) = item.kind;
176+
if let ItemKind::Impl { ref self_ty, ref items } = item.kind;
177177
if let TyKind::Path(QPath::Resolved(_, ref item_path)) = item_type.kind;
178178
then {
179179
let parameters = &item_path.segments.last().expect(SEGMENTS_MSG).args;
@@ -195,7 +195,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseSelf {
195195
let impl_trait_ref = cx.tcx.impl_trait_ref(impl_def_id);
196196

197197
if let Some(impl_trait_ref) = impl_trait_ref {
198-
for impl_item_ref in refs {
198+
for impl_item_ref in items {
199199
let impl_item = cx.tcx.hir().impl_item(impl_item_ref.id);
200200
if let ImplItemKind::Method(FnSig{ decl: impl_decl, .. }, impl_body_id)
201201
= &impl_item.kind {
@@ -209,7 +209,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseSelf {
209209
}
210210
}
211211
} else {
212-
for impl_item_ref in refs {
212+
for impl_item_ref in items {
213213
let impl_item = cx.tcx.hir().impl_item(impl_item_ref.id);
214214
visitor.visit_impl_item(impl_item);
215215
}
@@ -269,7 +269,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UseSelfVisitor<'a, 'tcx> {
269269
| ItemKind::Enum(..)
270270
| ItemKind::Struct(..)
271271
| ItemKind::Union(..)
272-
| ItemKind::Impl(..)
272+
| ItemKind::Impl { .. }
273273
| ItemKind::Fn(..) => {
274274
// Don't check statements that shadow `Self` or where `Self` can't be used
275275
},

clippy_lints/src/utils/inspector.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,10 @@ fn print_item(cx: &LateContext<'_, '_>, item: &hir::Item<'_>) {
388388
hir::ItemKind::TraitAlias(..) => {
389389
println!("trait alias");
390390
},
391-
hir::ItemKind::Impl(_, _, _, _, Some(ref _trait_ref), _, _) => {
391+
hir::ItemKind::Impl { of_trait: Some(_), .. } => {
392392
println!("trait impl");
393393
},
394-
hir::ItemKind::Impl(_, _, _, _, None, _, _) => {
394+
hir::ItemKind::Impl { of_trait: None, .. } => {
395395
println!("impl");
396396
},
397397
}

clippy_lints/src/utils/internal_lints.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass {
219219
} else if is_expn_of(item.span, "impl_lint_pass").is_some()
220220
|| is_expn_of(item.span, "declare_lint_pass").is_some()
221221
{
222-
if let hir::ItemKind::Impl(.., None, _, ref impl_item_refs) = item.kind {
222+
if let hir::ItemKind::Impl { of_trait: None, ref items, ..} = item.kind {
223223
let mut collector = LintCollector {
224224
output: &mut self.registered_lints,
225225
cx,
226226
};
227227
let body_id = cx.tcx.hir().body_owned_by(
228-
impl_item_refs
228+
items
229229
.iter()
230230
.find(|iiref| iiref.ident.as_str() == "get_lints")
231231
.expect("LintPass needs to implement get_lints")

clippy_lints/src/utils/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ pub fn trait_ref_of_method<'tcx>(cx: &LateContext<'_, 'tcx>, hir_id: HirId) -> O
357357
if_chain! {
358358
if parent_impl != hir::CRATE_HIR_ID;
359359
if let hir::Node::Item(item) = cx.tcx.hir().get(parent_impl);
360-
if let hir::ItemKind::Impl(_, _, _, _, trait_ref, _, _) = &item.kind;
361-
then { return trait_ref.as_ref(); }
360+
if let hir::ItemKind::Impl { of_trait, .. } = &item.kind;
361+
then { return of_trait.as_ref(); }
362362
}
363363
None
364364
}

0 commit comments

Comments
 (0)