diff options
| author | Nika Layzell <nika@thelayzells.com> | 2022-06-25 12:11:44 -0400 |
|---|---|---|
| committer | Nika Layzell <nika@thelayzells.com> | 2022-06-25 12:26:21 -0400 |
| commit | 2456ff892889fff5dea1ed0d234c22ab676d91da (patch) | |
| tree | 72ec6d9067f3230d89cbb8c77325fd7ae7564ddc | |
| parent | 55f052d9c927699e0f69b937ac93701442155d39 (diff) | |
| download | rust-2456ff892889fff5dea1ed0d234c22ab676d91da.tar.gz rust-2456ff892889fff5dea1ed0d234c22ab676d91da.zip | |
proc_macro: remove Context trait, and put span methods directly on Server
| -rw-r--r-- | compiler/rustc_expand/src/proc_macro_server.rs | 8 | ||||
| -rw-r--r-- | library/proc_macro/src/bridge/server.rs | 22 |
2 files changed, 13 insertions, 17 deletions
diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs index eace22d63f4..dddcff4c6dd 100644 --- a/compiler/rustc_expand/src/proc_macro_server.rs +++ b/compiler/rustc_expand/src/proc_macro_server.rs @@ -372,7 +372,7 @@ impl<'a, 'b> Rustc<'a, 'b> { fn lit(&mut self, kind: token::LitKind, symbol: Symbol, suffix: Option<Symbol>) -> Literal { Literal { lit: token::Lit::new(kind, symbol, suffix), - span: server::Context::call_site(self), + span: server::Server::call_site(self), } } } @@ -550,7 +550,7 @@ impl server::Group for Rustc<'_, '_> { Group { delimiter, stream: stream.unwrap_or_default(), - span: DelimSpan::from_single(server::Context::call_site(self)), + span: DelimSpan::from_single(server::Server::call_site(self)), flatten: false, } } @@ -582,7 +582,7 @@ impl server::Group for Rustc<'_, '_> { impl server::Punct for Rustc<'_, '_> { fn new(&mut self, ch: char, spacing: Spacing) -> Self::Punct { - Punct::new(ch, spacing == Spacing::Joint, server::Context::call_site(self)) + Punct::new(ch, spacing == Spacing::Joint, server::Server::call_site(self)) } fn as_char(&mut self, punct: Self::Punct) -> char { @@ -918,7 +918,7 @@ impl server::Span for Rustc<'_, '_> { } } -impl server::Context for Rustc<'_, '_> { +impl server::Server for Rustc<'_, '_> { fn def_site(&mut self) -> Self::Span { self.def_site } diff --git a/library/proc_macro/src/bridge/server.rs b/library/proc_macro/src/bridge/server.rs index d9a6ce81e4e..debcffc6f79 100644 --- a/library/proc_macro/src/bridge/server.rs +++ b/library/proc_macro/src/bridge/server.rs @@ -30,13 +30,6 @@ macro_rules! associated_fn { ($($item:tt)*) => ($($item)*;) } -/// Helper methods defined by `Server` types not invoked over RPC. -pub trait Context: Types { - fn def_site(&mut self) -> Self::Span; - fn call_site(&mut self) -> Self::Span; - fn mixed_site(&mut self) -> Self::Span; -} - macro_rules! declare_server_traits { ($($name:ident { $(fn $method:ident($($arg:ident: $arg_ty:ty),* $(,)?) $(-> $ret_ty:ty)?;)* @@ -45,23 +38,26 @@ macro_rules! declare_server_traits { $(associated_fn!(fn $method(&mut self, $($arg: $arg_ty),*) $(-> $ret_ty)?);)* })* - pub trait Server: Types + Context $(+ $name)* {} - impl<S: Types + Context $(+ $name)*> Server for S {} + pub trait Server: Types $(+ $name)* { + fn def_site(&mut self) -> Self::Span; + fn call_site(&mut self) -> Self::Span; + fn mixed_site(&mut self) -> Self::Span; + } } } with_api!(Self, self_, declare_server_traits); pub(super) struct MarkedTypes<S: Types>(S); -impl<S: Context> Context for MarkedTypes<S> { +impl<S: Server> Server for MarkedTypes<S> { fn def_site(&mut self) -> Self::Span { - <_>::mark(Context::def_site(&mut self.0)) + <_>::mark(Server::def_site(&mut self.0)) } fn call_site(&mut self) -> Self::Span { - <_>::mark(Context::call_site(&mut self.0)) + <_>::mark(Server::call_site(&mut self.0)) } fn mixed_site(&mut self) -> Self::Span { - <_>::mark(Context::mixed_site(&mut self.0)) + <_>::mark(Server::mixed_site(&mut self.0)) } } |
