Skip to content

Commit d744dcd

Browse files
committed
find_by_hir_id -> find
1 parent c47a7e4 commit d744dcd

10 files changed

+17
-17
lines changed

clippy_lints/src/escape.rs

+3-3
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 {
@@ -115,7 +115,7 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
115115
let map = &self.cx.tcx.hir();
116116
if map.is_argument(map.hir_to_node_id(consume_pat.hir_id)) {
117117
// Skip closure arguments
118-
if let Some(Node::Expr(..)) = map.find_by_hir_id(map.get_parent_node(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(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

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ fn check_for_unsequenced_reads(vis: &mut ReadVisitor<'_, '_>) {
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-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
110110
let is_impl = if let Some(hir::Node::Item(item)) = cx
111111
.tcx
112112
.hir()
113-
.find_by_hir_id(cx.tcx.hir().get_parent_node(hir_id))
113+
.find(cx.tcx.hir().get_parent_node(hir_id))
114114
{
115115
matches!(item.node, hir::ItemKind::Impl(_, _, _, _, Some(_), _, _))
116116
} else {

clippy_lints/src/loops.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2219,7 +2219,7 @@ fn is_nested(cx: &LateContext<'_, '_>, match_expr: &Expr, iter_expr: &Expr) -> b
22192219
if_chain! {
22202220
if let Some(loop_block) = get_enclosing_block(cx, match_expr.hir_id);
22212221
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_by_hir_id(parent_node);
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
}
@@ -2239,7 +2239,7 @@ fn is_loop_nested(cx: &LateContext<'_, '_>, loop_expr: &Expr, iter_expr: &Expr)
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/needless_pass_by_value.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
9191
if let Some(Node::Item(item)) = cx
9292
.tcx
9393
.hir()
94-
.find_by_hir_id(cx.tcx.hir().get_parent_node(hir_id))
94+
.find(cx.tcx.hir().get_parent_node(hir_id))
9595
{
9696
if matches!(item.node, ItemKind::Impl(_, _, _, _, Some(_), _, _) |
9797
ItemKind::Trait(..))
@@ -364,7 +364,7 @@ impl<'a, 'tcx> MovedVariablesCtxt<'a, 'tcx> {
364364
}
365365
id = parent;
366366

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

clippy_lints/src/non_copy_const.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCopyConst {
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/trivially_copy_pass_by_ref.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef {
182182
if let Some(Node::Item(item)) = cx
183183
.tcx
184184
.hir()
185-
.find_by_hir_id(cx.tcx.hir().get_parent_node(hir_id))
185+
.find(cx.tcx.hir().get_parent_node(hir_id))
186186
{
187187
if matches!(item.node, ItemKind::Impl(_, _, _, _, Some(_), _, _) |
188188
ItemKind::Trait(..))

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(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

+3-3
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)
@@ -596,7 +596,7 @@ pub fn get_parent_expr<'c>(cx: &'c LateContext<'_, '_>, e: &Expr) -> Option<&'c
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)