Skip to content

Commit

Permalink
Update for hir renamings in rustc
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Jul 16, 2018
1 parent 8e92994 commit 6992937
Show file tree
Hide file tree
Showing 41 changed files with 181 additions and 153 deletions.
30 changes: 15 additions & 15 deletions clippy_lints/src/assign_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
$cx:expr,
$ty:expr,
$rty:expr,
$($trait_name:ident:$full_trait_name:ident),+) => {
$($trait_name:ident),+) => {
match $op {
$(hir::$full_trait_name => {
$(hir::BinOpKind::$trait_name => {
let [krate, module] = crate::utils::paths::OPS_MODULE;
let path = [krate, module, concat!(stringify!($trait_name), "Assign")];
let trait_id = if let Some(trait_id) = get_trait_def_id($cx, &path) {
Expand All @@ -159,7 +159,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
if_chain! {
if parent_impl != ast::CRATE_NODE_ID;
if let hir::map::Node::NodeItem(item) = cx.tcx.hir.get(parent_impl);
if let hir::Item_::ItemImpl(_, _, _, _, Some(ref trait_ref), _, _) =
if let hir::ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) =
item.node;
if trait_ref.path.def.def_id() == trait_id;
then { return; }
Expand All @@ -175,18 +175,18 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
cx,
ty,
rty.into(),
Add: BinOpKind::Add,
Sub: BinOpKind::Sub,
Mul: BinOpKind::Mul,
Div: BinOpKind::Div,
Rem: BinOpKind::Rem,
And: BinOpKind::And,
Or: BinOpKind::Or,
BitAnd: BinOpKind::BitAnd,
BitOr: BinOpKind::BitOr,
BitXor: BinOpKind::BitXor,
Shr: BinOpKind::Shr,
Shl: BinOpKind::Shl
Add,
Sub,
Mul,
Div,
Rem,
And,
Or,
BitAnd,
BitOr,
BitXor,
Shr,
Shl
) {
span_lint_and_then(
cx,
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
check_attrs(cx, item.span, item.name, &item.attrs)
}
match item.node {
ItemExternCrate(_) | ItemUse(_, _) => {
ItemKind::ExternCrate(_) | ItemKind::Use(_, _) => {
for attr in &item.attrs {
if let Some(ref lint_list) = attr.meta_item_list() {
match &*attr.name().as_str() {
"allow" | "warn" | "deny" | "forbid" => {
// whitelist `unused_imports` and `deprecated`
for lint in lint_list {
if is_word(lint, "unused_imports") || is_word(lint, "deprecated") {
if let ItemUse(_, _) = item.node {
if let ItemKind::Use(_, _) = item.node {
return;
}
}
Expand Down Expand Up @@ -207,7 +207,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
}

fn is_relevant_item(tcx: TyCtxt, item: &Item) -> bool {
if let ItemFn(_, _, _, eid) = item.node {
if let ItemKind::Fn(_, _, _, eid) = item.node {
is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.hir.body(eid).value)
} else {
true
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 @@ -70,7 +70,7 @@ impl LintPass for Derive {

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

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/empty_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl LintPass for EmptyEnum {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EmptyEnum {
fn check_item(&mut self, cx: &LateContext, item: &Item) {
let did = cx.tcx.hir.local_def_id(item.id);
if let ItemEnum(..) = item.node {
if let ItemKind::Enum(..) = item.node {
let ty = cx.tcx.type_of(did);
let adt = ty.ty_adt_def()
.expect("already checked whether this is an enum");
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/enum_clike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
if cx.tcx.data_layout.pointer_size.bits() != 64 {
return;
}
if let ItemEnum(ref def, _) = item.node {
if let ItemKind::Enum(ref def, _) = item.node {
for var in &def.variants {
let variant = &var.node;
if let Some(ref anon_const) = variant.disr_expr {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/enum_glob_use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl EnumGlobUse {
if item.vis.node.is_pub() {
return; // re-exports are fine
}
if let ItemUse(ref path, UseKind::Glob) = item.node {
if let ItemKind::Use(ref path, UseKind::Glob) = item.node {
if let Def::Enum(_) = path.def {
span_lint(
cx,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
let id = map.hir_to_node_id(cmt.hir_id);
if let Some(NodeStmt(st)) = map.find(map.get_parent_node(id)) {
if let StmtKind::Decl(ref decl, _) = st.node {
if let DeclLocal(ref loc) = decl.node {
if let DeclKind::Local(ref loc) = decl.node {
if let Some(ref ex) = loc.init {
if let ExprKind::Box(..) = ex.node {
if is_non_trait_box(cmt.ty) && !self.is_large_box(cmt.ty) {
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/eval_order_dependence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EvalOrderDependence {
fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) {
match stmt.node {
StmtKind::Expr(ref e, _) | StmtKind::Semi(ref e, _) => DivergenceVisitor { cx }.maybe_walk_expr(e),
StmtKind::Decl(ref d, _) => if let DeclLocal(ref local) = d.node {
StmtKind::Decl(ref d, _) => if let DeclKind::Local(ref local) = d.node {
if let Local {
init: Some(ref e), ..
} = **local
Expand Down Expand Up @@ -267,7 +267,7 @@ fn check_stmt<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, stmt: &'tcx Stmt) -> St
// If the declaration is of a local variable, check its initializer
// expression if it has one. Otherwise, keep going.
let local = match decl.node {
DeclLocal(ref local) => Some(local),
DeclKind::Local(ref local) => Some(local),
_ => None,
};
local
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 @@ -39,7 +39,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for FallibleImplFrom {
// check for `impl From<???> for ..`
let impl_def_id = cx.tcx.hir.local_def_id(item.id);
if_chain! {
if let hir::ItemImpl(.., ref impl_items) = item.node;
if let hir::ItemKind::Impl(.., ref impl_items) = item.node;
if let Some(impl_trait_ref) = cx.tcx.impl_trait_ref(impl_def_id);
if match_def_path(cx.tcx, impl_trait_ref.def_id, &FROM_TRAIT);
then {
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 @@ -86,7 +86,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
use rustc::hir::map::Node::*;

let is_impl = if let Some(NodeItem(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(nodeid)) {
matches!(item.node, hir::ItemImpl(_, _, _, _, Some(_), _, _))
matches!(item.node, hir::ItemKind::Impl(_, _, _, _, 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 @@ -56,7 +56,7 @@ impl LintPass for Pass {

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
fn check_item(&mut self, _: &LateContext<'a, 'tcx>, item: &'tcx Item) {
if let Item_::ItemImpl(_, _, _, ref generics, None, _, _) = item.node {
if let ItemKind::Impl(_, _, _, ref generics, None, _, _) = item.node {
// Remember for each inherent implementation encoutered its span and generics
self.impls
.insert(item.hir_id.owner_def_id(), (item.span, generics.clone()));
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/large_enum_variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl LintPass for LargeEnumVariant {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeEnumVariant {
fn check_item(&mut self, cx: &LateContext, item: &Item) {
let did = cx.tcx.hir.local_def_id(item.id);
if let ItemEnum(ref def, _) = item.node {
if let ItemKind::Enum(ref def, _) = item.node {
let ty = cx.tcx.type_of(did);
let adt = ty.ty_adt_def()
.expect("already checked whether this is an enum");
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/len_zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LenZero {
}

match item.node {
ItemTrait(_, _, _, _, ref trait_items) => check_trait_items(cx, item, trait_items),
ItemImpl(_, _, _, _, None, _, ref impl_items) => check_impl_items(cx, item, impl_items),
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),
_ => (),
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/let_if_seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq {
if_chain! {
if let Some(expr) = it.peek();
if let hir::StmtKind::Decl(ref decl, _) = stmt.node;
if let hir::DeclLocal(ref decl) = decl.node;
if let hir::DeclKind::Local(ref decl) = decl.node;
if let hir::PatKind::Binding(mode, canonical_id, ident, None) = decl.pat.node;
if let hir::StmtKind::Expr(ref if_, _) = expr.node;
if let hir::ExprKind::If(ref cond, ref then, ref else_) = if_.node;
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl LintPass for LifetimePass {

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LifetimePass {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
if let ItemFn(ref decl, _, ref generics, id) = item.node {
if let ItemKind::Fn(ref decl, _, ref generics, id) = item.node {
check_fn_inner(cx, decl, Some(id), generics, item.span);
}
}
Expand Down Expand Up @@ -345,7 +345,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
if let QPath::Resolved(_, ref path) = *path {
if let Def::Existential(def_id) = path.def {
let node_id = self.cx.tcx.hir.as_local_node_id(def_id).unwrap();
if let ItemExistential(ref exist_ty) = self.cx.tcx.hir.expect_item(node_id).node {
if let ItemKind::Existential(ref exist_ty) = self.cx.tcx.hir.expect_item(node_id).node {
for bound in &exist_ty.bounds {
if let GenericBound::Outlives(_) = *bound {
self.record(&None);
Expand All @@ -360,7 +360,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
}
self.collect_anonymous_lifetimes(path, ty);
}
TyTraitObject(ref bounds, ref lt) => {
TyKind::TraitObject(ref bounds, ref lt) => {
if !lt.is_elided() {
self.abort = true;
}
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/loops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ fn stmt_to_expr(stmt: &Stmt) -> Option<&Expr> {

fn decl_to_expr(decl: &Decl) -> Option<&Expr> {
match decl.node {
DeclLocal(ref local) => local.init.as_ref().map(|p| &**p),
DeclKind::Local(ref local) => local.init.as_ref().map(|p| &**p),
_ => None,
}
}
Expand Down Expand Up @@ -771,7 +771,7 @@ fn get_fixed_offset_var<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &Expr, var:

let offset = match idx.node {
ExprKind::Binary(op, ref lhs, ref rhs) => match op.node {
BinOpKindAdd => {
BinOpKind::Add => {
let offset_opt = if same_var(cx, lhs, var) {
extract_offset(cx, rhs, var)
} else if same_var(cx, rhs, var) {
Expand Down Expand Up @@ -1810,7 +1810,7 @@ fn extract_expr_from_first_stmt(block: &Block) -> Option<&Expr> {
return None;
}
if let StmtKind::Decl(ref decl, _) = block.stmts[0].node {
if let DeclLocal(ref local) = decl.node {
if let DeclKind::Local(ref local) = decl.node {
if let Some(ref expr) = local.init {
Some(expr)
} else {
Expand Down Expand Up @@ -1931,7 +1931,7 @@ struct InitializeVisitor<'a, 'tcx: 'a> {
impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> {
fn visit_decl(&mut self, decl: &'tcx Decl) {
// Look for declarations of the variable
if let DeclLocal(ref local) = decl.node {
if let DeclKind::Local(ref local) = decl.node {
if local.pat.id == self.var_id {
if let PatKind::Binding(_, _, ident, _) = local.pat.node {
self.name = Some(ident.name);
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
if let hir::ImplItemKind::Method(ref sig, id) = implitem.node;
if let Some(first_arg_ty) = sig.decl.inputs.get(0);
if let Some(first_arg) = iter_input_pats(&sig.decl, cx.tcx.hir.body(id)).next();
if let hir::ItemImpl(_, _, _, _, None, ref self_ty, _) = item.node;
if let hir::ItemKind::Impl(_, _, _, _, None, ref self_ty, _) = item.node;
then {
if cx.access_levels.is_exported(implitem.id) {
// check missing trait implementations
Expand Down Expand Up @@ -1140,7 +1140,7 @@ fn lint_clone_on_copy(cx: &LateContext, expr: &hir::Expr, arg: &hir::Expr, arg_t
}
hir::map::NodeStmt(stmt) => {
if let hir::StmtKind::Decl(ref decl, _) = stmt.node {
if let hir::DeclLocal(ref loc) = decl.node {
if let hir::DeclKind::Local(ref loc) = decl.node {
if let hir::PatKind::Ref(..) = loc.pat.node {
// let ref y = *x borrows x, let ref y = x.clone() does not
return;
Expand Down Expand Up @@ -1338,7 +1338,7 @@ fn lint_unnecessary_fold(cx: &LateContext, expr: &hir::Expr, fold_args: &[hir::E
cx, fold_args, hir::BinOpKind::And, "all", true
),
ast::LitKind::Int(0, _) => check_fold_with_op(
cx, fold_args, hir::BinOpKindAdd, "sum", false
cx, fold_args, hir::BinOpKind::Add, "sum", false
),
ast::LitKind::Int(1, _) => check_fold_with_op(
cx, fold_args, hir::BinOpKind::Mul, "product", false
Expand Down Expand Up @@ -2175,7 +2175,7 @@ enum OutType {

impl OutType {
fn matches(self, cx: &LateContext, ty: &hir::FunctionRetTy) -> bool {
let is_unit = |ty: &hir::Ty| SpanlessEq::new(cx).eq_ty_kind(&ty.node, &hir::TyTup(vec![].into()));
let is_unit = |ty: &hir::Ty| SpanlessEq::new(cx).eq_ty_kind(&ty.node, &hir::TyKind::Tup(vec![].into()));
match (self, ty) {
(OutType::Unit, &hir::DefaultReturn(_)) => true,
(OutType::Unit, &hir::Return(ref ty)) if is_unit(ty) => true,
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, s: &'tcx Stmt) {
if_chain! {
if let StmtKind::Decl(ref d, _) = s.node;
if let DeclLocal(ref l) = d.node;
if let DeclKind::Local(ref l) = d.node;
if let PatKind::Binding(an, _, i, None) = l.pat.node;
if let Some(ref init) = l.init;
then {
Expand Down Expand Up @@ -520,7 +520,7 @@ fn check_to_owned(cx: &LateContext, expr: &Expr, other: &Expr) {
let parent_impl = cx.tcx.hir.get_parent(parent_fn);
if parent_impl != CRATE_NODE_ID {
if let map::NodeItem(item) = cx.tcx.hir.get(parent_impl) {
if let ItemImpl(.., Some(ref trait_ref), _, _) = item.node {
if let ItemKind::Impl(.., Some(ref trait_ref), _, _) = item.node {
if trait_ref.path.def.def_id() == partial_eq_trait_id {
// we are implementing PartialEq, don't suggest not doing `to_owned`, otherwise
// we go into
Expand Down
32 changes: 16 additions & 16 deletions clippy_lints/src/missing_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {

fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
let desc = match it.node {
hir::ItemConst(..) => "a constant",
hir::ItemEnum(..) => "an enum",
hir::ItemFn(..) => {
hir::ItemKind::Const(..) => "a constant",
hir::ItemKind::Enum(..) => "an enum",
hir::ItemKind::Fn(..) => {
// ignore main()
if it.name == "main" {
let def_id = cx.tcx.hir.local_def_id(it.id);
Expand All @@ -135,19 +135,19 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
}
"a function"
},
hir::ItemMod(..) => "a module",
hir::ItemStatic(..) => "a static",
hir::ItemStruct(..) => "a struct",
hir::ItemTrait(..) => "a trait",
hir::ItemTraitAlias(..) => "a trait alias",
hir::ItemGlobalAsm(..) => "an assembly blob",
hir::ItemTy(..) => "a type alias",
hir::ItemUnion(..) => "a union",
hir::ItemExistential(..) => "an existential type",
hir::ItemExternCrate(..) |
hir::ItemForeignMod(..) |
hir::ItemImpl(..) |
hir::ItemUse(..) => return,
hir::ItemKind::Mod(..) => "a module",
hir::ItemKind::Static(..) => "a static",
hir::ItemKind::Struct(..) => "a struct",
hir::ItemKind::Trait(..) => "a trait",
hir::ItemKind::TraitAlias(..) => "a trait alias",
hir::ItemKind::GlobalAsm(..) => "an assembly blob",
hir::ItemKind::Ty(..) => "a type alias",
hir::ItemKind::Union(..) => "a union",
hir::ItemKind::Existential(..) => "an existential type",
hir::ItemKind::ExternCrate(..) |
hir::ItemKind::ForeignMod(..) |
hir::ItemKind::Impl(..) |
hir::ItemKind::Use(..) => return,
};

self.check_missing_docs_attrs(cx, &it.attrs, it.span, desc);
Expand Down
Loading

0 comments on commit 6992937

Please sign in to comment.