Skip to content

Commit

Permalink
Fix fallout from rust-lang/rust#68204
Browse files Browse the repository at this point in the history
`{ast,hir}::ItemKind::Impl` use named fields now
  • Loading branch information
ecstatic-morse committed Jan 18, 2020
1 parent 6bd0580 commit 8d61c72
Show file tree
Hide file tree
Showing 23 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/copy_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ declare_lint_pass!(CopyIterator => [COPY_ITERATOR]);

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

if is_copy(cx, ty) && match_path(&trait_ref.path, &paths::ITERATOR) {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ declare_lint_pass!(Derive => [EXPL_IMPL_CLONE_ON_COPY, DERIVE_HASH_XOR_EQ]);

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

Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DocMarkdown {
lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers);
}
},
hir::ItemKind::Impl(_, _, _, _, ref trait_ref, ..) => {
self.in_trait_impl = trait_ref.is_some();
hir::ItemKind::Impl { ref of_trait, .. } => {
self.in_trait_impl = of_trait.is_some();
},
_ => {},
}
}

fn check_item_post(&mut self, _cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item<'_>) {
if let hir::ItemKind::Impl(..) = item.kind {
if let hir::ItemKind::Impl { .. } = item.kind {
self.in_trait_impl = false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/fallible_impl_from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for FallibleImplFrom {
// check for `impl From<???> for ..`
let impl_def_id = cx.tcx.hir().local_def_id(item.hir_id);
if_chain! {
if let hir::ItemKind::Impl(.., impl_items) = item.kind;
if let hir::ItemKind::Impl { items, .. } = item.kind;
if let Some(impl_trait_ref) = cx.tcx.impl_trait_ref(impl_def_id);
if match_def_path(cx, impl_trait_ref.def_id, &FROM_TRAIT);
then {
lint_impl_body(cx, item.span, impl_items);
lint_impl_body(cx, item.span, items);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
hir_id: hir::HirId,
) {
let is_impl = if let Some(hir::Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) {
matches!(item.kind, hir::ItemKind::Impl(_, _, _, _, Some(_), _, _))
matches!(item.kind, hir::ItemKind::Impl { of_trait: Some(_), .. })
} else {
false
};
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/inherent_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl_lint_pass!(MultipleInherentImpl => [MULTIPLE_INHERENT_IMPL]);

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MultipleInherentImpl {
fn check_item(&mut self, _: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
if let ItemKind::Impl(_, _, _, ref generics, None, _, _) = item.kind {
if let ItemKind::Impl { ref generics, of_trait: None, .. } = item.kind {
// Remember for each inherent implementation encoutered its span and generics
// but filter out implementations that have generic params (type or lifetime)
// or are derived from a macro
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/len_zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LenZero {

match item.kind {
ItemKind::Trait(_, _, _, _, ref trait_items) => check_trait_items(cx, item, trait_items),
ItemKind::Impl(_, _, _, _, None, _, ref impl_items) => check_impl_items(cx, item, impl_items),
ItemKind::Impl { of_trait: None, ref items, .. } => check_impl_items(cx, item, items),
_ => (),
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Methods {
if_chain! {
if let hir::ImplItemKind::Method(ref sig, id) = impl_item.kind;
if let Some(first_arg) = iter_input_pats(&sig.decl, cx.tcx.hir().body(id)).next();
if let hir::ItemKind::Impl(_, _, _, _, None, _, _) = item.kind;
if let hir::ItemKind::Impl { of_trait: None, .. } = item.kind;

let method_def_id = cx.tcx.hir().local_def_id(impl_item.hir_id);
let method_sig = cx.tcx.fn_sig(method_def_id);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/missing_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
hir::ItemKind::ExternCrate(..)
| hir::ItemKind::ForeignMod(..)
| hir::ItemKind::GlobalAsm(..)
| hir::ItemKind::Impl(..)
| hir::ItemKind::Impl { .. }
| hir::ItemKind::Use(..) => return,
};

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/missing_inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
| hir::ItemKind::OpaqueTy(..)
| hir::ItemKind::ExternCrate(..)
| hir::ItemKind::ForeignMod(..)
| hir::ItemKind::Impl(..)
| hir::ItemKind::Impl { .. }
| hir::ItemKind::Use(..) => {},
};
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/needless_pass_by_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {

// Exclude non-inherent impls
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) {
if matches!(item.kind, ItemKind::Impl(_, _, _, _, Some(_), _, _) |
if matches!(item.kind, ItemKind::Impl { of_trait: Some(_), .. } |
ItemKind::Trait(..))
{
return;
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/new_without_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl_lint_pass!(NewWithoutDefault => [NEW_WITHOUT_DEFAULT]);

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item<'_>) {
if let hir::ItemKind::Impl(_, _, _, _, None, _, items) = item.kind {
if let hir::ItemKind::Impl { of_trait: None, items, .. } = item.kind {
for assoc_item in items {
if let hir::AssocItemKind::Method { has_self: false } = assoc_item.kind {
let impl_item = cx.tcx.hir().impl_item(assoc_item.id);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/non_copy_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCopyConst {
let item_hir_id = cx.tcx.hir().get_parent_node(impl_item.hir_id);
let item = cx.tcx.hir().expect_item(item_hir_id);
// Ensure the impl is an inherent impl.
if let ItemKind::Impl(_, _, _, _, None, _, _) = item.kind {
if let ItemKind::Impl { None, .. } = item.kind {
let ty = hir_ty_to_ty(cx.tcx, hir_ty);
verify_ty_bound(
cx,
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/partialeq_ne_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ declare_lint_pass!(PartialEqNeImpl => [PARTIALEQ_NE_IMPL]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PartialEqNeImpl {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
if_chain! {
if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, impl_items) = item.kind;
if let ItemKind::Impl { of_trait: Some(ref trait_ref), items, .. } = item.kind;
if !is_automatically_derived(&*item.attrs);
if let Some(eq_trait) = cx.tcx.lang_items().eq_trait();
if trait_ref.path.res.def_id() == eq_trait;
then {
for impl_item in impl_items {
for impl_item in items {
if impl_item.ident.name == sym!(ne) {
span_lint_hir(
cx,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Ptr {
if let ImplItemKind::Method(ref sig, body_id) = item.kind {
let parent_item = cx.tcx.hir().get_parent_item(item.hir_id);
if let Some(Node::Item(it)) = cx.tcx.hir().find(parent_item) {
if let ItemKind::Impl(_, _, _, _, Some(_), _, _) = it.kind {
if let ItemKind::Impl { of_trait: Some(_), .. } = it.kind {
return; // ignore trait impls
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/serde_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ declare_lint_pass!(SerdeAPI => [SERDE_API_MISUSE]);

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SerdeAPI {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, items) = item.kind {
if let ItemKind::Impl { of_trait: Some(ref trait_ref), items, .. } = item.kind {
let did = trait_ref.path.res.def_id();
if let Some(visit_did) = get_trait_def_id(cx, &paths::SERDE_DE_VISITOR) {
if did == visit_did {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/trivially_copy_pass_by_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef {

// Exclude non-inherent impls
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) {
if matches!(item.kind, ItemKind::Impl(_, _, _, _, Some(_), _, _) |
if matches!(item.kind, ItemKind::Impl { of_trait: Some(_), .. } |
ItemKind::Trait(..))
{
return;
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Types {
) {
// Skip trait implementations; see issue #605.
if let Some(hir::Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_item(id)) {
if let ItemKind::Impl(_, _, _, _, Some(..), _, _) = item.kind {
if let ItemKind::Impl { of_trait: Some(_), .. } = item.kind {
return;
}
}
Expand Down Expand Up @@ -2106,9 +2106,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImplicitHasher {
}

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

for target in &vis.found {
if differing_macro_contexts(item.span, target.span()) {
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/unused_self.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedSelf {
if item.span.from_expansion() {
return;
}
if let ItemKind::Impl(_, _, _, _, None, _, impl_item_refs) = item.kind {
for impl_item_ref in impl_item_refs {
if let ItemKind::Impl { of_trait: None, items, .. } = item.kind {
for impl_item_ref in items {
if_chain! {
if let ImplItemRef {
kind: AssocItemKind::Method { has_self: true },
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/use_self.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseSelf {
return;
}
if_chain! {
if let ItemKind::Impl(.., ref item_type, refs) = item.kind;
if let ItemKind::Impl { ref self_ty, ref items } = item.kind;
if let TyKind::Path(QPath::Resolved(_, ref item_path)) = item_type.kind;
then {
let parameters = &item_path.segments.last().expect(SEGMENTS_MSG).args;
Expand All @@ -195,7 +195,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseSelf {
let impl_trait_ref = cx.tcx.impl_trait_ref(impl_def_id);

if let Some(impl_trait_ref) = impl_trait_ref {
for impl_item_ref in refs {
for impl_item_ref in items {
let impl_item = cx.tcx.hir().impl_item(impl_item_ref.id);
if let ImplItemKind::Method(FnSig{ decl: impl_decl, .. }, impl_body_id)
= &impl_item.kind {
Expand All @@ -209,7 +209,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseSelf {
}
}
} else {
for impl_item_ref in refs {
for impl_item_ref in items {
let impl_item = cx.tcx.hir().impl_item(impl_item_ref.id);
visitor.visit_impl_item(impl_item);
}
Expand Down Expand Up @@ -269,7 +269,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UseSelfVisitor<'a, 'tcx> {
| ItemKind::Enum(..)
| ItemKind::Struct(..)
| ItemKind::Union(..)
| ItemKind::Impl(..)
| ItemKind::Impl { .. }
| ItemKind::Fn(..) => {
// Don't check statements that shadow `Self` or where `Self` can't be used
},
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/utils/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,10 @@ fn print_item(cx: &LateContext<'_, '_>, item: &hir::Item<'_>) {
hir::ItemKind::TraitAlias(..) => {
println!("trait alias");
},
hir::ItemKind::Impl(_, _, _, _, Some(ref _trait_ref), _, _) => {
hir::ItemKind::Impl { of_trait: Some(_), .. } => {
println!("trait impl");
},
hir::ItemKind::Impl(_, _, _, _, None, _, _) => {
hir::ItemKind::Impl { of_trait: None, .. } => {
println!("impl");
},
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/utils/internal_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass {
} else if is_expn_of(item.span, "impl_lint_pass").is_some()
|| is_expn_of(item.span, "declare_lint_pass").is_some()
{
if let hir::ItemKind::Impl(.., None, _, ref impl_item_refs) = item.kind {
if let hir::ItemKind::Impl { of_trait: None, ref items, ..} = item.kind {
let mut collector = LintCollector {
output: &mut self.registered_lints,
cx,
};
let body_id = cx.tcx.hir().body_owned_by(
impl_item_refs
items
.iter()
.find(|iiref| iiref.ident.as_str() == "get_lints")
.expect("LintPass needs to implement get_lints")
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ pub fn trait_ref_of_method<'tcx>(cx: &LateContext<'_, 'tcx>, hir_id: HirId) -> O
if_chain! {
if parent_impl != hir::CRATE_HIR_ID;
if let hir::Node::Item(item) = cx.tcx.hir().get(parent_impl);
if let hir::ItemKind::Impl(_, _, _, _, trait_ref, _, _) = &item.kind;
then { return trait_ref.as_ref(); }
if let hir::ItemKind::Impl { of_trait, .. } = &item.kind;
then { return of_trait.as_ref(); }
}
None
}
Expand Down

0 comments on commit 8d61c72

Please sign in to comment.