Skip to content

Commit e3cb40e

Browse files
committed
Auto merge of rust-lang#4235 - Manishearth:rustup, r=Manishearth
Rustup to 5f9c044 Fixes fallout from https://github.com/rust-lang/rust/pull/62091/files changelog: none
2 parents f0edfab + e3619a6 commit e3cb40e

13 files changed

+29
-41
lines changed

clippy_lints/src/escape.rs

+4-4
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

+2-2
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/functions.rs

+1-5
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

+4-4
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

+1-1
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

+1-1
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

+3-7
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

+3-3
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

+1-1
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
}

clippy_lints/src/suspicious_trait_impl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SuspiciousImpl {
6565
}
6666
// Check if the binary expression is part of another bi/unary expression
6767
// as a child node
68-
let mut parent_expr = cx.tcx.hir().get_parent_node_by_hir_id(expr.hir_id);
68+
let mut parent_expr = cx.tcx.hir().get_parent_node(expr.hir_id);
6969
while parent_expr != hir::CRATE_HIR_ID {
7070
if let hir::Node::Expr(e) = cx.tcx.hir().get(parent_expr) {
7171
match e.node {
@@ -75,7 +75,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SuspiciousImpl {
7575
_ => {},
7676
}
7777
}
78-
parent_expr = cx.tcx.hir().get_parent_node_by_hir_id(parent_expr);
78+
parent_expr = cx.tcx.hir().get_parent_node(parent_expr);
7979
}
8080
// as a parent node
8181
let mut visitor = BinaryExprVisitor { in_binary_expr: false };

clippy_lints/src/trivially_copy_pass_by_ref.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef {
179179
}
180180

181181
// Exclude non-inherent impls
182-
if let Some(Node::Item(item)) = cx
183-
.tcx
184-
.hir()
185-
.find_by_hir_id(cx.tcx.hir().get_parent_node_by_hir_id(hir_id))
186-
{
182+
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) {
187183
if matches!(item.node, ItemKind::Impl(_, _, _, _, Some(_), _, _) |
188184
ItemKind::Trait(..))
189185
{

clippy_lints/src/types.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ declare_lint_pass!(Types => [BOX_VEC, VEC_BOX, OPTION_OPTION, LINKEDLIST, BORROW
168168
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Types {
169169
fn check_fn(&mut self, cx: &LateContext<'_, '_>, _: FnKind<'_>, decl: &FnDecl, _: &Body, _: Span, id: HirId) {
170170
// Skip trait implementations; see issue #605.
171-
if let Some(hir::Node::Item(item)) = cx.tcx.hir().find_by_hir_id(cx.tcx.hir().get_parent_item(id)) {
171+
if let Some(hir::Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_item(id)) {
172172
if let ItemKind::Impl(_, _, _, _, Some(..), _, _) = item.node {
173173
return;
174174
}
@@ -585,7 +585,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnitArg {
585585
}
586586
if_chain! {
587587
let map = &cx.tcx.hir();
588-
let opt_parent_node = map.find_by_hir_id(map.get_parent_node_by_hir_id(expr.hir_id));
588+
let opt_parent_node = map.find(map.get_parent_node(expr.hir_id));
589589
if let Some(hir::Node::Expr(parent_expr)) = opt_parent_node;
590590
if is_questionmark_desugar_marked_call(parent_expr);
591591
then {

clippy_lints/src/utils/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ pub fn is_entrypoint_fn(cx: &LateContext<'_, '_>, def_id: DefId) -> bool {
404404
/// Gets the name of the item the expression is in, if available.
405405
pub fn get_item_name(cx: &LateContext<'_, '_>, expr: &Expr) -> Option<Name> {
406406
let parent_id = cx.tcx.hir().get_parent_item(expr.hir_id);
407-
match cx.tcx.hir().find_by_hir_id(parent_id) {
407+
match cx.tcx.hir().find(parent_id) {
408408
Some(Node::Item(&Item { ref ident, .. })) => Some(ident.name),
409409
Some(Node::TraitItem(&TraitItem { ident, .. })) | Some(Node::ImplItem(&ImplItem { ident, .. })) => {
410410
Some(ident.name)
@@ -592,11 +592,11 @@ fn trim_multiline_inner(s: Cow<'_, str>, ignore_first: bool, ch: char) -> Cow<'_
592592
pub fn get_parent_expr<'c>(cx: &'c LateContext<'_, '_>, e: &Expr) -> Option<&'c Expr> {
593593
let map = &cx.tcx.hir();
594594
let hir_id = e.hir_id;
595-
let parent_id = map.get_parent_node_by_hir_id(hir_id);
595+
let parent_id = map.get_parent_node(hir_id);
596596
if hir_id == parent_id {
597597
return None;
598598
}
599-
map.find_by_hir_id(parent_id).and_then(|node| {
599+
map.find(parent_id).and_then(|node| {
600600
if let Node::Expr(parent) = node {
601601
Some(parent)
602602
} else {
@@ -609,7 +609,7 @@ pub fn get_enclosing_block<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, hir_id: HirId)
609609
let map = &cx.tcx.hir();
610610
let enclosing_node = map
611611
.get_enclosing_scope(hir_id)
612-
.and_then(|enclosing_id| map.find_by_hir_id(enclosing_id));
612+
.and_then(|enclosing_id| map.find(enclosing_id));
613613
if let Some(node) = enclosing_node {
614614
match node {
615615
Node::Block(block) => Some(block),

0 commit comments

Comments
 (0)