diff options
| author | bors <bors@rust-lang.org> | 2019-03-08 17:10:52 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-03-08 17:10:52 +0000 |
| commit | bd6b5a1a36cb7b105bff8c4e2629bf28eca8471e (patch) | |
| tree | 8fe15321268e43eeb074417ab7e1f01970985533 /clippy_lints/src/utils | |
| parent | 9702b3d2c0905b6975a0e6a9ce25c55f95eba65e (diff) | |
| parent | 5d78250c75db3b1923072cf1be3b03f7d0cef5e2 (diff) | |
Auto merge of #3854 - ljedrz:rustc_58992, r=phansch
Align with rust-lang/rust/#58992 Some adjustments needed after the most recent round of HirIdification.
Diffstat (limited to 'clippy_lints/src/utils')
| -rw-r--r-- | clippy_lints/src/utils/internal_lints.rs | 3 | ||||
| -rw-r--r-- | clippy_lints/src/utils/mod.rs | 12 |
2 files changed, 7 insertions, 8 deletions
diff --git a/clippy_lints/src/utils/internal_lints.rs b/clippy_lints/src/utils/internal_lints.rs index 877f431e641..343098ceeee 100644 --- a/clippy_lints/src/utils/internal_lints.rs +++ b/clippy_lints/src/utils/internal_lints.rs @@ -164,8 +164,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass { output: &mut self.registered_lints, 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(node_id); + let body_id = cx.tcx.hir().body_owned_by(impl_item_refs[0].id.hir_id); collector.visit_expr(&cx.tcx.hir().body(body_id).value); } } diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index 70ba0592caa..f6b9a77a573 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -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 /// expanded from `?` operator or `try` macro. -pub fn is_try(expr: &Expr) -> Option<&Expr> { - fn is_ok(arm: &Arm) -> bool { +pub fn is_try<'a>(cx: &'_ LateContext<'_, '_>, expr: &'a Expr) -> Option<&'a Expr> { + fn is_ok(cx: &'_ LateContext<'_, '_>, arm: &Arm) -> bool { if_chain! { if let PatKind::TupleStruct(ref path, ref pat, None) = arm.pats[0].node; 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 Def::Local(lid) = path.def; - if lid == defid; + if cx.tcx.hir().node_to_hir_id(lid) == hir_id; then { return true; } @@ -863,8 +863,8 @@ pub fn is_try(expr: &Expr) -> Option<&Expr> { if arms.len() == 2; if arms[0].pats.len() == 1 && arms[0].guard.is_none(); if arms[1].pats.len() == 1 && arms[1].guard.is_none(); - if (is_ok(&arms[0]) && is_err(&arms[1])) || - (is_ok(&arms[1]) && is_err(&arms[0])); + if (is_ok(cx, &arms[0]) && is_err(&arms[1])) || + (is_ok(cx, &arms[1]) && is_err(&arms[0])); then { return Some(expr); } |
