about summary refs log tree commit diff
path: root/src/libsyntax_pos
diff options
context:
space:
mode:
authorNicholas Nethercote <nnethercote@mozilla.com>2019-06-03 09:43:20 +1000
committerNicholas Nethercote <nnethercote@mozilla.com>2019-06-05 07:43:15 +1000
commit6596743d5e710e69d88f9522a207f41731177ef0 (patch)
treef91f5f14720c3f52db97444e681344e1074ddfb9 /src/libsyntax_pos
parentf9209fcd634fd5fc1fc83387af3b16b7cab62b74 (diff)
downloadrust-6596743d5e710e69d88f9522a207f41731177ef0.tar.gz
rust-6596743d5e710e69d88f9522a207f41731177ef0.zip
Add `SyntaxContext::hygienic_eq`.
This combines multiple `HygieneData::with` calls into one, by combining
parts of `hygienic_eq` and `adjust_ident`.
Diffstat (limited to 'src/libsyntax_pos')
-rw-r--r--src/libsyntax_pos/hygiene.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs
index 5691258152a..451ae5808f6 100644
--- a/src/libsyntax_pos/hygiene.rs
+++ b/src/libsyntax_pos/hygiene.rs
@@ -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))