Skip to content

Commit 2456ff8

Browse files
committed
proc_macro: remove Context trait, and put span methods directly on Server
1 parent 55f052d commit 2456ff8

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

compiler/rustc_expand/src/proc_macro_server.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ impl<'a, 'b> Rustc<'a, 'b> {
372372
fn lit(&mut self, kind: token::LitKind, symbol: Symbol, suffix: Option<Symbol>) -> Literal {
373373
Literal {
374374
lit: token::Lit::new(kind, symbol, suffix),
375-
span: server::Context::call_site(self),
375+
span: server::Server::call_site(self),
376376
}
377377
}
378378
}
@@ -550,7 +550,7 @@ impl server::Group for Rustc<'_, '_> {
550550
Group {
551551
delimiter,
552552
stream: stream.unwrap_or_default(),
553-
span: DelimSpan::from_single(server::Context::call_site(self)),
553+
span: DelimSpan::from_single(server::Server::call_site(self)),
554554
flatten: false,
555555
}
556556
}
@@ -582,7 +582,7 @@ impl server::Group for Rustc<'_, '_> {
582582

583583
impl server::Punct for Rustc<'_, '_> {
584584
fn new(&mut self, ch: char, spacing: Spacing) -> Self::Punct {
585-
Punct::new(ch, spacing == Spacing::Joint, server::Context::call_site(self))
585+
Punct::new(ch, spacing == Spacing::Joint, server::Server::call_site(self))
586586
}
587587

588588
fn as_char(&mut self, punct: Self::Punct) -> char {
@@ -918,7 +918,7 @@ impl server::Span for Rustc<'_, '_> {
918918
}
919919
}
920920

921-
impl server::Context for Rustc<'_, '_> {
921+
impl server::Server for Rustc<'_, '_> {
922922
fn def_site(&mut self) -> Self::Span {
923923
self.def_site
924924
}

library/proc_macro/src/bridge/server.rs

+9-13
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ macro_rules! associated_fn {
3030
($($item:tt)*) => ($($item)*;)
3131
}
3232

33-
/// Helper methods defined by `Server` types not invoked over RPC.
34-
pub trait Context: Types {
35-
fn def_site(&mut self) -> Self::Span;
36-
fn call_site(&mut self) -> Self::Span;
37-
fn mixed_site(&mut self) -> Self::Span;
38-
}
39-
4033
macro_rules! declare_server_traits {
4134
($($name:ident {
4235
$(fn $method:ident($($arg:ident: $arg_ty:ty),* $(,)?) $(-> $ret_ty:ty)?;)*
@@ -45,23 +38,26 @@ macro_rules! declare_server_traits {
4538
$(associated_fn!(fn $method(&mut self, $($arg: $arg_ty),*) $(-> $ret_ty)?);)*
4639
})*
4740

48-
pub trait Server: Types + Context $(+ $name)* {}
49-
impl<S: Types + Context $(+ $name)*> Server for S {}
41+
pub trait Server: Types $(+ $name)* {
42+
fn def_site(&mut self) -> Self::Span;
43+
fn call_site(&mut self) -> Self::Span;
44+
fn mixed_site(&mut self) -> Self::Span;
45+
}
5046
}
5147
}
5248
with_api!(Self, self_, declare_server_traits);
5349

5450
pub(super) struct MarkedTypes<S: Types>(S);
5551

56-
impl<S: Context> Context for MarkedTypes<S> {
52+
impl<S: Server> Server for MarkedTypes<S> {
5753
fn def_site(&mut self) -> Self::Span {
58-
<_>::mark(Context::def_site(&mut self.0))
54+
<_>::mark(Server::def_site(&mut self.0))
5955
}
6056
fn call_site(&mut self) -> Self::Span {
61-
<_>::mark(Context::call_site(&mut self.0))
57+
<_>::mark(Server::call_site(&mut self.0))
6258
}
6359
fn mixed_site(&mut self) -> Self::Span {
64-
<_>::mark(Context::mixed_site(&mut self.0))
60+
<_>::mark(Server::mixed_site(&mut self.0))
6561
}
6662
}
6763

0 commit comments

Comments
 (0)