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:
bors 2019-06-22 08:42:09 +00:00
commit 6f82ea53c5
5 changed files with 6 additions and 6 deletions

View file

@ -1647,7 +1647,7 @@ fn check_for_mutability(cx: &LateContext<'_, '_>, bound: &Expr) -> Option<HirId>
then {
let res = cx.tables.qpath_res(qpath, bound.hir_id);
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 let Node::Binding(pat) = node_str;
if let PatKind::Binding(bind_ann, ..) = pat.node;

View file

@ -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)));
} else {
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 {
// &*x is a nop, &x.clone() is not
hir::ExprKind::AddrOf(..) |

View file

@ -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 {
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 higher::if_block(&e).is_some() {

View file

@ -67,7 +67,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SuspiciousImpl {
// as a child node
let mut parent_expr = cx.tcx.hir().get_parent_node_by_hir_id(expr.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 {
hir::ExprKind::Binary(..)
| hir::ExprKind::Unary(hir::UnOp::UnNot, _)

View file

@ -66,7 +66,7 @@ pub fn differing_macro_contexts(lhs: Span, rhs: Span) -> bool {
/// ```
pub fn in_constant(cx: &LateContext<'_, '_>, id: HirId) -> bool {
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: 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);
if_chain! {
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;
then { return trait_ref.as_ref(); }
}