mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-17 06:28:42 +00:00
Auto merge of #4227 - lzutao:node-pruning, r=flip1995
Fix fallout cause NodeId pruning Rustup rust-lang/rust#61984 changelog: none
This commit is contained in:
commit
6f82ea53c5
5 changed files with 6 additions and 6 deletions
|
@ -1647,7 +1647,7 @@ fn check_for_mutability(cx: &LateContext<'_, '_>, bound: &Expr) -> Option<HirId>
|
||||||
then {
|
then {
|
||||||
let res = cx.tables.qpath_res(qpath, bound.hir_id);
|
let res = cx.tables.qpath_res(qpath, bound.hir_id);
|
||||||
if let Res::Local(node_id) = res {
|
if let Res::Local(node_id) = res {
|
||||||
let node_str = cx.tcx.hir().get_by_hir_id(node_id);
|
let node_str = cx.tcx.hir().get(node_id);
|
||||||
if_chain! {
|
if_chain! {
|
||||||
if let Node::Binding(pat) = node_str;
|
if let Node::Binding(pat) = node_str;
|
||||||
if let PatKind::Binding(bind_ann, ..) = pat.node;
|
if let PatKind::Binding(bind_ann, ..) = pat.node;
|
||||||
|
|
|
@ -1424,7 +1424,7 @@ fn lint_clone_on_copy(cx: &LateContext<'_, '_>, expr: &hir::Expr, arg: &hir::Exp
|
||||||
snip = Some(("try removing the `clone` call", format!("{}", snippet)));
|
snip = Some(("try removing the `clone` call", format!("{}", snippet)));
|
||||||
} else {
|
} else {
|
||||||
let parent = cx.tcx.hir().get_parent_node_by_hir_id(expr.hir_id);
|
let parent = cx.tcx.hir().get_parent_node_by_hir_id(expr.hir_id);
|
||||||
match cx.tcx.hir().get_by_hir_id(parent) {
|
match cx.tcx.hir().get(parent) {
|
||||||
hir::Node::Expr(parent) => match parent.node {
|
hir::Node::Expr(parent) => match parent.node {
|
||||||
// &*x is a nop, &x.clone() is not
|
// &*x is a nop, &x.clone() is not
|
||||||
hir::ExprKind::AddrOf(..) |
|
hir::ExprKind::AddrOf(..) |
|
||||||
|
|
|
@ -116,7 +116,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBool {
|
||||||
|
|
||||||
fn parent_node_is_if_expr<'a, 'b>(expr: &Expr, cx: &LateContext<'a, 'b>) -> bool {
|
fn parent_node_is_if_expr<'a, 'b>(expr: &Expr, cx: &LateContext<'a, 'b>) -> bool {
|
||||||
let parent_id = cx.tcx.hir().get_parent_node_by_hir_id(expr.hir_id);
|
let parent_id = cx.tcx.hir().get_parent_node_by_hir_id(expr.hir_id);
|
||||||
let parent_node = cx.tcx.hir().get_by_hir_id(parent_id);
|
let parent_node = cx.tcx.hir().get(parent_id);
|
||||||
|
|
||||||
if let rustc::hir::Node::Expr(e) = parent_node {
|
if let rustc::hir::Node::Expr(e) = parent_node {
|
||||||
if higher::if_block(&e).is_some() {
|
if higher::if_block(&e).is_some() {
|
||||||
|
|
|
@ -67,7 +67,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SuspiciousImpl {
|
||||||
// as a child node
|
// as a child node
|
||||||
let mut parent_expr = cx.tcx.hir().get_parent_node_by_hir_id(expr.hir_id);
|
let mut parent_expr = cx.tcx.hir().get_parent_node_by_hir_id(expr.hir_id);
|
||||||
while parent_expr != hir::CRATE_HIR_ID {
|
while parent_expr != hir::CRATE_HIR_ID {
|
||||||
if let hir::Node::Expr(e) = cx.tcx.hir().get_by_hir_id(parent_expr) {
|
if let hir::Node::Expr(e) = cx.tcx.hir().get(parent_expr) {
|
||||||
match e.node {
|
match e.node {
|
||||||
hir::ExprKind::Binary(..)
|
hir::ExprKind::Binary(..)
|
||||||
| hir::ExprKind::Unary(hir::UnOp::UnNot, _)
|
| hir::ExprKind::Unary(hir::UnOp::UnNot, _)
|
||||||
|
|
|
@ -66,7 +66,7 @@ pub fn differing_macro_contexts(lhs: Span, rhs: Span) -> bool {
|
||||||
/// ```
|
/// ```
|
||||||
pub fn in_constant(cx: &LateContext<'_, '_>, id: HirId) -> bool {
|
pub fn in_constant(cx: &LateContext<'_, '_>, id: HirId) -> bool {
|
||||||
let parent_id = cx.tcx.hir().get_parent_item(id);
|
let parent_id = cx.tcx.hir().get_parent_item(id);
|
||||||
match cx.tcx.hir().get_by_hir_id(parent_id) {
|
match cx.tcx.hir().get(parent_id) {
|
||||||
Node::Item(&Item {
|
Node::Item(&Item {
|
||||||
node: ItemKind::Const(..),
|
node: ItemKind::Const(..),
|
||||||
..
|
..
|
||||||
|
@ -320,7 +320,7 @@ pub fn trait_ref_of_method<'tcx>(cx: &LateContext<'_, 'tcx>, hir_id: HirId) -> O
|
||||||
let parent_impl = cx.tcx.hir().get_parent_item(hir_id);
|
let parent_impl = cx.tcx.hir().get_parent_item(hir_id);
|
||||||
if_chain! {
|
if_chain! {
|
||||||
if parent_impl != hir::CRATE_HIR_ID;
|
if parent_impl != hir::CRATE_HIR_ID;
|
||||||
if let hir::Node::Item(item) = cx.tcx.hir().get_by_hir_id(parent_impl);
|
if let hir::Node::Item(item) = cx.tcx.hir().get(parent_impl);
|
||||||
if let hir::ItemKind::Impl(_, _, _, _, trait_ref, _, _) = &item.node;
|
if let hir::ItemKind::Impl(_, _, _, _, trait_ref, _, _) = &item.node;
|
||||||
then { return trait_ref.as_ref(); }
|
then { return trait_ref.as_ref(); }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue