about summary refs log tree commit diff
path: root/src/libsyntax_pos
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2018-11-18 03:25:59 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2018-11-27 00:32:30 +0300
commitdae4c7b1ff62da4901caf28653baa3133a40496c (patch)
treec805c4c5ed9442f48ed0a611cacdce35b03947d8 /src/libsyntax_pos
parentfba116fc5fb7018faeb1834d42422d7bdbcc4f64 (diff)
downloadrust-dae4c7b1ff62da4901caf28653baa3133a40496c.tar.gz
rust-dae4c7b1ff62da4901caf28653baa3133a40496c.zip
resolve: Implement edition hygiene for imports and absolute paths
Use per-span hygiene in a few other places in resolve
Prefer `rust_2015`/`rust_2018` helpers to comparing editions
Diffstat (limited to 'src/libsyntax_pos')
-rw-r--r--src/libsyntax_pos/lib.rs10
-rw-r--r--src/libsyntax_pos/symbol.rs3
2 files changed, 11 insertions, 2 deletions
diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs
index a780a38ff96..65f6d27239b 100644
--- a/src/libsyntax_pos/lib.rs
+++ b/src/libsyntax_pos/lib.rs
@@ -325,6 +325,16 @@ impl Span {
                                                     |einfo| einfo.edition)
     }
 
+    #[inline]
+    pub fn rust_2015(&self) -> bool {
+        self.edition() == edition::Edition::Edition2015
+    }
+
+    #[inline]
+    pub fn rust_2018(&self) -> bool {
+        self.edition() >= edition::Edition::Edition2018
+    }
+
     /// Return the source callee.
     ///
     /// Returns `None` if the supplied span has no expansion trace,
diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs
index 361353c82e2..e333a4f2176 100644
--- a/src/libsyntax_pos/symbol.rs
+++ b/src/libsyntax_pos/symbol.rs
@@ -12,7 +12,6 @@
 //! allows bidirectional lookup; i.e. given a value, one can easily find the
 //! type, and vice versa.
 
-use edition::Edition;
 use hygiene::SyntaxContext;
 use {Span, DUMMY_SP, GLOBALS};
 
@@ -444,7 +443,7 @@ impl Ident {
     pub fn is_unused_keyword(self) -> bool {
         // Note: `span.edition()` is relatively expensive, don't call it unless necessary.
         self.name >= keywords::Abstract.name() && self.name <= keywords::Yield.name() ||
-        self.name.is_unused_keyword_2018() && self.span.edition() == Edition::Edition2018
+        self.name.is_unused_keyword_2018() && self.span.rust_2018()
     }
 
     /// Returns `true` if the token is either a special identifier or a keyword.