Function clippy_utils::match_path
source · Expand description
THIS METHOD IS DEPRECATED and will eventually be removed since it does not match against the
entire path or resolved DefId
. Prefer using match_def_path
. Consider getting a DefId
from
QPath::Resolved.1.res.opt_def_id()
.
Matches a Path
against a slice of segment string literals.
There is also match_qpath
if you are dealing with a rustc_hir::QPath
instead of a
rustc_hir::Path
.
Examples
ⓘ
if match_path(&trait_ref.path, &paths::HASH) {
// This is the `std::hash::Hash` trait.
}
if match_path(ty_path, &["rustc", "lint", "Lint"]) {
// This is a `rustc_middle::lint::Lint`.
}