@@ -3,7 +3,7 @@ use std::fmt::Display;
33use clippy_utils:: consts:: { ConstEvalCtxt , Constant } ;
44use clippy_utils:: diagnostics:: { span_lint, span_lint_and_help} ;
55use clippy_utils:: source:: SpanRangeExt ;
6- use clippy_utils:: { def_path_def_ids , path_def_id, paths} ;
6+ use clippy_utils:: { def_path_res_with_base , find_crates , path_def_id, paths} ;
77use rustc_ast:: ast:: { LitKind , StrStyle } ;
88use rustc_hir:: def_id:: DefIdMap ;
99use rustc_hir:: { BorrowKind , Expr , ExprKind } ;
@@ -75,11 +75,14 @@ impl<'tcx> LateLintPass<'tcx> for Regex {
7575 // We don't use `match_def_path` here because that relies on matching the exact path, which changed
7676 // between regex 1.8 and 1.9
7777 //
78- // `def_path_def_ids` will resolve through re-exports but is relatively heavy, so we only perform
79- // the operation once and store the results
80- let mut resolve = |path, kind| {
81- for id in def_path_def_ids ( cx. tcx , path) {
82- self . definitions . insert ( id, kind) ;
78+ // `def_path_res_with_base` will resolve through re-exports but is relatively heavy, so we only
79+ // perform the operation once and store the results
80+ let regex_crates = find_crates ( cx. tcx , sym ! ( regex) ) ;
81+ let mut resolve = |path : & [ & str ] , kind : RegexKind | {
82+ for res in def_path_res_with_base ( cx. tcx , regex_crates. clone ( ) , & path[ 1 ..] ) {
83+ if let Some ( id) = res. opt_def_id ( ) {
84+ self . definitions . insert ( id, kind) ;
85+ }
8386 }
8487 } ;
8588
0 commit comments