Skip to content

Commit c6cc07a

Browse files
committed
Auto merge of rust-lang#5452 - phansch:match_def_path_refactor, r=matthiaskrgr
Refactor: Use rustc's `match_def_path` This replaces our match_def_path implementation with the rustc one. Note that we can't just use it in all call sites because of the `&[&str]` / `&[Symbol]` difference in Clippy/rustc. changelog: none
2 parents 81b3e70 + 9ec95af commit c6cc07a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

clippy_lints/src/utils/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1222,8 +1222,10 @@ pub fn is_normalizable<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, param_env: ty::Para
12221222
}
12231223

12241224
pub fn match_def_path<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, did: DefId, syms: &[&str]) -> bool {
1225-
let path = cx.get_def_path(did);
1226-
path.len() == syms.len() && path.into_iter().zip(syms.iter()).all(|(a, &b)| a.as_str() == b)
1225+
// We have to convert `syms` to `&[Symbol]` here because rustc's `match_def_path`
1226+
// accepts only that. We should probably move to Symbols in Clippy as well.
1227+
let syms = syms.iter().map(|p| Symbol::intern(p)).collect::<Vec<Symbol>>();
1228+
cx.match_def_path(did, &syms)
12271229
}
12281230

12291231
/// Returns the list of condition expressions and the list of blocks in a

0 commit comments

Comments
 (0)