|
1 | 1 | use super::MANUAL_FIND; |
2 | 2 | use super::utils::make_iterator_snippet; |
3 | 3 | use clippy_utils::diagnostics::span_lint_and_then; |
| 4 | +use clippy_utils::res::{MaybeQPath, MaybeResPath}; |
4 | 5 | use clippy_utils::source::snippet_with_applicability; |
5 | 6 | use clippy_utils::ty::implements_trait; |
6 | 7 | use clippy_utils::usage::contains_return_break_continue_macro; |
7 | | -use clippy_utils::{higher, is_res_lang_ctor, path_res, peel_blocks_with_stmt}; |
| 8 | +use clippy_utils::{higher, is_res_lang_ctor, peel_blocks_with_stmt}; |
8 | 9 | use rustc_errors::Applicability; |
9 | | -use rustc_hir::def::Res; |
10 | 10 | use rustc_hir::lang_items::LangItem; |
11 | 11 | use rustc_hir::{BindingMode, Block, Expr, ExprKind, HirId, Node, Pat, PatKind, Stmt, StmtKind}; |
12 | 12 | use rustc_lint::LateContext; |
@@ -34,8 +34,8 @@ pub(super) fn check<'tcx>( |
34 | 34 | && let StmtKind::Semi(semi) = stmt.kind |
35 | 35 | && let ExprKind::Ret(Some(ret_value)) = semi.kind |
36 | 36 | && let ExprKind::Call(ctor, [inner_ret]) = ret_value.kind |
37 | | - && is_res_lang_ctor(cx, path_res(cx, ctor), LangItem::OptionSome) |
38 | | - && path_res(cx, inner_ret) == Res::Local(binding_id) |
| 37 | + && is_res_lang_ctor(cx, ctor.res(cx), LangItem::OptionSome) |
| 38 | + && inner_ret.res_local_id() == Some(binding_id) |
39 | 39 | && !contains_return_break_continue_macro(cond) |
40 | 40 | && let Some((last_stmt, last_ret)) = last_stmt_and_ret(cx, expr) |
41 | 41 | { |
@@ -150,7 +150,7 @@ fn last_stmt_and_ret<'tcx>( |
150 | 150 | && let Some((_, Node::Block(block))) = parent_iter.next() |
151 | 151 | && let Some((last_stmt, last_ret)) = extract(block) |
152 | 152 | && last_stmt.hir_id == node_hir |
153 | | - && is_res_lang_ctor(cx, path_res(cx, last_ret), LangItem::OptionNone) |
| 153 | + && is_res_lang_ctor(cx, last_ret.res(cx), LangItem::OptionNone) |
154 | 154 | && let Some((_, Node::Expr(_block))) = parent_iter.next() |
155 | 155 | // This includes the function header |
156 | 156 | && let Some((_, func)) = parent_iter.next() |
|
0 commit comments