@@ -3,7 +3,7 @@ use std::fmt::Display;
3
3
use clippy_utils:: consts:: { ConstEvalCtxt , Constant } ;
4
4
use clippy_utils:: diagnostics:: { span_lint, span_lint_and_help} ;
5
5
use 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} ;
7
7
use rustc_ast:: ast:: { LitKind , StrStyle } ;
8
8
use rustc_hir:: def_id:: DefIdMap ;
9
9
use rustc_hir:: { BorrowKind , Expr , ExprKind } ;
@@ -75,11 +75,14 @@ impl<'tcx> LateLintPass<'tcx> for Regex {
75
75
// We don't use `match_def_path` here because that relies on matching the exact path, which changed
76
76
// between regex 1.8 and 1.9
77
77
//
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
+ }
83
86
}
84
87
} ;
85
88
0 commit comments