]> git.lizzy.rs Git - rust.git/commitdiff
Move modules outside the proc macro
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>
Tue, 9 Apr 2019 07:36:17 +0000 (09:36 +0200)
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>
Mon, 15 Apr 2019 05:23:04 +0000 (07:23 +0200)
src/librustc_macros/src/symbols.rs
src/libsyntax_pos/symbol.rs

index e72ab7f84e92af4a1248f06743f85eb78652fa2a..15f4d988a1f657ada92c39d4655cae91249079f7 100644 (file)
@@ -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 {
index 83cb6f4e86b0ea31ec05c97abfa29b0612b1dbc9..a5611d9ab147f608c777c91303c99a26515432cc 100644 (file)
@@ -406,6 +406,34 @@ pub fn get(&self, symbol: Symbol) -> &str {
     }
 }
 
+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()