Skip to content

Commit acd7a54

Browse files
committed
review changes
longer names for RPC generics and reduced dependency on macros in the server.
1 parent 0197965 commit acd7a54

File tree

2 files changed

+33
-28
lines changed

2 files changed

+33
-28
lines changed

proc_macro/src/bridge/mod.rs

+27-26
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ mark_noop! {
325325
&'_ [u8],
326326
&'_ str,
327327
String,
328+
u8,
328329
usize,
329330
Delimiter,
330331
Level,
@@ -431,48 +432,48 @@ compound_traits!(
431432
);
432433

433434
#[derive(Copy, Clone)]
434-
pub struct DelimSpan<S> {
435-
pub open: S,
436-
pub close: S,
437-
pub entire: S,
435+
pub struct DelimSpan<Span> {
436+
pub open: Span,
437+
pub close: Span,
438+
pub entire: Span,
438439
}
439440

440-
impl<S: Copy> DelimSpan<S> {
441-
pub fn from_single(span: S) -> Self {
441+
impl<Span: Copy> DelimSpan<Span> {
442+
pub fn from_single(span: Span) -> Self {
442443
DelimSpan { open: span, close: span, entire: span }
443444
}
444445
}
445446

446-
compound_traits!(struct DelimSpan<Sp> { open, close, entire });
447+
compound_traits!(struct DelimSpan<Span> { open, close, entire });
447448

448449
#[derive(Clone)]
449-
pub struct Group<T, S> {
450+
pub struct Group<TokenStream, Span> {
450451
pub delimiter: Delimiter,
451-
pub stream: Option<T>,
452-
pub span: DelimSpan<S>,
452+
pub stream: Option<TokenStream>,
453+
pub span: DelimSpan<Span>,
453454
}
454455

455-
compound_traits!(struct Group<T, Sp> { delimiter, stream, span });
456+
compound_traits!(struct Group<TokenStream, Span> { delimiter, stream, span });
456457

457458
#[derive(Clone)]
458-
pub struct Punct<S> {
459-
pub ch: char,
459+
pub struct Punct<Span> {
460+
pub ch: u8,
460461
pub joint: bool,
461-
pub span: S,
462+
pub span: Span,
462463
}
463464

464-
compound_traits!(struct Punct<Sp> { ch, joint, span });
465+
compound_traits!(struct Punct<Span> { ch, joint, span });
465466

466467
#[derive(Clone)]
467-
pub enum TokenTree<T, S, I, L> {
468-
Group(Group<T, S>),
469-
Punct(Punct<S>),
470-
Ident(I),
471-
Literal(L),
468+
pub enum TokenTree<TokenStream, Span, Ident, Literal> {
469+
Group(Group<TokenStream, Span>),
470+
Punct(Punct<Span>),
471+
Ident(Ident),
472+
Literal(Literal),
472473
}
473474

474475
compound_traits!(
475-
enum TokenTree<T, Sp, I, L> {
476+
enum TokenTree<TokenStream, Span, Ident, Literal> {
476477
Group(tt),
477478
Punct(tt),
478479
Ident(tt),
@@ -483,12 +484,12 @@ compound_traits!(
483484
/// Globals provided alongside the initial inputs for a macro expansion.
484485
/// Provides values such as spans which are used frequently to avoid RPC.
485486
#[derive(Clone)]
486-
pub struct ExpnGlobals<S> {
487-
pub def_site: S,
488-
pub call_site: S,
489-
pub mixed_site: S,
487+
pub struct ExpnGlobals<Span> {
488+
pub def_site: Span,
489+
pub call_site: Span,
490+
pub mixed_site: Span,
490491
}
491492

492493
compound_traits!(
493-
struct ExpnGlobals<Sp> { def_site, call_site, mixed_site }
494+
struct ExpnGlobals<Span> { def_site, call_site, mixed_site }
494495
);

proc_macro/src/lib.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -969,13 +969,17 @@ impl Punct {
969969
if !LEGAL_CHARS.contains(&ch) {
970970
panic!("unsupported character `{:?}`", ch);
971971
}
972-
Punct(bridge::Punct { ch, joint: spacing == Spacing::Joint, span: Span::call_site().0 })
972+
Punct(bridge::Punct {
973+
ch: ch as u8,
974+
joint: spacing == Spacing::Joint,
975+
span: Span::call_site().0,
976+
})
973977
}
974978

975979
/// Returns the value of this punctuation character as `char`.
976980
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
977981
pub fn as_char(&self) -> char {
978-
self.0.ch
982+
self.0.ch as char
979983
}
980984

981985
/// Returns the spacing of this punctuation character, indicating whether it's immediately

0 commit comments

Comments
 (0)