Skip to content

Commit e36a33f

Browse files
committed
Auto merge of #5059 - JohnTitor:rustup-0118, r=llogiq
Rustup to rust-lang/rust#68204 changelog: none
2 parents 6bd0580 + e72f0e6 commit e36a33f

24 files changed

+75
-28
lines changed

clippy_lints/src/copy_iterator.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ 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 {
37+
of_trait: Some(ref trait_ref),
38+
..
39+
} = item.kind
40+
{
3741
let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id(item.hir_id));
3842

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

clippy_lints/src/derive.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ 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 {
70+
of_trait: Some(ref trait_ref),
71+
..
72+
} = item.kind
73+
{
7074
let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id(item.hir_id));
7175
let is_automatically_derived = is_automatically_derived(&*item.attrs);
7276

clippy_lints/src/doc.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,18 @@ 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, ..) => {
162+
hir::ItemKind::Impl {
163+
of_trait: ref trait_ref,
164+
..
165+
} => {
163166
self.in_trait_impl = trait_ref.is_some();
164167
},
165168
_ => {},
166169
}
167170
}
168171

169172
fn check_item_post(&mut self, _cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item<'_>) {
170-
if let hir::ItemKind::Impl(..) = item.kind {
173+
if let hir::ItemKind::Impl { .. } = item.kind {
171174
self.in_trait_impl = false;
172175
}
173176
}

clippy_lints/src/escape.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxedLocal {
6464
let parent_node = cx.tcx.hir().find(parent_id);
6565

6666
if let Some(Node::Item(item)) = parent_node {
67-
if let ItemKind::Impl(_, _, _, _, Some(..), _, _) = item.kind {
67+
if let ItemKind::Impl { of_trait: Some(_), .. } = item.kind {
6868
return;
6969
}
7070
}

clippy_lints/src/fallible_impl_from.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ 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: 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 {

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ 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 {
53+
ref generics,
54+
of_trait: None,
55+
..
56+
} = item.kind
57+
{
5358
// Remember for each inherent implementation encoutered its span and generics
5459
// but filter out implementations that have generic params (type or lifetime)
5560
// or are derived from a macro

clippy_lints/src/len_zero.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ 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 {
82+
of_trait: None,
83+
items: ref impl_items,
84+
..
85+
} => check_impl_items(cx, item, impl_items),
8286
_ => (),
8387
}
8488
}

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,12 @@ pub struct NewWithoutDefault {
9393
impl_lint_pass!(NewWithoutDefault => [NEW_WITHOUT_DEFAULT]);
9494

9595
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
96+
#[allow(clippy::too_many_lines)]
9697
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item<'_>) {
97-
if let hir::ItemKind::Impl(_, _, _, _, None, _, items) = item.kind {
98+
if let hir::ItemKind::Impl {
99+
of_trait: None, items, ..
100+
} = item.kind
101+
{
98102
for assoc_item in items {
99103
if let hir::AssocItemKind::Method { has_self: false } = assoc_item.kind {
100104
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 { of_trait: 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

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ 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: impl_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;

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ 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 {
26+
of_trait: Some(ref trait_ref),
27+
items,
28+
..
29+
} = item.kind
30+
{
2631
let did = trait_ref.path.res.def_id();
2732
if let Some(visit_did) = get_trait_def_id(cx, &paths::SERDE_DE_VISITOR) {
2833
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

+7-2
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,7 +2106,12 @@ 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 {
2110+
ref generics,
2111+
self_ty: ref ty,
2112+
ref items,
2113+
..
2114+
} => {
21102115
let mut vis = ImplicitHasherTypeVisitor::new(cx);
21112116
vis.visit_ty(ty);
21122117

clippy_lints/src/unused_self.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ 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 {
47+
if let ItemKind::Impl {
48+
of_trait: None,
49+
items: impl_item_refs,
50+
..
51+
} = item.kind
52+
{
4853
for impl_item_ref in impl_item_refs {
4954
if_chain! {
5055
if let ImplItemRef {

clippy_lints/src/use_self.rs

+2-2
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{ self_ty: ref item_type, items: refs, .. } = 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;
@@ -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

+5-2
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,13 @@ 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 {
392+
of_trait: Some(ref _trait_ref),
393+
..
394+
} => {
392395
println!("trait impl");
393396
},
394-
hir::ItemKind::Impl(_, _, _, _, None, _, _) => {
397+
hir::ItemKind::Impl { of_trait: None, .. } => {
395398
println!("impl");
396399
},
397400
}

clippy_lints/src/utils/internal_lints.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,12 @@ 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 {
223+
of_trait: None,
224+
items: ref impl_item_refs,
225+
..
226+
} = item.kind
227+
{
223228
let mut collector = LintCollector {
224229
output: &mut self.registered_lints,
225230
cx,

clippy_lints/src/utils/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ 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;
360+
if let hir::ItemKind::Impl{ of_trait: trait_ref, .. } = &item.kind;
361361
then { return trait_ref.as_ref(); }
362362
}
363363
None

0 commit comments

Comments
 (0)