@@ -3,7 +3,7 @@ use clippy_utils::diagnostics::span_lint_and_then;
3
3
use clippy_utils:: higher:: VecArgs ;
4
4
use clippy_utils:: macros:: matching_root_macro_call;
5
5
use clippy_utils:: source:: snippet;
6
- use clippy_utils:: { expr_or_init, fn_def_id, match_def_path , paths } ;
6
+ use clippy_utils:: { expr_or_init, fn_def_id} ;
7
7
use rustc_errors:: Applicability ;
8
8
use rustc_hir:: { Expr , ExprKind } ;
9
9
use rustc_lint:: { LateContext , LateLintPass } ;
@@ -67,7 +67,7 @@ fn emit_lint(cx: &LateContext<'_>, span: Span, kind: &str, note: &'static str, s
67
67
fn check_vec_macro ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > ) {
68
68
if matching_root_macro_call ( cx, expr. span , sym:: vec_macro) . is_some ( )
69
69
&& let Some ( VecArgs :: Repeat ( repeat_expr, len_expr) ) = VecArgs :: hir ( cx, expr)
70
- && fn_def_id ( cx, repeat_expr) . is_some_and ( |did| match_def_path ( cx , did, & paths :: VEC_WITH_CAPACITY ) )
70
+ && fn_def_id ( cx, repeat_expr) . is_some_and ( |did| cx . tcx . is_diagnostic_item ( sym :: vec_with_capacity , did) )
71
71
&& !len_expr. span . from_expansion ( )
72
72
&& let Some ( Constant :: Int ( 2 ..) ) = ConstEvalCtxt :: new ( cx) . eval ( expr_or_init ( cx, len_expr) )
73
73
{
@@ -91,7 +91,7 @@ fn check_repeat_fn(cx: &LateContext<'_>, expr: &Expr<'_>) {
91
91
if !expr. span . from_expansion ( )
92
92
&& fn_def_id ( cx, expr) . is_some_and ( |did| cx. tcx . is_diagnostic_item ( sym:: iter_repeat, did) )
93
93
&& let ExprKind :: Call ( _, [ repeat_expr] ) = expr. kind
94
- && fn_def_id ( cx, repeat_expr) . is_some_and ( |did| match_def_path ( cx , did, & paths :: VEC_WITH_CAPACITY ) )
94
+ && fn_def_id ( cx, repeat_expr) . is_some_and ( |did| cx . tcx . is_diagnostic_item ( sym :: vec_with_capacity , did) )
95
95
&& !repeat_expr. span . from_expansion ( )
96
96
{
97
97
emit_lint (
0 commit comments