Skip to content

Commit 7830b0e

Browse files
committed
submodules: Update clippy from 8c80b65 to e3cb40e
1 parent db0d014 commit 7830b0e

14 files changed

+59
-71
lines changed

clippy_lints/src/escape.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxedLocal {
6363
) {
6464
// If the method is an impl for a trait, don't warn.
6565
let parent_id = cx.tcx.hir().get_parent_item(hir_id);
66-
let parent_node = cx.tcx.hir().find_by_hir_id(parent_id);
66+
let parent_node = cx.tcx.hir().find(parent_id);
6767

6868
if let Some(Node::Item(item)) = parent_node {
6969
if let ItemKind::Impl(_, _, _, _, Some(..), _, _) = item.node {
@@ -113,9 +113,9 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
113113
fn matched_pat(&mut self, _: &Pat, _: &cmt_<'tcx>, _: MatchMode) {}
114114
fn consume_pat(&mut self, consume_pat: &Pat, cmt: &cmt_<'tcx>, _: ConsumeMode) {
115115
let map = &self.cx.tcx.hir();
116-
if map.is_argument(map.hir_to_node_id(consume_pat.hir_id)) {
116+
if map.is_argument(consume_pat.hir_id) {
117117
// Skip closure arguments
118-
if let Some(Node::Expr(..)) = map.find_by_hir_id(map.get_parent_node_by_hir_id(consume_pat.hir_id)) {
118+
if let Some(Node::Expr(..)) = map.find(map.get_parent_node(consume_pat.hir_id)) {
119119
return;
120120
}
121121
if is_non_trait_box(cmt.ty) && !self.is_large_box(cmt.ty) {
@@ -124,7 +124,7 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
124124
return;
125125
}
126126
if let Categorization::Rvalue(..) = cmt.cat {
127-
if let Some(Node::Stmt(st)) = map.find_by_hir_id(map.get_parent_node_by_hir_id(cmt.hir_id)) {
127+
if let Some(Node::Stmt(st)) = map.find(map.get_parent_node(cmt.hir_id)) {
128128
if let StmtKind::Local(ref loc) = st.node {
129129
if let Some(ref ex) = loc.init {
130130
if let ExprKind::Box(..) = ex.node {

clippy_lints/src/eval_order_dependence.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,11 @@ fn check_for_unsequenced_reads(vis: &mut ReadVisitor<'_, '_>) {
176176
let map = &vis.cx.tcx.hir();
177177
let mut cur_id = vis.write_expr.hir_id;
178178
loop {
179-
let parent_id = map.get_parent_node_by_hir_id(cur_id);
179+
let parent_id = map.get_parent_node(cur_id);
180180
if parent_id == cur_id {
181181
break;
182182
}
183-
let parent_node = match map.find_by_hir_id(parent_id) {
183+
let parent_node = match map.find(parent_id) {
184184
Some(parent) => parent,
185185
None => break,
186186
};

clippy_lints/src/formatting.rs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ use crate::utils::{differing_macro_contexts, in_macro_or_desugar, snippet_opt, s
22
use if_chain::if_chain;
33
use rustc::lint::{in_external_macro, EarlyContext, EarlyLintPass, LintArray, LintPass};
44
use rustc::{declare_lint_pass, declare_tool_lint};
5-
use syntax::ast;
6-
use syntax::ptr::P;
5+
use syntax::ast::*;
76

87
declare_clippy_lint! {
98
/// **What it does:** Checks for use of the non-existent `=*`, `=!` and `=-`
@@ -86,33 +85,33 @@ declare_lint_pass!(Formatting => [
8685
]);
8786

8887
impl EarlyLintPass for Formatting {
89-
fn check_block(&mut self, cx: &EarlyContext<'_>, block: &ast::Block) {
88+
fn check_block(&mut self, cx: &EarlyContext<'_>, block: &Block) {
9089
for w in block.stmts.windows(2) {
9190
match (&w[0].node, &w[1].node) {
92-
(&ast::StmtKind::Expr(ref first), &ast::StmtKind::Expr(ref second))
93-
| (&ast::StmtKind::Expr(ref first), &ast::StmtKind::Semi(ref second)) => {
91+
(&StmtKind::Expr(ref first), &StmtKind::Expr(ref second))
92+
| (&StmtKind::Expr(ref first), &StmtKind::Semi(ref second)) => {
9493
check_missing_else(cx, first, second);
9594
},
9695
_ => (),
9796
}
9897
}
9998
}
10099

101-
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &ast::Expr) {
100+
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
102101
check_assign(cx, expr);
103102
check_else(cx, expr);
104103
check_array(cx, expr);
105104
}
106105
}
107106

108107
/// Implementation of the `SUSPICIOUS_ASSIGNMENT_FORMATTING` lint.
109-
fn check_assign(cx: &EarlyContext<'_>, expr: &ast::Expr) {
110-
if let ast::ExprKind::Assign(ref lhs, ref rhs) = expr.node {
108+
fn check_assign(cx: &EarlyContext<'_>, expr: &Expr) {
109+
if let ExprKind::Assign(ref lhs, ref rhs) = expr.node {
111110
if !differing_macro_contexts(lhs.span, rhs.span) && !in_macro_or_desugar(lhs.span) {
112111
let eq_span = lhs.span.between(rhs.span);
113-
if let ast::ExprKind::Unary(op, ref sub_rhs) = rhs.node {
112+
if let ExprKind::Unary(op, ref sub_rhs) = rhs.node {
114113
if let Some(eq_snippet) = snippet_opt(cx, eq_span) {
115-
let op = ast::UnOp::to_string(op);
114+
let op = UnOp::to_string(op);
116115
let eqop_span = lhs.span.between(sub_rhs.span);
117116
if eq_snippet.ends_with('=') {
118117
span_note_and_lint(
@@ -135,10 +134,10 @@ fn check_assign(cx: &EarlyContext<'_>, expr: &ast::Expr) {
135134
}
136135

137136
/// Implementation of the `SUSPICIOUS_ELSE_FORMATTING` lint for weird `else`.
138-
fn check_else(cx: &EarlyContext<'_>, expr: &ast::Expr) {
137+
fn check_else(cx: &EarlyContext<'_>, expr: &Expr) {
139138
if_chain! {
140-
if let Some((then, &Some(ref else_))) = unsugar_if(expr);
141-
if is_block(else_) || unsugar_if(else_).is_some();
139+
if let ExprKind::If(_, then, Some(else_)) = &expr.node;
140+
if is_block(else_) || is_if(else_);
142141
if !differing_macro_contexts(then.span, else_.span);
143142
if !in_macro_or_desugar(then.span) && !in_external_macro(cx.sess, expr.span);
144143

@@ -154,7 +153,7 @@ fn check_else(cx: &EarlyContext<'_>, expr: &ast::Expr) {
154153
if let Some(else_snippet) = snippet_opt(cx, else_span);
155154
if let Some(else_pos) = else_snippet.find("else");
156155
if else_snippet[else_pos..].contains('\n');
157-
let else_desc = if unsugar_if(else_).is_some() { "if" } else { "{..}" };
156+
let else_desc = if is_if(else_) { "if" } else { "{..}" };
158157

159158
then {
160159
span_note_and_lint(
@@ -173,16 +172,16 @@ fn check_else(cx: &EarlyContext<'_>, expr: &ast::Expr) {
173172
}
174173
}
175174

176-
fn has_unary_equivalent(bin_op: ast::BinOpKind) -> bool {
175+
fn has_unary_equivalent(bin_op: BinOpKind) -> bool {
177176
// &, *, -
178-
bin_op == ast::BinOpKind::And || bin_op == ast::BinOpKind::Mul || bin_op == ast::BinOpKind::Sub
177+
bin_op == BinOpKind::And || bin_op == BinOpKind::Mul || bin_op == BinOpKind::Sub
179178
}
180179

181180
/// Implementation of the `POSSIBLE_MISSING_COMMA` lint for array
182-
fn check_array(cx: &EarlyContext<'_>, expr: &ast::Expr) {
183-
if let ast::ExprKind::Array(ref array) = expr.node {
181+
fn check_array(cx: &EarlyContext<'_>, expr: &Expr) {
182+
if let ExprKind::Array(ref array) = expr.node {
184183
for element in array {
185-
if let ast::ExprKind::Binary(ref op, ref lhs, _) = element.node {
184+
if let ExprKind::Binary(ref op, ref lhs, _) = element.node {
186185
if has_unary_equivalent(op.node) && !differing_macro_contexts(lhs.span, op.span) {
187186
let space_span = lhs.span.between(op.span);
188187
if let Some(space_snippet) = snippet_opt(cx, space_span) {
@@ -204,18 +203,18 @@ fn check_array(cx: &EarlyContext<'_>, expr: &ast::Expr) {
204203
}
205204
}
206205

207-
fn check_missing_else(cx: &EarlyContext<'_>, first: &ast::Expr, second: &ast::Expr) {
206+
fn check_missing_else(cx: &EarlyContext<'_>, first: &Expr, second: &Expr) {
208207
if !differing_macro_contexts(first.span, second.span)
209208
&& !in_macro_or_desugar(first.span)
210-
&& unsugar_if(first).is_some()
211-
&& (is_block(second) || unsugar_if(second).is_some())
209+
&& is_if(first)
210+
&& (is_block(second) || is_if(second))
212211
{
213212
// where the else would be
214213
let else_span = first.span.between(second.span);
215214

216215
if let Some(else_snippet) = snippet_opt(cx, else_span) {
217216
if !else_snippet.contains('\n') {
218-
let (looks_like, next_thing) = if unsugar_if(second).is_some() {
217+
let (looks_like, next_thing) = if is_if(second) {
219218
("an `else if`", "the second `if`")
220219
} else {
221220
("an `else {..}`", "the next block")
@@ -237,18 +236,19 @@ fn check_missing_else(cx: &EarlyContext<'_>, first: &ast::Expr, second: &ast::Ex
237236
}
238237
}
239238

240-
fn is_block(expr: &ast::Expr) -> bool {
241-
if let ast::ExprKind::Block(..) = expr.node {
239+
fn is_block(expr: &Expr) -> bool {
240+
if let ExprKind::Block(..) = expr.node {
242241
true
243242
} else {
244243
false
245244
}
246245
}
247246

248-
/// Match `if` or `if let` expressions and return the `then` and `else` block.
249-
fn unsugar_if(expr: &ast::Expr) -> Option<(&P<ast::Block>, &Option<P<ast::Expr>>)> {
250-
match expr.node {
251-
ast::ExprKind::If(_, ref then, ref else_) => Some((then, else_)),
252-
_ => None,
247+
/// Check if the expression is an `if` or `if let`
248+
fn is_if(expr: &Expr) -> bool {
249+
if let ExprKind::If(..) = expr.node {
250+
true
251+
} else {
252+
false
253253
}
254254
}

clippy_lints/src/functions.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
107107
span: Span,
108108
hir_id: hir::HirId,
109109
) {
110-
let is_impl = if let Some(hir::Node::Item(item)) = cx
111-
.tcx
112-
.hir()
113-
.find_by_hir_id(cx.tcx.hir().get_parent_node_by_hir_id(hir_id))
114-
{
110+
let is_impl = if let Some(hir::Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) {
115111
matches!(item.node, hir::ItemKind::Impl(_, _, _, _, Some(_), _, _))
116112
} else {
117113
false

clippy_lints/src/loops.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2218,8 +2218,8 @@ fn is_conditional(expr: &Expr) -> bool {
22182218
fn is_nested(cx: &LateContext<'_, '_>, match_expr: &Expr, iter_expr: &Expr) -> bool {
22192219
if_chain! {
22202220
if let Some(loop_block) = get_enclosing_block(cx, match_expr.hir_id);
2221-
let parent_node = cx.tcx.hir().get_parent_node_by_hir_id(loop_block.hir_id);
2222-
if let Some(Node::Expr(loop_expr)) = cx.tcx.hir().find_by_hir_id(parent_node);
2221+
let parent_node = cx.tcx.hir().get_parent_node(loop_block.hir_id);
2222+
if let Some(Node::Expr(loop_expr)) = cx.tcx.hir().find(parent_node);
22232223
then {
22242224
return is_loop_nested(cx, loop_expr, iter_expr)
22252225
}
@@ -2235,11 +2235,11 @@ fn is_loop_nested(cx: &LateContext<'_, '_>, loop_expr: &Expr, iter_expr: &Expr)
22352235
return true;
22362236
};
22372237
loop {
2238-
let parent = cx.tcx.hir().get_parent_node_by_hir_id(id);
2238+
let parent = cx.tcx.hir().get_parent_node(id);
22392239
if parent == id {
22402240
return false;
22412241
}
2242-
match cx.tcx.hir().find_by_hir_id(parent) {
2242+
match cx.tcx.hir().find(parent) {
22432243
Some(Node::Expr(expr)) => match expr.node {
22442244
ExprKind::Loop(..) | ExprKind::While(..) => {
22452245
return true;

clippy_lints/src/methods/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,7 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp
14231423
if cx.tables.expr_ty(arg) == ty {
14241424
snip = Some(("try removing the `clone` call", format!("{}", snippet)));
14251425
} else {
1426-
let parent = cx.tcx.hir().get_parent_node_by_hir_id(expr.hir_id);
1426+
let parent = cx.tcx.hir().get_parent_node(expr.hir_id);
14271427
match cx.tcx.hir().get(parent) {
14281428
hir::Node::Expr(parent) => match parent.node {
14291429
// &*x is a nop, &x.clone() is not

clippy_lints/src/needless_bool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBool {
115115
}
116116

117117
fn parent_node_is_if_expr<'a, 'b>(expr: &Expr, cx: &LateContext<'a, 'b>) -> bool {
118-
let parent_id = cx.tcx.hir().get_parent_node_by_hir_id(expr.hir_id);
118+
let parent_id = cx.tcx.hir().get_parent_node(expr.hir_id);
119119
let parent_node = cx.tcx.hir().get(parent_id);
120120

121121
if let rustc::hir::Node::Expr(e) = parent_node {

clippy_lints/src/needless_pass_by_value.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
8888
}
8989

9090
// Exclude non-inherent impls
91-
if let Some(Node::Item(item)) = cx
92-
.tcx
93-
.hir()
94-
.find_by_hir_id(cx.tcx.hir().get_parent_node_by_hir_id(hir_id))
95-
{
91+
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) {
9692
if matches!(item.node, ItemKind::Impl(_, _, _, _, Some(_), _, _) |
9793
ItemKind::Trait(..))
9894
{
@@ -357,14 +353,14 @@ impl<'a, 'tcx> MovedVariablesCtxt<'a, 'tcx> {
357353
if let mc::Categorization::Local(vid) = cmt.cat {
358354
let mut id = matched_pat.hir_id;
359355
loop {
360-
let parent = self.cx.tcx.hir().get_parent_node_by_hir_id(id);
356+
let parent = self.cx.tcx.hir().get_parent_node(id);
361357
if id == parent {
362358
// no parent
363359
return;
364360
}
365361
id = parent;
366362

367-
if let Some(node) = self.cx.tcx.hir().find_by_hir_id(id) {
363+
if let Some(node) = self.cx.tcx.hir().find(id) {
368364
match node {
369365
Node::Expr(e) => {
370366
// `match` and `if let`

clippy_lints/src/non_copy_const.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCopyConst {
169169

170170
fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx ImplItem) {
171171
if let ImplItemKind::Const(hir_ty, ..) = &impl_item.node {
172-
let item_hir_id = cx.tcx.hir().get_parent_node_by_hir_id(impl_item.hir_id);
172+
let item_hir_id = cx.tcx.hir().get_parent_node(impl_item.hir_id);
173173
let item = cx.tcx.hir().expect_item(item_hir_id);
174174
// Ensure the impl is an inherent impl.
175175
if let ItemKind::Impl(_, _, _, _, None, _, _) = item.node {
@@ -204,11 +204,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCopyConst {
204204
let mut dereferenced_expr = expr;
205205
let mut needs_check_adjustment = true;
206206
loop {
207-
let parent_id = cx.tcx.hir().get_parent_node_by_hir_id(cur_expr.hir_id);
207+
let parent_id = cx.tcx.hir().get_parent_node(cur_expr.hir_id);
208208
if parent_id == cur_expr.hir_id {
209209
break;
210210
}
211-
if let Some(Node::Expr(parent_expr)) = cx.tcx.hir().find_by_hir_id(parent_id) {
211+
if let Some(Node::Expr(parent_expr)) = cx.tcx.hir().find(parent_id) {
212212
match &parent_expr.node {
213213
ExprKind::AddrOf(..) => {
214214
// `&e` => `e` must be referenced.

clippy_lints/src/ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Ptr {
106106
fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
107107
if let ImplItemKind::Method(ref sig, body_id) = item.node {
108108
let parent_item = cx.tcx.hir().get_parent_item(item.hir_id);
109-
if let Some(Node::Item(it)) = cx.tcx.hir().find_by_hir_id(parent_item) {
109+
if let Some(Node::Item(it)) = cx.tcx.hir().find(parent_item) {
110110
if let ItemKind::Impl(_, _, _, _, Some(_), _, _) = it.node {
111111
return; // ignore trait impls
112112
}

0 commit comments

Comments
 (0)