find_by_hir_id -> find
This commit is contained in:
@@ -63,7 +63,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxedLocal {
|
|||||||
) {
|
) {
|
||||||
// If the method is an impl for a trait, don't warn.
|
// If the method is an impl for a trait, don't warn.
|
||||||
let parent_id = cx.tcx.hir().get_parent_item(hir_id);
|
let parent_id = cx.tcx.hir().get_parent_item(hir_id);
|
||||||
let parent_node = cx.tcx.hir().find_by_hir_id(parent_id);
|
let parent_node = cx.tcx.hir().find(parent_id);
|
||||||
|
|
||||||
if let Some(Node::Item(item)) = parent_node {
|
if let Some(Node::Item(item)) = parent_node {
|
||||||
if let ItemKind::Impl(_, _, _, _, Some(..), _, _) = item.node {
|
if let ItemKind::Impl(_, _, _, _, Some(..), _, _) = item.node {
|
||||||
@@ -115,7 +115,7 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
|
|||||||
let map = &self.cx.tcx.hir();
|
let map = &self.cx.tcx.hir();
|
||||||
if map.is_argument(map.hir_to_node_id(consume_pat.hir_id)) {
|
if map.is_argument(map.hir_to_node_id(consume_pat.hir_id)) {
|
||||||
// Skip closure arguments
|
// Skip closure arguments
|
||||||
if let Some(Node::Expr(..)) = map.find_by_hir_id(map.get_parent_node(consume_pat.hir_id)) {
|
if let Some(Node::Expr(..)) = map.find(map.get_parent_node(consume_pat.hir_id)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if is_non_trait_box(cmt.ty) && !self.is_large_box(cmt.ty) {
|
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> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if let Categorization::Rvalue(..) = cmt.cat {
|
if let Categorization::Rvalue(..) = cmt.cat {
|
||||||
if let Some(Node::Stmt(st)) = map.find_by_hir_id(map.get_parent_node(cmt.hir_id)) {
|
if let Some(Node::Stmt(st)) = map.find(map.get_parent_node(cmt.hir_id)) {
|
||||||
if let StmtKind::Local(ref loc) = st.node {
|
if let StmtKind::Local(ref loc) = st.node {
|
||||||
if let Some(ref ex) = loc.init {
|
if let Some(ref ex) = loc.init {
|
||||||
if let ExprKind::Box(..) = ex.node {
|
if let ExprKind::Box(..) = ex.node {
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ fn check_for_unsequenced_reads(vis: &mut ReadVisitor<'_, '_>) {
|
|||||||
if parent_id == cur_id {
|
if parent_id == cur_id {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
let parent_node = match map.find_by_hir_id(parent_id) {
|
let parent_node = match map.find(parent_id) {
|
||||||
Some(parent) => parent,
|
Some(parent) => parent,
|
||||||
None => break,
|
None => break,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
|
|||||||
let is_impl = if let Some(hir::Node::Item(item)) = cx
|
let is_impl = if let Some(hir::Node::Item(item)) = cx
|
||||||
.tcx
|
.tcx
|
||||||
.hir()
|
.hir()
|
||||||
.find_by_hir_id(cx.tcx.hir().get_parent_node(hir_id))
|
.find(cx.tcx.hir().get_parent_node(hir_id))
|
||||||
{
|
{
|
||||||
matches!(item.node, hir::ItemKind::Impl(_, _, _, _, Some(_), _, _))
|
matches!(item.node, hir::ItemKind::Impl(_, _, _, _, Some(_), _, _))
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2219,7 +2219,7 @@ fn is_nested(cx: &LateContext<'_, '_>, match_expr: &Expr, iter_expr: &Expr) -> b
|
|||||||
if_chain! {
|
if_chain! {
|
||||||
if let Some(loop_block) = get_enclosing_block(cx, match_expr.hir_id);
|
if let Some(loop_block) = get_enclosing_block(cx, match_expr.hir_id);
|
||||||
let parent_node = cx.tcx.hir().get_parent_node(loop_block.hir_id);
|
let parent_node = cx.tcx.hir().get_parent_node(loop_block.hir_id);
|
||||||
if let Some(Node::Expr(loop_expr)) = cx.tcx.hir().find_by_hir_id(parent_node);
|
if let Some(Node::Expr(loop_expr)) = cx.tcx.hir().find(parent_node);
|
||||||
then {
|
then {
|
||||||
return is_loop_nested(cx, loop_expr, iter_expr)
|
return is_loop_nested(cx, loop_expr, iter_expr)
|
||||||
}
|
}
|
||||||
@@ -2239,7 +2239,7 @@ fn is_loop_nested(cx: &LateContext<'_, '_>, loop_expr: &Expr, iter_expr: &Expr)
|
|||||||
if parent == id {
|
if parent == id {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
match cx.tcx.hir().find_by_hir_id(parent) {
|
match cx.tcx.hir().find(parent) {
|
||||||
Some(Node::Expr(expr)) => match expr.node {
|
Some(Node::Expr(expr)) => match expr.node {
|
||||||
ExprKind::Loop(..) | ExprKind::While(..) => {
|
ExprKind::Loop(..) | ExprKind::While(..) => {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
|
|||||||
if let Some(Node::Item(item)) = cx
|
if let Some(Node::Item(item)) = cx
|
||||||
.tcx
|
.tcx
|
||||||
.hir()
|
.hir()
|
||||||
.find_by_hir_id(cx.tcx.hir().get_parent_node(hir_id))
|
.find(cx.tcx.hir().get_parent_node(hir_id))
|
||||||
{
|
{
|
||||||
if matches!(item.node, ItemKind::Impl(_, _, _, _, Some(_), _, _) |
|
if matches!(item.node, ItemKind::Impl(_, _, _, _, Some(_), _, _) |
|
||||||
ItemKind::Trait(..))
|
ItemKind::Trait(..))
|
||||||
@@ -364,7 +364,7 @@ impl<'a, 'tcx> MovedVariablesCtxt<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
id = parent;
|
id = parent;
|
||||||
|
|
||||||
if let Some(node) = self.cx.tcx.hir().find_by_hir_id(id) {
|
if let Some(node) = self.cx.tcx.hir().find(id) {
|
||||||
match node {
|
match node {
|
||||||
Node::Expr(e) => {
|
Node::Expr(e) => {
|
||||||
// `match` and `if let`
|
// `match` and `if let`
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCopyConst {
|
|||||||
if parent_id == cur_expr.hir_id {
|
if parent_id == cur_expr.hir_id {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if let Some(Node::Expr(parent_expr)) = cx.tcx.hir().find_by_hir_id(parent_id) {
|
if let Some(Node::Expr(parent_expr)) = cx.tcx.hir().find(parent_id) {
|
||||||
match &parent_expr.node {
|
match &parent_expr.node {
|
||||||
ExprKind::AddrOf(..) => {
|
ExprKind::AddrOf(..) => {
|
||||||
// `&e` => `e` must be referenced.
|
// `&e` => `e` must be referenced.
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Ptr {
|
|||||||
fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
|
fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
|
||||||
if let ImplItemKind::Method(ref sig, body_id) = item.node {
|
if let ImplItemKind::Method(ref sig, body_id) = item.node {
|
||||||
let parent_item = cx.tcx.hir().get_parent_item(item.hir_id);
|
let parent_item = cx.tcx.hir().get_parent_item(item.hir_id);
|
||||||
if let Some(Node::Item(it)) = cx.tcx.hir().find_by_hir_id(parent_item) {
|
if let Some(Node::Item(it)) = cx.tcx.hir().find(parent_item) {
|
||||||
if let ItemKind::Impl(_, _, _, _, Some(_), _, _) = it.node {
|
if let ItemKind::Impl(_, _, _, _, Some(_), _, _) = it.node {
|
||||||
return; // ignore trait impls
|
return; // ignore trait impls
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef {
|
|||||||
if let Some(Node::Item(item)) = cx
|
if let Some(Node::Item(item)) = cx
|
||||||
.tcx
|
.tcx
|
||||||
.hir()
|
.hir()
|
||||||
.find_by_hir_id(cx.tcx.hir().get_parent_node(hir_id))
|
.find(cx.tcx.hir().get_parent_node(hir_id))
|
||||||
{
|
{
|
||||||
if matches!(item.node, ItemKind::Impl(_, _, _, _, Some(_), _, _) |
|
if matches!(item.node, ItemKind::Impl(_, _, _, _, Some(_), _, _) |
|
||||||
ItemKind::Trait(..))
|
ItemKind::Trait(..))
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ declare_lint_pass!(Types => [BOX_VEC, VEC_BOX, OPTION_OPTION, LINKEDLIST, BORROW
|
|||||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Types {
|
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Types {
|
||||||
fn check_fn(&mut self, cx: &LateContext<'_, '_>, _: FnKind<'_>, decl: &FnDecl, _: &Body, _: Span, id: HirId) {
|
fn check_fn(&mut self, cx: &LateContext<'_, '_>, _: FnKind<'_>, decl: &FnDecl, _: &Body, _: Span, id: HirId) {
|
||||||
// Skip trait implementations; see issue #605.
|
// Skip trait implementations; see issue #605.
|
||||||
if let Some(hir::Node::Item(item)) = cx.tcx.hir().find_by_hir_id(cx.tcx.hir().get_parent_item(id)) {
|
if let Some(hir::Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_item(id)) {
|
||||||
if let ItemKind::Impl(_, _, _, _, Some(..), _, _) = item.node {
|
if let ItemKind::Impl(_, _, _, _, Some(..), _, _) = item.node {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -585,7 +585,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnitArg {
|
|||||||
}
|
}
|
||||||
if_chain! {
|
if_chain! {
|
||||||
let map = &cx.tcx.hir();
|
let map = &cx.tcx.hir();
|
||||||
let opt_parent_node = map.find_by_hir_id(map.get_parent_node(expr.hir_id));
|
let opt_parent_node = map.find(map.get_parent_node(expr.hir_id));
|
||||||
if let Some(hir::Node::Expr(parent_expr)) = opt_parent_node;
|
if let Some(hir::Node::Expr(parent_expr)) = opt_parent_node;
|
||||||
if is_questionmark_desugar_marked_call(parent_expr);
|
if is_questionmark_desugar_marked_call(parent_expr);
|
||||||
then {
|
then {
|
||||||
|
|||||||
@@ -404,7 +404,7 @@ pub fn is_entrypoint_fn(cx: &LateContext<'_, '_>, def_id: DefId) -> bool {
|
|||||||
/// Gets the name of the item the expression is in, if available.
|
/// Gets the name of the item the expression is in, if available.
|
||||||
pub fn get_item_name(cx: &LateContext<'_, '_>, expr: &Expr) -> Option<Name> {
|
pub fn get_item_name(cx: &LateContext<'_, '_>, expr: &Expr) -> Option<Name> {
|
||||||
let parent_id = cx.tcx.hir().get_parent_item(expr.hir_id);
|
let parent_id = cx.tcx.hir().get_parent_item(expr.hir_id);
|
||||||
match cx.tcx.hir().find_by_hir_id(parent_id) {
|
match cx.tcx.hir().find(parent_id) {
|
||||||
Some(Node::Item(&Item { ref ident, .. })) => Some(ident.name),
|
Some(Node::Item(&Item { ref ident, .. })) => Some(ident.name),
|
||||||
Some(Node::TraitItem(&TraitItem { ident, .. })) | Some(Node::ImplItem(&ImplItem { ident, .. })) => {
|
Some(Node::TraitItem(&TraitItem { ident, .. })) | Some(Node::ImplItem(&ImplItem { ident, .. })) => {
|
||||||
Some(ident.name)
|
Some(ident.name)
|
||||||
@@ -596,7 +596,7 @@ pub fn get_parent_expr<'c>(cx: &'c LateContext<'_, '_>, e: &Expr) -> Option<&'c
|
|||||||
if hir_id == parent_id {
|
if hir_id == parent_id {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
map.find_by_hir_id(parent_id).and_then(|node| {
|
map.find(parent_id).and_then(|node| {
|
||||||
if let Node::Expr(parent) = node {
|
if let Node::Expr(parent) = node {
|
||||||
Some(parent)
|
Some(parent)
|
||||||
} else {
|
} else {
|
||||||
@@ -609,7 +609,7 @@ pub fn get_enclosing_block<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, hir_id: HirId)
|
|||||||
let map = &cx.tcx.hir();
|
let map = &cx.tcx.hir();
|
||||||
let enclosing_node = map
|
let enclosing_node = map
|
||||||
.get_enclosing_scope(hir_id)
|
.get_enclosing_scope(hir_id)
|
||||||
.and_then(|enclosing_id| map.find_by_hir_id(enclosing_id));
|
.and_then(|enclosing_id| map.find(enclosing_id));
|
||||||
if let Some(node) = enclosing_node {
|
if let Some(node) = enclosing_node {
|
||||||
match node {
|
match node {
|
||||||
Node::Block(block) => Some(block),
|
Node::Block(block) => Some(block),
|
||||||
|
|||||||
Reference in New Issue
Block a user