Skip to content

Commit f30bf69

Browse files
committed
Auto merge of #4508 - rust-lang:reduced-symbolism, r=phansch
Simplify `utils::match_def_path`, removing a FIXME changelog: none This removes the `Vec<Symbol>` allocation. We still need to call `cx.get_def_path`, but this should already have been interned, and I don't see how we can keep ergonomics of that function without allocating a `Vec`. r? @phansch
2 parents 804f8e6 + 72058a6 commit f30bf69

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

clippy_lints/src/utils/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,6 @@ mod test {
11251125
}
11261126

11271127
pub fn match_def_path<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, did: DefId, syms: &[&str]) -> bool {
1128-
// HACK: find a way to use symbols from clippy or just go fully to diagnostic items
1129-
let syms: Vec<_> = syms.iter().map(|sym| Symbol::intern(sym)).collect();
1130-
cx.match_def_path(did, &syms)
1128+
let path = cx.get_def_path(did);
1129+
path.len() == syms.len() && path.into_iter().zip(syms.iter()).all(|(a, &b)| a.as_str() == b)
11311130
}

0 commit comments

Comments
 (0)