diff options
| author | bors <bors@rust-lang.org> | 2018-05-18 10:57:05 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-05-18 10:57:05 +0000 |
| commit | df40e61382a2cba0be621fdabb9971ce3475e9a7 (patch) | |
| tree | 7bdf66599659eccd8b03f5921c2e5087efe94008 /src/libsyntax_pos/lib.rs | |
| parent | fd18d2537ddcffb24b3739393b085ed28dfc340e (diff) | |
| parent | d8bbc1ee1ad44e9c7bd93c8d59103eacd0ed36e8 (diff) | |
| download | rust-df40e61382a2cba0be621fdabb9971ce3475e9a7.tar.gz rust-df40e61382a2cba0be621fdabb9971ce3475e9a7.zip | |
Auto merge of #50307 - petrochenkov:keyhyg2, r=nikomatsakis
Implement edition hygiene for keywords Determine "keywordness" of an identifier in its hygienic context. cc https://github.com/rust-lang/rust/pull/49611 I've resurrected `proc` as an Edition-2015-only keyword for testing purposes, but it should probably be buried again. EDIT: `proc` is removed again.
Diffstat (limited to 'src/libsyntax_pos/lib.rs')
| -rw-r--r-- | src/libsyntax_pos/lib.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 73f0e6a6018..17163576901 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -20,6 +20,7 @@ #![feature(const_fn)] #![feature(custom_attribute)] +#![feature(non_exhaustive)] #![feature(optin_builtin_traits)] #![allow(unused_attributes)] #![feature(specialization)] @@ -48,6 +49,7 @@ extern crate serialize as rustc_serialize; // used by deriving extern crate unicode_width; +pub mod edition; pub mod hygiene; pub use hygiene::{Mark, SyntaxContext, ExpnInfo, ExpnFormat, NameAndSpan, CompilerDesugaringKind}; @@ -298,6 +300,12 @@ impl Span { self.ctxt().outer().expn_info().map(|i| i.call_site) } + /// Edition of the crate from which this span came. + pub fn edition(self) -> edition::Edition { + self.ctxt().outer().expn_info().map_or_else(|| hygiene::default_edition(), + |einfo| einfo.callee.edition) + } + /// Return the source callee. /// /// Returns None if the supplied span has no expansion trace, |
