1
Fork 0

align with rust-lang/rust/#58992

This commit is contained in:
ljedrz 2019-03-07 21:51:05 +01:00
parent 77ba5045d7
commit 5d78250c75
11 changed files with 42 additions and 46 deletions

View file

@ -182,7 +182,7 @@ fn get_type_name(cx: &LateContext<'_, '_>, kind: &ty::TyKind<'_>) -> String {
fn compare_inputs(closure_inputs: &mut dyn Iterator<Item = &Arg>, call_args: &mut dyn Iterator<Item = &Expr>) -> bool { fn compare_inputs(closure_inputs: &mut dyn Iterator<Item = &Arg>, call_args: &mut dyn Iterator<Item = &Expr>) -> bool {
for (closure_input, function_arg) in closure_inputs.zip(call_args) { for (closure_input, function_arg) in closure_inputs.zip(call_args) {
if let PatKind::Binding(_, _, _, ident, _) = closure_input.pat.node { if let PatKind::Binding(_, _, ident, _) = closure_input.pat.node {
// XXXManishearth Should I be checking the binding mode here? // XXXManishearth Should I be checking the binding mode here?
if let ExprKind::Path(QPath::Resolved(None, ref p)) = function_arg.node { if let ExprKind::Path(QPath::Resolved(None, ref p)) = function_arg.node {
if p.segments.len() != 1 { if p.segments.len() != 1 {

View file

@ -8,7 +8,6 @@ use rustc::ty;
use rustc::{declare_tool_lint, lint_array}; use rustc::{declare_tool_lint, lint_array};
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_target::spec::abi::Abi; use rustc_target::spec::abi::Abi;
use syntax::ast;
use syntax::source_map::Span; use syntax::source_map::Span;
declare_clippy_lint! { declare_clippy_lint! {
@ -278,8 +277,8 @@ impl<'a, 'tcx> Functions {
} }
} }
fn raw_ptr_arg(arg: &hir::Arg, ty: &hir::Ty) -> Option<ast::NodeId> { fn raw_ptr_arg(arg: &hir::Arg, ty: &hir::Ty) -> Option<hir::HirId> {
if let (&hir::PatKind::Binding(_, id, _, _, _), &hir::TyKind::Ptr(_)) = (&arg.pat.node, &ty.node) { if let (&hir::PatKind::Binding(_, id, _, _), &hir::TyKind::Ptr(_)) = (&arg.pat.node, &ty.node) {
Some(id) Some(id)
} else { } else {
None None
@ -288,7 +287,7 @@ fn raw_ptr_arg(arg: &hir::Arg, ty: &hir::Ty) -> Option<ast::NodeId> {
struct DerefVisitor<'a, 'tcx: 'a> { struct DerefVisitor<'a, 'tcx: 'a> {
cx: &'a LateContext<'a, 'tcx>, cx: &'a LateContext<'a, 'tcx>,
ptrs: FxHashSet<ast::NodeId>, ptrs: FxHashSet<hir::HirId>,
tables: &'a ty::TypeckTables<'tcx>, tables: &'a ty::TypeckTables<'tcx>,
} }
@ -329,7 +328,7 @@ impl<'a, 'tcx: 'a> DerefVisitor<'a, 'tcx> {
fn check_arg(&self, ptr: &hir::Expr) { fn check_arg(&self, ptr: &hir::Expr) {
if let hir::ExprKind::Path(ref qpath) = ptr.node { if let hir::ExprKind::Path(ref qpath) = ptr.node {
if let Def::Local(id) = self.cx.tables.qpath_def(qpath, ptr.hir_id) { if let Def::Local(id) = self.cx.tables.qpath_def(qpath, ptr.hir_id) {
if self.ptrs.contains(&id) { if self.ptrs.contains(&self.cx.tcx.hir().node_to_hir_id(id)) {
span_lint( span_lint(
self.cx, self.cx,
NOT_UNSAFE_PTR_ARG_DEREF, NOT_UNSAFE_PTR_ARG_DEREF,

View file

@ -6,7 +6,6 @@ use rustc::hir::BindingAnnotation;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
use rustc::{declare_tool_lint, lint_array}; use rustc::{declare_tool_lint, lint_array};
use rustc_errors::Applicability; use rustc_errors::Applicability;
use syntax::ast;
declare_clippy_lint! { declare_clippy_lint! {
/// **What it does:** Checks for variable declarations immediately followed by a /// **What it does:** Checks for variable declarations immediately followed by a
@ -73,7 +72,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq {
if_chain! { if_chain! {
if let Some(expr) = it.peek(); if let Some(expr) = it.peek();
if let hir::StmtKind::Local(ref local) = stmt.node; if let hir::StmtKind::Local(ref local) = stmt.node;
if let hir::PatKind::Binding(mode, canonical_id, _, ident, None) = local.pat.node; if let hir::PatKind::Binding(mode, canonical_id, ident, None) = local.pat.node;
if let hir::StmtKind::Expr(ref if_) = expr.node; if let hir::StmtKind::Expr(ref if_) = expr.node;
if let hir::ExprKind::If(ref cond, ref then, ref else_) = if_.node; if let hir::ExprKind::If(ref cond, ref then, ref else_) = if_.node;
if !used_in_expr(cx, canonical_id, cond); if !used_in_expr(cx, canonical_id, cond);
@ -142,7 +141,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq {
struct UsedVisitor<'a, 'tcx: 'a> { struct UsedVisitor<'a, 'tcx: 'a> {
cx: &'a LateContext<'a, 'tcx>, cx: &'a LateContext<'a, 'tcx>,
id: ast::NodeId, id: hir::HirId,
used: bool, used: bool,
} }
@ -151,7 +150,7 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for UsedVisitor<'a, 'tcx> {
if_chain! { if_chain! {
if let hir::ExprKind::Path(ref qpath) = expr.node; if let hir::ExprKind::Path(ref qpath) = expr.node;
if let Def::Local(local_id) = self.cx.tables.qpath_def(qpath, expr.hir_id); if let Def::Local(local_id) = self.cx.tables.qpath_def(qpath, expr.hir_id);
if self.id == local_id; if self.id == self.cx.tcx.hir().node_to_hir_id(local_id);
then { then {
self.used = true; self.used = true;
return; return;
@ -166,7 +165,7 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for UsedVisitor<'a, 'tcx> {
fn check_assign<'a, 'tcx>( fn check_assign<'a, 'tcx>(
cx: &LateContext<'a, 'tcx>, cx: &LateContext<'a, 'tcx>,
decl: ast::NodeId, decl: hir::HirId,
block: &'tcx hir::Block, block: &'tcx hir::Block,
) -> Option<&'tcx hir::Expr> { ) -> Option<&'tcx hir::Expr> {
if_chain! { if_chain! {
@ -176,7 +175,7 @@ fn check_assign<'a, 'tcx>(
if let hir::ExprKind::Assign(ref var, ref value) = expr.node; if let hir::ExprKind::Assign(ref var, ref value) = expr.node;
if let hir::ExprKind::Path(ref qpath) = var.node; if let hir::ExprKind::Path(ref qpath) = var.node;
if let Def::Local(local_id) = cx.tables.qpath_def(qpath, var.hir_id); if let Def::Local(local_id) = cx.tables.qpath_def(qpath, var.hir_id);
if decl == local_id; if decl == cx.tcx.hir().node_to_hir_id(local_id);
then { then {
let mut v = UsedVisitor { let mut v = UsedVisitor {
cx, cx,
@ -199,7 +198,7 @@ fn check_assign<'a, 'tcx>(
None None
} }
fn used_in_expr<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, id: ast::NodeId, expr: &'tcx hir::Expr) -> bool { fn used_in_expr<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, id: hir::HirId, expr: &'tcx hir::Expr) -> bool {
let mut v = UsedVisitor { cx, id, used: false }; let mut v = UsedVisitor { cx, id, used: false };
hir::intravisit::walk_expr(&mut v, expr); hir::intravisit::walk_expr(&mut v, expr);
v.used v.used

View file

@ -272,7 +272,7 @@ pub mod zero_div_zero;
pub use crate::utils::conf::Conf; pub use crate::utils::conf::Conf;
mod reexport { mod reexport {
crate use syntax::ast::{Name, NodeId}; crate use syntax::ast::Name;
} }
/// Register all pre expansion lints /// Register all pre expansion lints

View file

@ -486,8 +486,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
// check for never_loop // check for never_loop
match expr.node { match expr.node {
ExprKind::While(_, ref block, _) | ExprKind::Loop(ref block, _, _) => { ExprKind::While(_, ref block, _) | ExprKind::Loop(ref block, _, _) => {
let node_id = cx.tcx.hir().hir_to_node_id(expr.hir_id); match never_loop_block(block, expr.hir_id) {
match never_loop_block(block, node_id) {
NeverLoopResult::AlwaysBreak => { NeverLoopResult::AlwaysBreak => {
span_lint(cx, NEVER_LOOP, expr.span, "this loop never actually loops") span_lint(cx, NEVER_LOOP, expr.span, "this loop never actually loops")
}, },
@ -664,7 +663,7 @@ fn combine_branches(b1: NeverLoopResult, b2: NeverLoopResult) -> NeverLoopResult
} }
} }
fn never_loop_block(block: &Block, main_loop_id: NodeId) -> NeverLoopResult { fn never_loop_block(block: &Block, main_loop_id: HirId) -> NeverLoopResult {
let stmts = block.stmts.iter().map(stmt_to_expr); let stmts = block.stmts.iter().map(stmt_to_expr);
let expr = once(block.expr.as_ref().map(|p| &**p)); let expr = once(block.expr.as_ref().map(|p| &**p));
let mut iter = stmts.chain(expr).filter_map(|e| e); let mut iter = stmts.chain(expr).filter_map(|e| e);
@ -679,7 +678,7 @@ fn stmt_to_expr(stmt: &Stmt) -> Option<&Expr> {
} }
} }
fn never_loop_expr(expr: &Expr, main_loop_id: NodeId) -> NeverLoopResult { fn never_loop_expr(expr: &Expr, main_loop_id: HirId) -> NeverLoopResult {
match expr.node { match expr.node {
ExprKind::Box(ref e) ExprKind::Box(ref e)
| ExprKind::Unary(_, ref e) | ExprKind::Unary(_, ref e)
@ -753,17 +752,17 @@ fn never_loop_expr(expr: &Expr, main_loop_id: NodeId) -> NeverLoopResult {
} }
} }
fn never_loop_expr_seq<'a, T: Iterator<Item = &'a Expr>>(es: &mut T, main_loop_id: NodeId) -> NeverLoopResult { fn never_loop_expr_seq<'a, T: Iterator<Item = &'a Expr>>(es: &mut T, main_loop_id: HirId) -> NeverLoopResult {
es.map(|e| never_loop_expr(e, main_loop_id)) es.map(|e| never_loop_expr(e, main_loop_id))
.fold(NeverLoopResult::Otherwise, combine_seq) .fold(NeverLoopResult::Otherwise, combine_seq)
} }
fn never_loop_expr_all<'a, T: Iterator<Item = &'a Expr>>(es: &mut T, main_loop_id: NodeId) -> NeverLoopResult { fn never_loop_expr_all<'a, T: Iterator<Item = &'a Expr>>(es: &mut T, main_loop_id: HirId) -> NeverLoopResult {
es.map(|e| never_loop_expr(e, main_loop_id)) es.map(|e| never_loop_expr(e, main_loop_id))
.fold(NeverLoopResult::Otherwise, combine_both) .fold(NeverLoopResult::Otherwise, combine_both)
} }
fn never_loop_expr_branch<'a, T: Iterator<Item = &'a Expr>>(e: &mut T, main_loop_id: NodeId) -> NeverLoopResult { fn never_loop_expr_branch<'a, T: Iterator<Item = &'a Expr>>(e: &mut T, main_loop_id: HirId) -> NeverLoopResult {
e.map(|e| never_loop_expr(e, main_loop_id)) e.map(|e| never_loop_expr(e, main_loop_id))
.fold(NeverLoopResult::AlwaysBreak, combine_branches) .fold(NeverLoopResult::AlwaysBreak, combine_branches)
} }
@ -784,14 +783,14 @@ fn check_for_loop<'a, 'tcx>(
detect_manual_memcpy(cx, pat, arg, body, expr); detect_manual_memcpy(cx, pat, arg, body, expr);
} }
fn same_var<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &Expr, var: ast::NodeId) -> bool { fn same_var<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &Expr, var: HirId) -> bool {
if_chain! { if_chain! {
if let ExprKind::Path(ref qpath) = expr.node; if let ExprKind::Path(ref qpath) = expr.node;
if let QPath::Resolved(None, ref path) = *qpath; if let QPath::Resolved(None, ref path) = *qpath;
if path.segments.len() == 1; if path.segments.len() == 1;
if let Def::Local(local_id) = cx.tables.qpath_def(qpath, expr.hir_id); if let Def::Local(local_id) = cx.tables.qpath_def(qpath, expr.hir_id);
// our variable! // our variable!
if local_id == var; if cx.tcx.hir().node_to_hir_id(local_id) == var;
then { then {
return true; return true;
} }
@ -833,8 +832,8 @@ fn is_slice_like<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'_>) -> bool {
is_slice || match_type(cx, ty, &paths::VEC) || match_type(cx, ty, &paths::VEC_DEQUE) is_slice || match_type(cx, ty, &paths::VEC) || match_type(cx, ty, &paths::VEC_DEQUE)
} }
fn get_fixed_offset_var<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &Expr, var: ast::NodeId) -> Option<FixedOffsetVar> { fn get_fixed_offset_var<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &Expr, var: HirId) -> Option<FixedOffsetVar> {
fn extract_offset<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, e: &Expr, var: ast::NodeId) -> Option<String> { fn extract_offset<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, e: &Expr, var: HirId) -> Option<String> {
match e.node { match e.node {
ExprKind::Lit(ref l) => match l.node { ExprKind::Lit(ref l) => match l.node {
ast::LitKind::Int(x, _ty) => Some(x.to_string()), ast::LitKind::Int(x, _ty) => Some(x.to_string()),
@ -889,7 +888,7 @@ fn get_fixed_offset_var<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &Expr, var:
fn fetch_cloned_fixed_offset_var<'a, 'tcx>( fn fetch_cloned_fixed_offset_var<'a, 'tcx>(
cx: &LateContext<'a, 'tcx>, cx: &LateContext<'a, 'tcx>,
expr: &Expr, expr: &Expr,
var: ast::NodeId, var: HirId,
) -> Option<FixedOffsetVar> { ) -> Option<FixedOffsetVar> {
if_chain! { if_chain! {
if let ExprKind::MethodCall(ref method, _, ref args) = expr.node; if let ExprKind::MethodCall(ref method, _, ref args) = expr.node;
@ -907,12 +906,12 @@ fn fetch_cloned_fixed_offset_var<'a, 'tcx>(
fn get_indexed_assignments<'a, 'tcx>( fn get_indexed_assignments<'a, 'tcx>(
cx: &LateContext<'a, 'tcx>, cx: &LateContext<'a, 'tcx>,
body: &Expr, body: &Expr,
var: ast::NodeId, var: HirId,
) -> Vec<(FixedOffsetVar, FixedOffsetVar)> { ) -> Vec<(FixedOffsetVar, FixedOffsetVar)> {
fn get_assignment<'a, 'tcx>( fn get_assignment<'a, 'tcx>(
cx: &LateContext<'a, 'tcx>, cx: &LateContext<'a, 'tcx>,
e: &Expr, e: &Expr,
var: ast::NodeId, var: HirId,
) -> Option<(FixedOffsetVar, FixedOffsetVar)> { ) -> Option<(FixedOffsetVar, FixedOffsetVar)> {
if let ExprKind::Assign(ref lhs, ref rhs) = e.node { if let ExprKind::Assign(ref lhs, ref rhs) = e.node {
match ( match (
@ -970,7 +969,7 @@ fn detect_manual_memcpy<'a, 'tcx>(
}) = higher::range(cx, arg) }) = higher::range(cx, arg)
{ {
// the var must be a single name // the var must be a single name
if let PatKind::Binding(_, canonical_id, _, _, _) = pat.node { if let PatKind::Binding(_, canonical_id, _, _) = pat.node {
let print_sum = |arg1: &Offset, arg2: &Offset| -> String { let print_sum = |arg1: &Offset, arg2: &Offset| -> String {
match (&arg1.value[..], arg1.negate, &arg2.value[..], arg2.negate) { match (&arg1.value[..], arg1.negate, &arg2.value[..], arg2.negate) {
("0", _, "0", _) => "".into(), ("0", _, "0", _) => "".into(),
@ -1087,7 +1086,7 @@ fn check_for_loop_range<'a, 'tcx>(
}) = higher::range(cx, arg) }) = higher::range(cx, arg)
{ {
// the var must be a single name // the var must be a single name
if let PatKind::Binding(_, canonical_id, _, ident, _) = pat.node { if let PatKind::Binding(_, canonical_id, ident, _) = pat.node {
let mut visitor = VarVisitor { let mut visitor = VarVisitor {
cx, cx,
var: canonical_id, var: canonical_id,
@ -1711,7 +1710,7 @@ impl<'tcx> Visitor<'tcx> for UsedVisitor {
struct LocalUsedVisitor<'a, 'tcx: 'a> { struct LocalUsedVisitor<'a, 'tcx: 'a> {
cx: &'a LateContext<'a, 'tcx>, cx: &'a LateContext<'a, 'tcx>,
local: ast::NodeId, local: HirId,
used: bool, used: bool,
} }
@ -1733,7 +1732,7 @@ struct VarVisitor<'a, 'tcx: 'a> {
/// context reference /// context reference
cx: &'a LateContext<'a, 'tcx>, cx: &'a LateContext<'a, 'tcx>,
/// var name to look for as index /// var name to look for as index
var: ast::NodeId, var: HirId,
/// indexed variables that are used mutably /// indexed variables that are used mutably
indexed_mut: FxHashSet<Name>, indexed_mut: FxHashSet<Name>,
/// indirectly indexed variables (`v[(i + 4) % N]`), the extend is `None` for global /// indirectly indexed variables (`v[(i + 4) % N]`), the extend is `None` for global
@ -1841,7 +1840,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
then { then {
match self.cx.tables.qpath_def(qpath, expr.hir_id) { match self.cx.tables.qpath_def(qpath, expr.hir_id) {
Def::Upvar(local_id, ..) => { Def::Upvar(local_id, ..) => {
if local_id == self.var { if self.cx.tcx.hir().node_to_hir_id(local_id) == self.var {
// we are not indexing anything, record that // we are not indexing anything, record that
self.nonindex = true; self.nonindex = true;
} }
@ -1849,7 +1848,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
Def::Local(local_id) => Def::Local(local_id) =>
{ {
if local_id == self.var { if self.cx.tcx.hir().node_to_hir_id(local_id) == self.var {
self.nonindex = true; self.nonindex = true;
} else { } else {
// not the correct variable, but still a variable // not the correct variable, but still a variable

View file

@ -482,7 +482,7 @@ fn check_wild_enum_match(cx: &LateContext<'_, '_>, ex: &Expr, arms: &[Arm]) {
for pat in &arm.pats { for pat in &arm.pats {
if let PatKind::Wild = pat.node { if let PatKind::Wild = pat.node {
wildcard_span = Some(pat.span); wildcard_span = Some(pat.span);
} else if let PatKind::Binding(_, _, _, ident, None) = pat.node { } else if let PatKind::Binding(_, _, ident, None) = pat.node {
wildcard_span = Some(pat.span); wildcard_span = Some(pat.span);
wildcard_ident = Some(ident); wildcard_ident = Some(ident);
} }

View file

@ -115,7 +115,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
// trait method with default body needs inline in case // trait method with default body needs inline in case
// an impl is not provided // an impl is not provided
let desc = "a default trait method"; let desc = "a default trait method";
let item = cx.tcx.hir().expect_trait_item_by_hir_id(tit.id.hir_id); let item = cx.tcx.hir().expect_trait_item(tit.id.hir_id);
check_missing_inline_attrs(cx, &item.attrs, item.span, desc); check_missing_inline_attrs(cx, &item.attrs, item.span, desc);
} }
}, },

View file

@ -209,7 +209,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
if !implements_borrow_trait; if !implements_borrow_trait;
if !all_borrowable_trait; if !all_borrowable_trait;
if let PatKind::Binding(mode, _, canonical_id, ..) = arg.pat.node; if let PatKind::Binding(mode, canonical_id, ..) = arg.pat.node;
if !moved_vars.contains(&canonical_id); if !moved_vars.contains(&canonical_id);
then { then {
if mode == BindingAnnotation::Mutable || mode == BindingAnnotation::RefMut { if mode == BindingAnnotation::Mutable || mode == BindingAnnotation::RefMut {

View file

@ -50,7 +50,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedIoAmount {
}; };
match expr.node { match expr.node {
hir::ExprKind::Match(ref res, _, _) if is_try(expr).is_some() => { hir::ExprKind::Match(ref res, _, _) if is_try(cx, expr).is_some() => {
if let hir::ExprKind::Call(ref func, ref args) = res.node { if let hir::ExprKind::Call(ref func, ref args) = res.node {
if let hir::ExprKind::Path(ref path) = func.node { if let hir::ExprKind::Path(ref path) = func.node {
if match_qpath(path, &paths::TRY_INTO_RESULT) && args.len() == 1 { if match_qpath(path, &paths::TRY_INTO_RESULT) && args.len() == 1 {

View file

@ -164,8 +164,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass {
output: &mut self.registered_lints, output: &mut self.registered_lints,
cx, cx,
}; };
let node_id = cx.tcx.hir().hir_to_node_id(impl_item_refs[0].id.hir_id); let body_id = cx.tcx.hir().body_owned_by(impl_item_refs[0].id.hir_id);
let body_id = cx.tcx.hir().body_owned_by(node_id);
collector.visit_expr(&cx.tcx.hir().body(body_id).value); collector.visit_expr(&cx.tcx.hir().body(body_id).value);
} }
} }

View file

@ -829,15 +829,15 @@ pub fn iter_input_pats<'tcx>(decl: &FnDecl, body: &'tcx Body) -> impl Iterator<I
/// Check if a given expression is a match expression /// Check if a given expression is a match expression
/// expanded from `?` operator or `try` macro. /// expanded from `?` operator or `try` macro.
pub fn is_try(expr: &Expr) -> Option<&Expr> { pub fn is_try<'a>(cx: &'_ LateContext<'_, '_>, expr: &'a Expr) -> Option<&'a Expr> {
fn is_ok(arm: &Arm) -> bool { fn is_ok(cx: &'_ LateContext<'_, '_>, arm: &Arm) -> bool {
if_chain! { if_chain! {
if let PatKind::TupleStruct(ref path, ref pat, None) = arm.pats[0].node; if let PatKind::TupleStruct(ref path, ref pat, None) = arm.pats[0].node;
if match_qpath(path, &paths::RESULT_OK[1..]); if match_qpath(path, &paths::RESULT_OK[1..]);
if let PatKind::Binding(_, defid, _, _, None) = pat[0].node; if let PatKind::Binding(_, hir_id, _, None) = pat[0].node;
if let ExprKind::Path(QPath::Resolved(None, ref path)) = arm.body.node; if let ExprKind::Path(QPath::Resolved(None, ref path)) = arm.body.node;
if let Def::Local(lid) = path.def; if let Def::Local(lid) = path.def;
if lid == defid; if cx.tcx.hir().node_to_hir_id(lid) == hir_id;
then { then {
return true; return true;
} }
@ -863,8 +863,8 @@ pub fn is_try(expr: &Expr) -> Option<&Expr> {
if arms.len() == 2; if arms.len() == 2;
if arms[0].pats.len() == 1 && arms[0].guard.is_none(); if arms[0].pats.len() == 1 && arms[0].guard.is_none();
if arms[1].pats.len() == 1 && arms[1].guard.is_none(); if arms[1].pats.len() == 1 && arms[1].guard.is_none();
if (is_ok(&arms[0]) && is_err(&arms[1])) || if (is_ok(cx, &arms[0]) && is_err(&arms[1])) ||
(is_ok(&arms[1]) && is_err(&arms[0])); (is_ok(cx, &arms[1]) && is_err(&arms[0]));
then { then {
return Some(expr); return Some(expr);
} }