Skip to content

Commit

Permalink
Auto merge of #4508 - rust-lang:reduced-symbolism, r=phansch
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Sep 6, 2019
2 parents 804f8e6 + 72058a6 commit f30bf69
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions clippy_lints/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,6 @@ mod test {
}

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

0 comments on commit f30bf69

Please sign in to comment.