Add SyntaxContext::hygienic_eq
.
This combines multiple `HygieneData::with` calls into one, by combining parts of `hygienic_eq` and `adjust_ident`.
This commit is contained in:
parent
f9209fcd63
commit
6596743d5e
2 changed files with 10 additions and 1 deletions
|
@ -3089,7 +3089,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
// comparison fails frequently, and we want to avoid the expensive
|
||||
// `modern()` calls required for the span comparison whenever possible.
|
||||
use_name.name == def_name.name &&
|
||||
self.adjust_ident(use_name, def_parent_def_id).span.ctxt() == def_name.modern().span.ctxt()
|
||||
use_name.span.ctxt().hygienic_eq(def_name.span.ctxt(),
|
||||
self.expansion_that_defined(def_parent_def_id))
|
||||
}
|
||||
|
||||
fn expansion_that_defined(self, scope: DefId) -> Mark {
|
||||
|
|
|
@ -543,6 +543,14 @@ impl SyntaxContext {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn hygienic_eq(self, other: SyntaxContext, mark: Mark) -> bool {
|
||||
HygieneData::with(|data| {
|
||||
let mut self_modern = data.modern(self);
|
||||
data.adjust(&mut self_modern, mark);
|
||||
self_modern == data.modern(other)
|
||||
})
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn modern(self) -> SyntaxContext {
|
||||
HygieneData::with(|data| data.modern(self))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue