|
1 | 1 | use clippy_utils::diagnostics::span_lint_and_sugg; |
2 | 2 | use clippy_utils::macros::matching_root_macro_call; |
| 3 | +use clippy_utils::res::{MaybeDef, MaybeQPath, MaybeResPath}; |
3 | 4 | use clippy_utils::sugg::Sugg; |
4 | 5 | use clippy_utils::{ |
5 | | - SpanlessEq, get_enclosing_block, is_integer_literal, is_path_diagnostic_item, path_to_local, path_to_local_id, |
6 | | - span_contains_comment, sym, |
| 6 | + SpanlessEq, get_enclosing_block, is_integer_literal, path_to_local, path_to_local_id, span_contains_comment, sym, |
7 | 7 | }; |
8 | 8 | use rustc_errors::Applicability; |
9 | 9 | use rustc_hir::intravisit::{Visitor, walk_block, walk_expr, walk_stmt}; |
@@ -149,10 +149,10 @@ impl SlowVectorInit { |
149 | 149 | } |
150 | 150 |
|
151 | 151 | if let ExprKind::Call(func, [len_expr]) = expr.kind |
152 | | - && is_path_diagnostic_item(cx, func, sym::vec_with_capacity) |
| 152 | + && func.ty_rel_def(cx).is_diag_item(cx, sym::vec_with_capacity) |
153 | 153 | { |
154 | 154 | Some(InitializedSize::Initialized(len_expr)) |
155 | | - } else if matches!(expr.kind, ExprKind::Call(func, []) if is_path_diagnostic_item(cx, func, sym::vec_new)) { |
| 155 | + } else if matches!(expr.kind, ExprKind::Call(func, []) if func.ty_rel_def(cx).is_diag_item(cx, sym::vec_new)) { |
156 | 156 | Some(InitializedSize::Uninitialized) |
157 | 157 | } else { |
158 | 158 | None |
@@ -301,7 +301,7 @@ impl<'tcx> VectorInitializationVisitor<'_, 'tcx> { |
301 | 301 | /// Returns `true` if given expression is `repeat(0)` |
302 | 302 | fn is_repeat_zero(&self, expr: &Expr<'_>) -> bool { |
303 | 303 | if let ExprKind::Call(fn_expr, [repeat_arg]) = expr.kind |
304 | | - && is_path_diagnostic_item(self.cx, fn_expr, sym::iter_repeat) |
| 304 | + && fn_expr.basic_res().is_diag_item(self.cx, sym::iter_repeat) |
305 | 305 | && is_integer_literal(repeat_arg, 0) |
306 | 306 | { |
307 | 307 | true |
|
0 commit comments