about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2022-05-17 07:42:57 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2022-05-27 16:02:24 +1000
commit41c10dde95b447b160a39ae2b7ebfd81faad5e0a (patch)
treeef7797aedd1a1da635e15ad287eed9d8c46c8cb6
parente6fa19a3ce9a060373ea4a6d9305745ff92b342f (diff)
downloadrust-41c10dde95b447b160a39ae2b7ebfd81faad5e0a.tar.gz
rust-41c10dde95b447b160a39ae2b7ebfd81faad5e0a.zip
Cut down `associated_item`.
The part of it dealing with types obfuscates and makes the code less
concise. This commit removes that part.
-rw-r--r--library/proc_macro/src/bridge/server.rs38
1 files changed, 18 insertions, 20 deletions
diff --git a/library/proc_macro/src/bridge/server.rs b/library/proc_macro/src/bridge/server.rs
index b15afa32987..12c754682a0 100644
--- a/library/proc_macro/src/bridge/server.rs
+++ b/library/proc_macro/src/bridge/server.rs
@@ -5,22 +5,24 @@ use super::*;
 // FIXME(eddyb) generate the definition of `HandleStore` in `server.rs`.
 use super::client::HandleStore;
 
-/// Declare an associated item of one of the traits below, optionally
-/// adjusting it (i.e., adding bounds to types and default bodies to methods).
-macro_rules! associated_item {
-    (type FreeFunctions) => (type FreeFunctions: 'static;);
-    (type TokenStream) => (type TokenStream: 'static + Clone;);
-    (type TokenStreamBuilder) => (type TokenStreamBuilder: 'static;);
-    (type TokenStreamIter) => (type TokenStreamIter: 'static + Clone;);
-    (type Group) => (type Group: 'static + Clone;);
-    (type Punct) => (type Punct: 'static + Copy + Eq + Hash;);
-    (type Ident) => (type Ident: 'static + Copy + Eq + Hash;);
-    (type Literal) => (type Literal: 'static + Clone;);
-    (type SourceFile) => (type SourceFile: 'static + Clone;);
-    (type MultiSpan) => (type MultiSpan: 'static;);
-    (type Diagnostic) => (type Diagnostic: 'static;);
-    (type Span) => (type Span: 'static + Copy + Eq + Hash;);
+pub trait Types {
+    type FreeFunctions: 'static;
+    type TokenStream: 'static + Clone;
+    type TokenStreamBuilder: 'static;
+    type TokenStreamIter: 'static + Clone;
+    type Group: 'static + Clone;
+    type Punct: 'static + Copy + Eq + Hash;
+    type Ident: 'static + Copy + Eq + Hash;
+    type Literal: 'static + Clone;
+    type SourceFile: 'static + Clone;
+    type MultiSpan: 'static;
+    type Diagnostic: 'static;
+    type Span: 'static + Copy + Eq + Hash;
+}
 
+/// Declare an associated fn of one of the traits below, adding necessary
+/// default bodies.
+macro_rules! associated_fn {
     (fn drop(&mut self, $arg:ident: $arg_ty:ty)) =>
         (fn drop(&mut self, $arg: $arg_ty) { mem::drop($arg) });
 
@@ -34,12 +36,8 @@ macro_rules! declare_server_traits {
     ($($name:ident {
         $(fn $method:ident($($arg:ident: $arg_ty:ty),* $(,)?) $(-> $ret_ty:ty)?;)*
     }),* $(,)?) => {
-        pub trait Types {
-            $(associated_item!(type $name);)*
-        }
-
         $(pub trait $name: Types {
-            $(associated_item!(fn $method(&mut self, $($arg: $arg_ty),*) $(-> $ret_ty)?);)*
+            $(associated_fn!(fn $method(&mut self, $($arg: $arg_ty),*) $(-> $ret_ty)?);)*
         })*
 
         pub trait Server: Types $(+ $name)* {}