diff options
| author | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2019-04-09 09:36:17 +0200 |
|---|---|---|
| committer | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2019-04-15 07:23:04 +0200 |
| commit | baebf79057fba32c27c3353aacbd389692a54a0c (patch) | |
| tree | cc12ca826d1f1edebee1cccfa1f814cb87f0b51a | |
| parent | afeda72dad761325ea759fd2008730e24a165b9c (diff) | |
| download | rust-baebf79057fba32c27c3353aacbd389692a54a0c.tar.gz rust-baebf79057fba32c27c3353aacbd389692a54a0c.zip | |
Move modules outside the proc macro
| -rw-r--r-- | src/librustc_macros/src/symbols.rs | 42 | ||||
| -rw-r--r-- | src/libsyntax_pos/symbol.rs | 28 |
2 files changed, 44 insertions, 26 deletions
diff --git a/src/librustc_macros/src/symbols.rs b/src/librustc_macros/src/symbols.rs index e72ab7f84e9..15f4d988a1f 100644 --- a/src/librustc_macros/src/symbols.rs +++ b/src/librustc_macros/src/symbols.rs @@ -129,37 +129,27 @@ pub fn symbols(input: TokenStream) -> TokenStream { } TokenStream::from(quote! { - #[allow(non_upper_case_globals)] - pub mod keywords { - use super::{Symbol, Ident}; - #[derive(Clone, Copy, PartialEq, Eq)] - pub struct Keyword { - ident: Ident, - } - impl Keyword { - #[inline] pub fn ident(self) -> Ident { self.ident } - #[inline] pub fn name(self) -> Symbol { self.ident.name } - } - - #keyword_stream - - impl std::str::FromStr for Keyword { - type Err = (); - - fn from_str(s: &str) -> Result<Self, ()> { - match s { - #from_str_stream - _ => Err(()), + macro_rules! keywords { + () => { + #keyword_stream + + impl std::str::FromStr for Keyword { + type Err = (); + + fn from_str(s: &str) -> Result<Self, ()> { + match s { + #from_str_stream + _ => Err(()), + } } } } } - #[allow(non_upper_case_globals)] - pub mod symbols { - use super::Symbol; - - #symbols_stream + macro_rules! symbols { + () => { + #symbols_stream + } } impl Interner { diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index 83cb6f4e86b..a5611d9ab14 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -406,6 +406,34 @@ impl Interner { } } +pub mod keywords { + use super::{Symbol, Ident}; + + #[derive(Clone, Copy, PartialEq, Eq)] + pub struct Keyword { + ident: Ident, + } + + impl Keyword { + #[inline] + pub fn ident(self) -> Ident { + self.ident + } + + #[inline] + pub fn name(self) -> Symbol { + self.ident.name + } + } + + keywords!(); +} + +pub mod symbols { + use super::Symbol; + symbols!(); +} + impl Symbol { fn is_used_keyword_2018(self) -> bool { self == keywords::Dyn.name() |
