Skip to content

Commit baebf79

Browse files
committed
Move modules outside the proc macro
1 parent afeda72 commit baebf79

File tree

2 files changed

+44
-26
lines changed

2 files changed

+44
-26
lines changed

src/librustc_macros/src/symbols.rs

+16-26
Original file line numberDiff line numberDiff line change
@@ -129,37 +129,27 @@ pub fn symbols(input: TokenStream) -> TokenStream {
129129
}
130130

131131
TokenStream::from(quote! {
132-
#[allow(non_upper_case_globals)]
133-
pub mod keywords {
134-
use super::{Symbol, Ident};
135-
#[derive(Clone, Copy, PartialEq, Eq)]
136-
pub struct Keyword {
137-
ident: Ident,
138-
}
139-
impl Keyword {
140-
#[inline] pub fn ident(self) -> Ident { self.ident }
141-
#[inline] pub fn name(self) -> Symbol { self.ident.name }
142-
}
143-
144-
#keyword_stream
145-
146-
impl std::str::FromStr for Keyword {
147-
type Err = ();
148-
149-
fn from_str(s: &str) -> Result<Self, ()> {
150-
match s {
151-
#from_str_stream
152-
_ => Err(()),
132+
macro_rules! keywords {
133+
() => {
134+
#keyword_stream
135+
136+
impl std::str::FromStr for Keyword {
137+
type Err = ();
138+
139+
fn from_str(s: &str) -> Result<Self, ()> {
140+
match s {
141+
#from_str_stream
142+
_ => Err(()),
143+
}
153144
}
154145
}
155146
}
156147
}
157148

158-
#[allow(non_upper_case_globals)]
159-
pub mod symbols {
160-
use super::Symbol;
161-
162-
#symbols_stream
149+
macro_rules! symbols {
150+
() => {
151+
#symbols_stream
152+
}
163153
}
164154

165155
impl Interner {

src/libsyntax_pos/symbol.rs

+28
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,34 @@ impl Interner {
406406
}
407407
}
408408

409+
pub mod keywords {
410+
use super::{Symbol, Ident};
411+
412+
#[derive(Clone, Copy, PartialEq, Eq)]
413+
pub struct Keyword {
414+
ident: Ident,
415+
}
416+
417+
impl Keyword {
418+
#[inline]
419+
pub fn ident(self) -> Ident {
420+
self.ident
421+
}
422+
423+
#[inline]
424+
pub fn name(self) -> Symbol {
425+
self.ident.name
426+
}
427+
}
428+
429+
keywords!();
430+
}
431+
432+
pub mod symbols {
433+
use super::Symbol;
434+
symbols!();
435+
}
436+
409437
impl Symbol {
410438
fn is_used_keyword_2018(self) -> bool {
411439
self == keywords::Dyn.name()

0 commit comments

Comments
 (0)