Skip to content

Commit 6992937

Browse files
committed
Update for hir renamings in rustc
1 parent 8e92994 commit 6992937

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+181
-153
lines changed

clippy_lints/src/assign_ops.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
142142
$cx:expr,
143143
$ty:expr,
144144
$rty:expr,
145-
$($trait_name:ident:$full_trait_name:ident),+) => {
145+
$($trait_name:ident),+) => {
146146
match $op {
147-
$(hir::$full_trait_name => {
147+
$(hir::BinOpKind::$trait_name => {
148148
let [krate, module] = crate::utils::paths::OPS_MODULE;
149149
let path = [krate, module, concat!(stringify!($trait_name), "Assign")];
150150
let trait_id = if let Some(trait_id) = get_trait_def_id($cx, &path) {
@@ -159,7 +159,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
159159
if_chain! {
160160
if parent_impl != ast::CRATE_NODE_ID;
161161
if let hir::map::Node::NodeItem(item) = cx.tcx.hir.get(parent_impl);
162-
if let hir::Item_::ItemImpl(_, _, _, _, Some(ref trait_ref), _, _) =
162+
if let hir::ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) =
163163
item.node;
164164
if trait_ref.path.def.def_id() == trait_id;
165165
then { return; }
@@ -175,18 +175,18 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
175175
cx,
176176
ty,
177177
rty.into(),
178-
Add: BinOpKind::Add,
179-
Sub: BinOpKind::Sub,
180-
Mul: BinOpKind::Mul,
181-
Div: BinOpKind::Div,
182-
Rem: BinOpKind::Rem,
183-
And: BinOpKind::And,
184-
Or: BinOpKind::Or,
185-
BitAnd: BinOpKind::BitAnd,
186-
BitOr: BinOpKind::BitOr,
187-
BitXor: BinOpKind::BitXor,
188-
Shr: BinOpKind::Shr,
189-
Shl: BinOpKind::Shl
178+
Add,
179+
Sub,
180+
Mul,
181+
Div,
182+
Rem,
183+
And,
184+
Or,
185+
BitAnd,
186+
BitOr,
187+
BitXor,
188+
Shr,
189+
Shl
190190
) {
191191
span_lint_and_then(
192192
cx,

clippy_lints/src/attrs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
154154
check_attrs(cx, item.span, item.name, &item.attrs)
155155
}
156156
match item.node {
157-
ItemExternCrate(_) | ItemUse(_, _) => {
157+
ItemKind::ExternCrate(_) | ItemKind::Use(_, _) => {
158158
for attr in &item.attrs {
159159
if let Some(ref lint_list) = attr.meta_item_list() {
160160
match &*attr.name().as_str() {
161161
"allow" | "warn" | "deny" | "forbid" => {
162162
// whitelist `unused_imports` and `deprecated`
163163
for lint in lint_list {
164164
if is_word(lint, "unused_imports") || is_word(lint, "deprecated") {
165-
if let ItemUse(_, _) = item.node {
165+
if let ItemKind::Use(_, _) = item.node {
166166
return;
167167
}
168168
}
@@ -207,7 +207,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
207207
}
208208

209209
fn is_relevant_item(tcx: TyCtxt, item: &Item) -> bool {
210-
if let ItemFn(_, _, _, eid) = item.node {
210+
if let ItemKind::Fn(_, _, _, eid) = item.node {
211211
is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.hir.body(eid).value)
212212
} else {
213213
true

clippy_lints/src/derive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl LintPass for Derive {
7070

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

clippy_lints/src/empty_enum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl LintPass for EmptyEnum {
3434
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EmptyEnum {
3535
fn check_item(&mut self, cx: &LateContext, item: &Item) {
3636
let did = cx.tcx.hir.local_def_id(item.id);
37-
if let ItemEnum(..) = item.node {
37+
if let ItemKind::Enum(..) = item.node {
3838
let ty = cx.tcx.type_of(did);
3939
let adt = ty.ty_adt_def()
4040
.expect("already checked whether this is an enum");

clippy_lints/src/enum_clike.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
4747
if cx.tcx.data_layout.pointer_size.bits() != 64 {
4848
return;
4949
}
50-
if let ItemEnum(ref def, _) = item.node {
50+
if let ItemKind::Enum(ref def, _) = item.node {
5151
for var in &def.variants {
5252
let variant = &var.node;
5353
if let Some(ref anon_const) = variant.disr_expr {

clippy_lints/src/enum_glob_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl EnumGlobUse {
4747
if item.vis.node.is_pub() {
4848
return; // re-exports are fine
4949
}
50-
if let ItemUse(ref path, UseKind::Glob) = item.node {
50+
if let ItemKind::Use(ref path, UseKind::Glob) = item.node {
5151
if let Def::Enum(_) = path.def {
5252
span_lint(
5353
cx,

clippy_lints/src/escape.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
111111
let id = map.hir_to_node_id(cmt.hir_id);
112112
if let Some(NodeStmt(st)) = map.find(map.get_parent_node(id)) {
113113
if let StmtKind::Decl(ref decl, _) = st.node {
114-
if let DeclLocal(ref loc) = decl.node {
114+
if let DeclKind::Local(ref loc) = decl.node {
115115
if let Some(ref ex) = loc.init {
116116
if let ExprKind::Box(..) = ex.node {
117117
if is_non_trait_box(cmt.ty) && !self.is_large_box(cmt.ty) {

clippy_lints/src/eval_order_dependence.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EvalOrderDependence {
8383
fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, stmt: &'tcx Stmt) {
8484
match stmt.node {
8585
StmtKind::Expr(ref e, _) | StmtKind::Semi(ref e, _) => DivergenceVisitor { cx }.maybe_walk_expr(e),
86-
StmtKind::Decl(ref d, _) => if let DeclLocal(ref local) = d.node {
86+
StmtKind::Decl(ref d, _) => if let DeclKind::Local(ref local) = d.node {
8787
if let Local {
8888
init: Some(ref e), ..
8989
} = **local
@@ -267,7 +267,7 @@ fn check_stmt<'a, 'tcx>(vis: &mut ReadVisitor<'a, 'tcx>, stmt: &'tcx Stmt) -> St
267267
// If the declaration is of a local variable, check its initializer
268268
// expression if it has one. Otherwise, keep going.
269269
let local = match decl.node {
270-
DeclLocal(ref local) => Some(local),
270+
DeclKind::Local(ref local) => Some(local),
271271
_ => None,
272272
};
273273
local

clippy_lints/src/fallible_impl_from.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for FallibleImplFrom {
3939
// check for `impl From<???> for ..`
4040
let impl_def_id = cx.tcx.hir.local_def_id(item.id);
4141
if_chain! {
42-
if let hir::ItemImpl(.., ref impl_items) = item.node;
42+
if let hir::ItemKind::Impl(.., ref impl_items) = item.node;
4343
if let Some(impl_trait_ref) = cx.tcx.impl_trait_ref(impl_def_id);
4444
if match_def_path(cx.tcx, impl_trait_ref.def_id, &FROM_TRAIT);
4545
then {

clippy_lints/src/functions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
8686
use rustc::hir::map::Node::*;
8787

8888
let is_impl = if let Some(NodeItem(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(nodeid)) {
89-
matches!(item.node, hir::ItemImpl(_, _, _, _, Some(_), _, _))
89+
matches!(item.node, hir::ItemKind::Impl(_, _, _, _, Some(_), _, _))
9090
} else {
9191
false
9292
};

clippy_lints/src/inherent_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl LintPass for Pass {
5656

5757
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
5858
fn check_item(&mut self, _: &LateContext<'a, 'tcx>, item: &'tcx Item) {
59-
if let Item_::ItemImpl(_, _, _, ref generics, None, _, _) = item.node {
59+
if let ItemKind::Impl(_, _, _, ref generics, None, _, _) = item.node {
6060
// Remember for each inherent implementation encoutered its span and generics
6161
self.impls
6262
.insert(item.hir_id.owner_def_id(), (item.span, generics.clone()));

clippy_lints/src/large_enum_variant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl LintPass for LargeEnumVariant {
4949
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeEnumVariant {
5050
fn check_item(&mut self, cx: &LateContext, item: &Item) {
5151
let did = cx.tcx.hir.local_def_id(item.id);
52-
if let ItemEnum(ref def, _) = item.node {
52+
if let ItemKind::Enum(ref def, _) = item.node {
5353
let ty = cx.tcx.type_of(did);
5454
let adt = ty.ty_adt_def()
5555
.expect("already checked whether this is an enum");

clippy_lints/src/len_zero.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LenZero {
6868
}
6969

7070
match item.node {
71-
ItemTrait(_, _, _, _, ref trait_items) => check_trait_items(cx, item, trait_items),
72-
ItemImpl(_, _, _, _, None, _, ref impl_items) => check_impl_items(cx, item, impl_items),
71+
ItemKind::Trait(_, _, _, _, ref trait_items) => check_trait_items(cx, item, trait_items),
72+
ItemKind::Impl(_, _, _, _, None, _, ref impl_items) => check_impl_items(cx, item, impl_items),
7373
_ => (),
7474
}
7575
}

clippy_lints/src/let_if_seq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq {
6666
if_chain! {
6767
if let Some(expr) = it.peek();
6868
if let hir::StmtKind::Decl(ref decl, _) = stmt.node;
69-
if let hir::DeclLocal(ref decl) = decl.node;
69+
if let hir::DeclKind::Local(ref decl) = decl.node;
7070
if let hir::PatKind::Binding(mode, canonical_id, ident, None) = decl.pat.node;
7171
if let hir::StmtKind::Expr(ref if_, _) = expr.node;
7272
if let hir::ExprKind::If(ref cond, ref then, ref else_) = if_.node;

clippy_lints/src/lifetimes.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl LintPass for LifetimePass {
5959

6060
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LifetimePass {
6161
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
62-
if let ItemFn(ref decl, _, ref generics, id) = item.node {
62+
if let ItemKind::Fn(ref decl, _, ref generics, id) = item.node {
6363
check_fn_inner(cx, decl, Some(id), generics, item.span);
6464
}
6565
}
@@ -345,7 +345,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
345345
if let QPath::Resolved(_, ref path) = *path {
346346
if let Def::Existential(def_id) = path.def {
347347
let node_id = self.cx.tcx.hir.as_local_node_id(def_id).unwrap();
348-
if let ItemExistential(ref exist_ty) = self.cx.tcx.hir.expect_item(node_id).node {
348+
if let ItemKind::Existential(ref exist_ty) = self.cx.tcx.hir.expect_item(node_id).node {
349349
for bound in &exist_ty.bounds {
350350
if let GenericBound::Outlives(_) = *bound {
351351
self.record(&None);
@@ -360,7 +360,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
360360
}
361361
self.collect_anonymous_lifetimes(path, ty);
362362
}
363-
TyTraitObject(ref bounds, ref lt) => {
363+
TyKind::TraitObject(ref bounds, ref lt) => {
364364
if !lt.is_elided() {
365365
self.abort = true;
366366
}

clippy_lints/src/loops.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ fn stmt_to_expr(stmt: &Stmt) -> Option<&Expr> {
591591

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

772772
let offset = match idx.node {
773773
ExprKind::Binary(op, ref lhs, ref rhs) => match op.node {
774-
BinOpKindAdd => {
774+
BinOpKind::Add => {
775775
let offset_opt = if same_var(cx, lhs, var) {
776776
extract_offset(cx, rhs, var)
777777
} else if same_var(cx, rhs, var) {
@@ -1810,7 +1810,7 @@ fn extract_expr_from_first_stmt(block: &Block) -> Option<&Expr> {
18101810
return None;
18111811
}
18121812
if let StmtKind::Decl(ref decl, _) = block.stmts[0].node {
1813-
if let DeclLocal(ref local) = decl.node {
1813+
if let DeclKind::Local(ref local) = decl.node {
18141814
if let Some(ref expr) = local.init {
18151815
Some(expr)
18161816
} else {
@@ -1931,7 +1931,7 @@ struct InitializeVisitor<'a, 'tcx: 'a> {
19311931
impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> {
19321932
fn visit_decl(&mut self, decl: &'tcx Decl) {
19331933
// Look for declarations of the variable
1934-
if let DeclLocal(ref local) = decl.node {
1934+
if let DeclKind::Local(ref local) = decl.node {
19351935
if local.pat.id == self.var_id {
19361936
if let PatKind::Binding(_, _, ident, _) = local.pat.node {
19371937
self.name = Some(ident.name);

clippy_lints/src/methods.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
813813
if let hir::ImplItemKind::Method(ref sig, id) = implitem.node;
814814
if let Some(first_arg_ty) = sig.decl.inputs.get(0);
815815
if let Some(first_arg) = iter_input_pats(&sig.decl, cx.tcx.hir.body(id)).next();
816-
if let hir::ItemImpl(_, _, _, _, None, ref self_ty, _) = item.node;
816+
if let hir::ItemKind::Impl(_, _, _, _, None, ref self_ty, _) = item.node;
817817
then {
818818
if cx.access_levels.is_exported(implitem.id) {
819819
// check missing trait implementations
@@ -1140,7 +1140,7 @@ fn lint_clone_on_copy(cx: &LateContext, expr: &hir::Expr, arg: &hir::Expr, arg_t
11401140
}
11411141
hir::map::NodeStmt(stmt) => {
11421142
if let hir::StmtKind::Decl(ref decl, _) = stmt.node {
1143-
if let hir::DeclLocal(ref loc) = decl.node {
1143+
if let hir::DeclKind::Local(ref loc) = decl.node {
11441144
if let hir::PatKind::Ref(..) = loc.pat.node {
11451145
// let ref y = *x borrows x, let ref y = x.clone() does not
11461146
return;
@@ -1338,7 +1338,7 @@ fn lint_unnecessary_fold(cx: &LateContext, expr: &hir::Expr, fold_args: &[hir::E
13381338
cx, fold_args, hir::BinOpKind::And, "all", true
13391339
),
13401340
ast::LitKind::Int(0, _) => check_fold_with_op(
1341-
cx, fold_args, hir::BinOpKindAdd, "sum", false
1341+
cx, fold_args, hir::BinOpKind::Add, "sum", false
13421342
),
13431343
ast::LitKind::Int(1, _) => check_fold_with_op(
13441344
cx, fold_args, hir::BinOpKind::Mul, "product", false
@@ -2175,7 +2175,7 @@ enum OutType {
21752175

21762176
impl OutType {
21772177
fn matches(self, cx: &LateContext, ty: &hir::FunctionRetTy) -> bool {
2178-
let is_unit = |ty: &hir::Ty| SpanlessEq::new(cx).eq_ty_kind(&ty.node, &hir::TyTup(vec![].into()));
2178+
let is_unit = |ty: &hir::Ty| SpanlessEq::new(cx).eq_ty_kind(&ty.node, &hir::TyKind::Tup(vec![].into()));
21792179
match (self, ty) {
21802180
(OutType::Unit, &hir::DefaultReturn(_)) => true,
21812181
(OutType::Unit, &hir::Return(ref ty)) if is_unit(ty) => true,

clippy_lints/src/misc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
270270
fn check_stmt(&mut self, cx: &LateContext<'a, 'tcx>, s: &'tcx Stmt) {
271271
if_chain! {
272272
if let StmtKind::Decl(ref d, _) = s.node;
273-
if let DeclLocal(ref l) = d.node;
273+
if let DeclKind::Local(ref l) = d.node;
274274
if let PatKind::Binding(an, _, i, None) = l.pat.node;
275275
if let Some(ref init) = l.init;
276276
then {
@@ -520,7 +520,7 @@ fn check_to_owned(cx: &LateContext, expr: &Expr, other: &Expr) {
520520
let parent_impl = cx.tcx.hir.get_parent(parent_fn);
521521
if parent_impl != CRATE_NODE_ID {
522522
if let map::NodeItem(item) = cx.tcx.hir.get(parent_impl) {
523-
if let ItemImpl(.., Some(ref trait_ref), _, _) = item.node {
523+
if let ItemKind::Impl(.., Some(ref trait_ref), _, _) = item.node {
524524
if trait_ref.path.def.def_id() == partial_eq_trait_id {
525525
// we are implementing PartialEq, don't suggest not doing `to_owned`, otherwise
526526
// we go into

clippy_lints/src/missing_doc.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
122122

123123
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
124124
let desc = match it.node {
125-
hir::ItemConst(..) => "a constant",
126-
hir::ItemEnum(..) => "an enum",
127-
hir::ItemFn(..) => {
125+
hir::ItemKind::Const(..) => "a constant",
126+
hir::ItemKind::Enum(..) => "an enum",
127+
hir::ItemKind::Fn(..) => {
128128
// ignore main()
129129
if it.name == "main" {
130130
let def_id = cx.tcx.hir.local_def_id(it.id);
@@ -135,19 +135,19 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
135135
}
136136
"a function"
137137
},
138-
hir::ItemMod(..) => "a module",
139-
hir::ItemStatic(..) => "a static",
140-
hir::ItemStruct(..) => "a struct",
141-
hir::ItemTrait(..) => "a trait",
142-
hir::ItemTraitAlias(..) => "a trait alias",
143-
hir::ItemGlobalAsm(..) => "an assembly blob",
144-
hir::ItemTy(..) => "a type alias",
145-
hir::ItemUnion(..) => "a union",
146-
hir::ItemExistential(..) => "an existential type",
147-
hir::ItemExternCrate(..) |
148-
hir::ItemForeignMod(..) |
149-
hir::ItemImpl(..) |
150-
hir::ItemUse(..) => return,
138+
hir::ItemKind::Mod(..) => "a module",
139+
hir::ItemKind::Static(..) => "a static",
140+
hir::ItemKind::Struct(..) => "a struct",
141+
hir::ItemKind::Trait(..) => "a trait",
142+
hir::ItemKind::TraitAlias(..) => "a trait alias",
143+
hir::ItemKind::GlobalAsm(..) => "an assembly blob",
144+
hir::ItemKind::Ty(..) => "a type alias",
145+
hir::ItemKind::Union(..) => "a union",
146+
hir::ItemKind::Existential(..) => "an existential type",
147+
hir::ItemKind::ExternCrate(..) |
148+
hir::ItemKind::ForeignMod(..) |
149+
hir::ItemKind::Impl(..) |
150+
hir::ItemKind::Use(..) => return,
151151
};
152152

153153
self.check_missing_docs_attrs(cx, &it.attrs, it.span, desc);

0 commit comments

Comments
 (0)