Skip to content

Commit

Permalink
Auto merge of #5324 - matthiaskrgr:rustup_32, r=flip1995
Browse files Browse the repository at this point in the history
rustup rust-lang/rust#69738

changelog: none
  • Loading branch information
bors committed Mar 16, 2020
2 parents 24f6d64 + a97f60b commit 23549a8
Show file tree
Hide file tree
Showing 18 changed files with 32 additions and 32 deletions.
8 changes: 4 additions & 4 deletions clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rustc_ast::ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MetaItemKind,
use rustc_ast::util::lev_distance::find_best_match_for_name;
use rustc_errors::Applicability;
use rustc_hir::{
Block, Expr, ExprKind, ImplItem, ImplItemKind, Item, ItemKind, StmtKind, TraitItem, TraitItemKind, TraitMethod,
Block, Expr, ExprKind, ImplItem, ImplItemKind, Item, ItemKind, StmtKind, TraitFn, TraitItem, TraitItemKind,
};
use rustc_lint::{CheckLintNameResult, EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
use rustc_session::{declare_lint_pass, declare_tool_lint};
Expand Down Expand Up @@ -372,15 +372,15 @@ fn is_relevant_item(cx: &LateContext<'_, '_>, item: &Item<'_>) -> bool {

fn is_relevant_impl(cx: &LateContext<'_, '_>, item: &ImplItem<'_>) -> bool {
match item.kind {
ImplItemKind::Method(_, eid) => is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value),
ImplItemKind::Fn(_, eid) => is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value),
_ => false,
}
}

fn is_relevant_trait(cx: &LateContext<'_, '_>, item: &TraitItem<'_>) -> bool {
match item.kind {
TraitItemKind::Fn(_, TraitMethod::Required(_)) => true,
TraitItemKind::Fn(_, TraitMethod::Provided(eid)) => {
TraitItemKind::Fn(_, TraitFn::Required(_)) => true,
TraitItemKind::Fn(_, TraitFn::Provided(eid)) => {
is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value)
},
_ => false,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DocMarkdown {
if self.in_trait_impl || in_external_macro(cx.tcx.sess, item.span) {
return;
}
if let hir::ImplItemKind::Method(ref sig, body_id) = item.kind {
if let hir::ImplItemKind::Fn(ref sig, body_id) = item.kind {
lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, Some(body_id));
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/fallible_impl_from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn lint_impl_body<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, impl_span: Span, impl_it
for impl_item in impl_items {
if_chain! {
if impl_item.ident.name == sym!(from);
if let ImplItemKind::Method(_, body_id) =
if let ImplItemKind::Fn(_, body_id) =
cx.tcx.hir().impl_item(impl_item.id).kind;
then {
// check the body for `begin_panic` or `unwrap`
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
}

fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::ImplItem<'_>) {
if let hir::ImplItemKind::Method(ref sig, ref body_id) = item.kind {
if let hir::ImplItemKind::Fn(ref sig, ref body_id) = item.kind {
let attr = must_use_attr(&item.attrs);
if let Some(attr) = attr {
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
Expand Down Expand Up @@ -284,7 +284,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
check_needless_must_use(cx, &sig.decl, item.hir_id, item.span, fn_header_span, attr);
}
if let hir::TraitMethod::Provided(eid) = *eid {
if let hir::TraitFn::Provided(eid) = *eid {
let body = cx.tcx.hir().body(eid);
Self::check_raw_ptr(cx, sig.header.unsafety, &sig.decl, body, item.hir_id);

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/inherent_to_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InherentToString {

if_chain! {
// Check if item is a method, called to_string and has a parameter 'self'
if let ImplItemKind::Method(ref signature, _) = impl_item.kind;
if let ImplItemKind::Fn(ref signature, _) = impl_item.kind;
if impl_item.ident.name.as_str() == "to_string";
let decl = &signature.decl;
if decl.implicit_self.has_implicit_self();
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/inline_fn_without_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::utils::span_lint_and_then;
use crate::utils::sugg::DiagnosticBuilderExt;
use rustc_ast::ast::{Attribute, Name};
use rustc_errors::Applicability;
use rustc_hir::{TraitItem, TraitItemKind, TraitMethod};
use rustc_hir::{TraitFn, TraitItem, TraitItemKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint};

Expand Down Expand Up @@ -32,7 +32,7 @@ declare_lint_pass!(InlineFnWithoutBody => [INLINE_FN_WITHOUT_BODY]);

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InlineFnWithoutBody {
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem<'_>) {
if let TraitItemKind::Fn(_, TraitMethod::Required(_)) = item.kind {
if let TraitItemKind::Fn(_, TraitFn::Required(_)) = item.kind {
check_attrs(cx, item.ident.name, &item.attrs);
}
}
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_hir::intravisit::{
use rustc_hir::FnRetTy::Return;
use rustc_hir::{
BodyId, FnDecl, GenericArg, GenericBound, GenericParam, GenericParamKind, Generics, ImplItem, ImplItemKind, Item,
ItemKind, Lifetime, LifetimeName, ParamName, QPath, TraitBoundModifier, TraitItem, TraitItemKind, TraitMethod, Ty,
ItemKind, Lifetime, LifetimeName, ParamName, QPath, TraitBoundModifier, TraitFn, TraitItem, TraitItemKind, Ty,
TyKind, WhereClause, WherePredicate,
};
use rustc_lint::{LateContext, LateLintPass, LintContext};
Expand Down Expand Up @@ -86,7 +86,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Lifetimes {
}

fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem<'_>) {
if let ImplItemKind::Method(ref sig, id) = item.kind {
if let ImplItemKind::Fn(ref sig, id) = item.kind {
let report_extra_lifetimes = trait_ref_of_method(cx, item.hir_id).is_none();
check_fn_inner(
cx,
Expand All @@ -102,8 +102,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Lifetimes {
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem<'_>) {
if let TraitItemKind::Fn(ref sig, ref body) = item.kind {
let body = match *body {
TraitMethod::Required(_) => None,
TraitMethod::Provided(id) => Some(id),
TraitFn::Required(_) => None,
TraitFn::Provided(id) => Some(id),
};
check_fn_inner(cx, &sig.decl, body, &item.generics, item.span, true);
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Methods {
let def_id = cx.tcx.hir().local_def_id(item.hir_id);
let ty = cx.tcx.type_of(def_id);
if_chain! {
if let hir::ImplItemKind::Method(ref sig, id) = impl_item.kind;
if let hir::ImplItemKind::Fn(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{ of_trait: None, .. } = item.kind;

Expand Down Expand Up @@ -1469,7 +1469,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Methods {
}
}

if let hir::ImplItemKind::Method(_, _) = impl_item.kind {
if let hir::ImplItemKind::Fn(_, _) = impl_item.kind {
let ret_ty = return_ty(cx, impl_item.hir_id);

// walk the return type and check for Self (this does not check associated types)
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 @@ -185,7 +185,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {

let desc = match impl_item.kind {
hir::ImplItemKind::Const(..) => "an associated constant",
hir::ImplItemKind::Method(..) => "a method",
hir::ImplItemKind::Fn(..) => "a method",
hir::ImplItemKind::TyAlias(_) => "an associated type",
hir::ImplItemKind::OpaqueTy(_) => "an existential type",
};
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 @@ -141,7 +141,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
}

let desc = match impl_item.kind {
hir::ImplItemKind::Method(..) => "a method",
hir::ImplItemKind::Fn(..) => "a method",
hir::ImplItemKind::Const(..) | hir::ImplItemKind::TyAlias(_) | hir::ImplItemKind::OpaqueTy(_) => return,
};

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/mut_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableKeyType {
}

fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::ImplItem<'tcx>) {
if let hir::ImplItemKind::Method(ref sig, ..) = item.kind {
if let hir::ImplItemKind::Fn(ref sig, ..) = item.kind {
if trait_ref_of_method(cx, item.hir_id).is_none() {
check_sig(cx, item.hir_id, &sig.decl);
}
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 @@ -105,7 +105,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
if in_external_macro(cx.sess(), impl_item.span) {
return;
}
if let hir::ImplItemKind::Method(ref sig, _) = impl_item.kind {
if let hir::ImplItemKind::Fn(ref sig, _) = impl_item.kind {
let name = impl_item.ident.name;
let id = impl_item.hir_id;
if sig.header.constness == hir::Constness::Const {
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rustc::ty;
use rustc_errors::Applicability;
use rustc_hir::{
BinOpKind, BodyId, Expr, ExprKind, FnDecl, FnRetTy, GenericArg, HirId, ImplItem, ImplItemKind, Item, ItemKind,
Lifetime, MutTy, Mutability, Node, PathSegment, QPath, TraitItem, TraitItemKind, TraitMethod, Ty, TyKind,
Lifetime, MutTy, Mutability, Node, PathSegment, QPath, TraitFn, TraitItem, TraitItemKind, Ty, TyKind,
};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint};
Expand Down Expand Up @@ -109,7 +109,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Ptr {
}

fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem<'_>) {
if let ImplItemKind::Method(ref sig, body_id) = item.kind {
if let ImplItemKind::Fn(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 { of_trait: Some(_), .. } = it.kind {
Expand All @@ -122,7 +122,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Ptr {

fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem<'_>) {
if let TraitItemKind::Fn(ref sig, ref trait_method) = item.kind {
let body_id = if let TraitMethod::Provided(b) = *trait_method {
let body_id = if let TraitFn::Provided(b) = *trait_method {
Some(b)
} else {
None
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 @@ -15,8 +15,8 @@ use rustc_hir as hir;
use rustc_hir::intravisit::{walk_body, walk_expr, walk_ty, FnKind, NestedVisitorMap, Visitor};
use rustc_hir::{
BinOpKind, Body, Expr, ExprKind, FnDecl, FnRetTy, FnSig, GenericArg, GenericParamKind, HirId, ImplItem,
ImplItemKind, Item, ItemKind, Lifetime, Local, MatchSource, MutTy, Mutability, QPath, Stmt, StmtKind, TraitItem,
TraitItemKind, TraitMethod, TyKind, UnOp,
ImplItemKind, Item, ItemKind, Lifetime, Local, MatchSource, MutTy, Mutability, QPath, Stmt, StmtKind, TraitFn,
TraitItem, TraitItemKind, TyKind, UnOp,
};
use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_session::{declare_lint_pass, declare_tool_lint, impl_lint_pass};
Expand Down Expand Up @@ -1457,7 +1457,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeComplexity {
fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem<'_>) {
match item.kind {
TraitItemKind::Const(ref ty, _) | TraitItemKind::Type(_, Some(ref ty)) => self.check_type(cx, ty),
TraitItemKind::Fn(FnSig { ref decl, .. }, TraitMethod::Required(_)) => self.check_fndecl(cx, decl),
TraitItemKind::Fn(FnSig { ref decl, .. }, TraitFn::Required(_)) => self.check_fndecl(cx, decl),
// methods with default impl are covered by check_fn
_ => (),
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/unused_self.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedSelf {
kind: AssocItemKind::Method { has_self: true },
..
} = impl_item_ref;
if let ImplItemKind::Method(_, body_id) = &impl_item.kind;
if let ImplItemKind::Fn(_, body_id) = &impl_item.kind;
let body = cx.tcx.hir().body(*body_id);
if !body.params.is_empty();
then {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/use_self.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseSelf {
if let Some(impl_trait_ref) = impl_trait_ref {
for impl_item_ref in refs {
let impl_item = cx.tcx.hir().impl_item(impl_item_ref.id);
if let ImplItemKind::Method(FnSig{ decl: impl_decl, .. }, impl_body_id)
if let ImplItemKind::Fn(FnSig{ decl: impl_decl, .. }, impl_body_id)
= &impl_item.kind {
let item_type = cx.tcx.type_of(impl_def_id);
check_trait_method_impl_decl(cx, item_type, impl_item, impl_decl, &impl_trait_ref);
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/utils/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DeepCodeInspector {
println!("associated constant");
print_expr(cx, &cx.tcx.hir().body(body_id).value, 1);
},
hir::ImplItemKind::Method(..) => println!("method"),
hir::ImplItemKind::Fn(..) => println!("method"),
hir::ImplItemKind::TyAlias(_) => println!("associated type"),
hir::ImplItemKind::OpaqueTy(_) => println!("existential type"),
}
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 @@ -101,7 +101,7 @@ pub fn in_constant(cx: &LateContext<'_, '_>, id: HirId) -> bool {
..
})
| Node::ImplItem(&ImplItem {
kind: ImplItemKind::Method(ref sig, _),
kind: ImplItemKind::Fn(ref sig, _),
..
}) => sig.header.constness == Constness::Const,
_ => false,
Expand Down Expand Up @@ -758,7 +758,7 @@ pub fn get_enclosing_block<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, hir_id: HirId)
..
})
| Node::ImplItem(&ImplItem {
kind: ImplItemKind::Method(_, eid),
kind: ImplItemKind::Fn(_, eid),
..
}) => match cx.tcx.hir().body(eid).value.kind {
ExprKind::Block(ref block, _) => Some(block),
Expand Down

0 comments on commit 23549a8

Please sign in to comment.