about summary refs log tree commit diff
path: root/src/libproc_macro/bridge
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2019-12-22 17:42:04 -0500
committerMark Rousskov <mark.simulacrum@gmail.com>2019-12-22 17:42:47 -0500
commita06baa56b95674fc626b3c3fd680d6a65357fe60 (patch)
treecd9d867c2ca3cff5c1d6b3bd73377c44649fb075 /src/libproc_macro/bridge
parent8eb7c58dbb7b32701af113bc58722d0d1fefb1eb (diff)
downloadrust-a06baa56b95674fc626b3c3fd680d6a65357fe60.tar.gz
rust-a06baa56b95674fc626b3c3fd680d6a65357fe60.zip
Format the world
Diffstat (limited to 'src/libproc_macro/bridge')
-rw-r--r--src/libproc_macro/bridge/buffer.rs20
-rw-r--r--src/libproc_macro/bridge/client.rs34
-rw-r--r--src/libproc_macro/bridge/closure.rs5
-rw-r--r--src/libproc_macro/bridge/handle.rs22
-rw-r--r--src/libproc_macro/bridge/mod.rs7
-rw-r--r--src/libproc_macro/bridge/server.rs36
6 files changed, 26 insertions, 98 deletions
diff --git a/src/libproc_macro/bridge/buffer.rs b/src/libproc_macro/bridge/buffer.rs
index a51e3a9a33d..aeecbd49662 100644
--- a/src/libproc_macro/bridge/buffer.rs
+++ b/src/libproc_macro/bridge/buffer.rs
@@ -23,10 +23,7 @@ impl<T> Clone for Slice<'a, T> {
 
 impl<T> From<&'a [T]> for Slice<'a, T> {
     fn from(xs: &'a [T]) -> Self {
-        Slice {
-            data: unsafe { &*(xs.as_ptr() as *const [T; 0]) },
-            len: xs.len(),
-        }
+        Slice { data: unsafe { &*(xs.as_ptr() as *const [T; 0]) }, len: xs.len() }
     }
 }
 
@@ -128,12 +125,7 @@ impl<T: Copy> From<Vec<T>> for Buffer<T> {
         // be safely called on `Buffer`s created by *this* `proc_macro`.
         fn to_vec<T: Copy>(b: Buffer<T>) -> Vec<T> {
             unsafe {
-                let Buffer {
-                    data,
-                    len,
-                    capacity,
-                    ..
-                } = b;
+                let Buffer { data, len, capacity, .. } = b;
                 mem::forget(b);
                 Vec::from_raw_parts(data, len, capacity)
             }
@@ -149,12 +141,6 @@ impl<T: Copy> From<Vec<T>> for Buffer<T> {
             mem::drop(to_vec(b));
         }
 
-        Buffer {
-            data,
-            len,
-            capacity,
-            extend_from_slice,
-            drop,
-        }
+        Buffer { data, len, capacity, extend_from_slice, drop }
     }
 }
diff --git a/src/libproc_macro/bridge/client.rs b/src/libproc_macro/bridge/client.rs
index 9643dba997a..dd948025c91 100644
--- a/src/libproc_macro/bridge/client.rs
+++ b/src/libproc_macro/bridge/client.rs
@@ -393,17 +393,13 @@ impl Client<fn(crate::TokenStream) -> crate::TokenStream> {
         ) -> Buffer<u8> {
             run_client(bridge, |input| f(crate::TokenStream(input)).0)
         }
-        Client {
-            get_handle_counters: HandleCounters::get,
-            run,
-            f,
-        }
+        Client { get_handle_counters: HandleCounters::get, run, f }
     }
 }
 
 impl Client<fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream> {
     pub const fn expand2(
-        f: fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream
+        f: fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream,
     ) -> Self {
         extern "C" fn run(
             bridge: Bridge<'_>,
@@ -413,11 +409,7 @@ impl Client<fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream> {
                 f(crate::TokenStream(input), crate::TokenStream(input2)).0
             })
         }
-        Client {
-            get_handle_counters: HandleCounters::get,
-            run,
-            f,
-        }
+        Client { get_handle_counters: HandleCounters::get, run, f }
     }
 }
 
@@ -446,7 +438,7 @@ impl ProcMacro {
         match self {
             ProcMacro::CustomDerive { trait_name, .. } => trait_name,
             ProcMacro::Attr { name, .. } => name,
-            ProcMacro::Bang { name, ..} => name
+            ProcMacro::Bang { name, .. } => name,
         }
     }
 
@@ -455,30 +447,20 @@ impl ProcMacro {
         attributes: &'static [&'static str],
         expand: fn(crate::TokenStream) -> crate::TokenStream,
     ) -> Self {
-        ProcMacro::CustomDerive {
-            trait_name,
-            attributes,
-            client: Client::expand1(expand),
-        }
+        ProcMacro::CustomDerive { trait_name, attributes, client: Client::expand1(expand) }
     }
 
     pub const fn attr(
         name: &'static str,
         expand: fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream,
     ) -> Self {
-        ProcMacro::Attr {
-            name,
-            client: Client::expand2(expand),
-        }
+        ProcMacro::Attr { name, client: Client::expand2(expand) }
     }
 
     pub const fn bang(
         name: &'static str,
-        expand: fn(crate::TokenStream) -> crate::TokenStream
+        expand: fn(crate::TokenStream) -> crate::TokenStream,
     ) -> Self {
-        ProcMacro::Bang {
-            name,
-            client: Client::expand1(expand),
-        }
+        ProcMacro::Bang { name, client: Client::expand1(expand) }
     }
 }
diff --git a/src/libproc_macro/bridge/closure.rs b/src/libproc_macro/bridge/closure.rs
index 8d8adfa1caa..5bfe287d33a 100644
--- a/src/libproc_macro/bridge/closure.rs
+++ b/src/libproc_macro/bridge/closure.rs
@@ -18,10 +18,7 @@ impl<'a, A, R, F: FnMut(A) -> R> From<&'a mut F> for Closure<'a, A, R> {
         unsafe extern "C" fn call<A, R, F: FnMut(A) -> R>(env: &mut Env, arg: A) -> R {
             (*(env as *mut _ as *mut F))(arg)
         }
-        Closure {
-            call: call::<A, R, F>,
-            env: unsafe { &mut *(f as *mut _ as *mut Env) },
-        }
+        Closure { call: call::<A, R, F>, env: unsafe { &mut *(f as *mut _ as *mut Env) } }
     }
 }
 
diff --git a/src/libproc_macro/bridge/handle.rs b/src/libproc_macro/bridge/handle.rs
index 66496ff3f1a..bcbb8681247 100644
--- a/src/libproc_macro/bridge/handle.rs
+++ b/src/libproc_macro/bridge/handle.rs
@@ -19,10 +19,7 @@ impl<T> OwnedStore<T> {
         // when `NonZeroU32::new` (aka `Handle::new`) is called in `alloc`.
         assert_ne!(counter.load(Ordering::SeqCst), 0);
 
-        OwnedStore {
-            counter,
-            data: BTreeMap::new(),
-        }
+        OwnedStore { counter, data: BTreeMap::new() }
     }
 }
 
@@ -35,26 +32,20 @@ impl<T> OwnedStore<T> {
     }
 
     pub(super) fn take(&mut self, h: Handle) -> T {
-        self.data
-            .remove(&h)
-            .expect("use-after-free in `proc_macro` handle")
+        self.data.remove(&h).expect("use-after-free in `proc_macro` handle")
     }
 }
 
 impl<T> Index<Handle> for OwnedStore<T> {
     type Output = T;
     fn index(&self, h: Handle) -> &T {
-        self.data
-            .get(&h)
-            .expect("use-after-free in `proc_macro` handle")
+        self.data.get(&h).expect("use-after-free in `proc_macro` handle")
     }
 }
 
 impl<T> IndexMut<Handle> for OwnedStore<T> {
     fn index_mut(&mut self, h: Handle) -> &mut T {
-        self.data
-            .get_mut(&h)
-            .expect("use-after-free in `proc_macro` handle")
+        self.data.get_mut(&h).expect("use-after-free in `proc_macro` handle")
     }
 }
 
@@ -65,10 +56,7 @@ pub(super) struct InternedStore<T: 'static> {
 
 impl<T: Copy + Eq + Hash> InternedStore<T> {
     pub(super) fn new(counter: &'static AtomicUsize) -> Self {
-        InternedStore {
-            owned: OwnedStore::new(counter),
-            interner: HashMap::new(),
-        }
+        InternedStore { owned: OwnedStore::new(counter), interner: HashMap::new() }
     }
 
     pub(super) fn alloc(&mut self, x: T) -> Handle {
diff --git a/src/libproc_macro/bridge/mod.rs b/src/libproc_macro/bridge/mod.rs
index c26b59f473c..a0e7d90f497 100644
--- a/src/libproc_macro/bridge/mod.rs
+++ b/src/libproc_macro/bridge/mod.rs
@@ -8,6 +8,7 @@
 
 #![deny(unsafe_code)]
 
+use crate::{Delimiter, Level, LineColumn, Spacing};
 use std::fmt;
 use std::hash::Hash;
 use std::marker;
@@ -17,7 +18,6 @@ use std::panic;
 use std::sync::atomic::AtomicUsize;
 use std::sync::Once;
 use std::thread;
-use crate::{Delimiter, Level, LineColumn, Spacing};
 
 /// Higher-order macro describing the server RPC API, allowing automatic
 /// generation of type-safe Rust APIs, both client-side and server-side.
@@ -270,10 +270,7 @@ struct Marked<T, M> {
 impl<T, M> Mark for Marked<T, M> {
     type Unmarked = T;
     fn mark(unmarked: Self::Unmarked) -> Self {
-        Marked {
-            value: unmarked,
-            _marker: marker::PhantomData,
-        }
+        Marked { value: unmarked, _marker: marker::PhantomData }
     }
 }
 impl<T, M> Unmark for Marked<T, M> {
diff --git a/src/libproc_macro/bridge/server.rs b/src/libproc_macro/bridge/server.rs
index f303e3e8288..ca18d4459aa 100644
--- a/src/libproc_macro/bridge/server.rs
+++ b/src/libproc_macro/bridge/server.rs
@@ -148,13 +148,7 @@ impl ExecutionStrategy for SameThread {
     ) -> Buffer<u8> {
         let mut dispatch = |b| dispatcher.dispatch(b);
 
-        run_client(
-            Bridge {
-                cached_buffer: input,
-                dispatch: (&mut dispatch).into(),
-            },
-            client_data,
-        )
+        run_client(Bridge { cached_buffer: input, dispatch: (&mut dispatch).into() }, client_data)
     }
 }
 
@@ -183,10 +177,7 @@ impl ExecutionStrategy for CrossThread1 {
             };
 
             run_client(
-                Bridge {
-                    cached_buffer: input,
-                    dispatch: (&mut dispatch).into(),
-                },
+                Bridge { cached_buffer: input, dispatch: (&mut dispatch).into() },
                 client_data,
             )
         });
@@ -233,10 +224,7 @@ impl ExecutionStrategy for CrossThread2 {
             };
 
             let r = run_client(
-                Bridge {
-                    cached_buffer: input,
-                    dispatch: (&mut dispatch).into(),
-                },
+                Bridge { cached_buffer: input, dispatch: (&mut dispatch).into() },
                 client_data,
             );
 
@@ -276,10 +264,8 @@ fn run_server<
     run_client: extern "C" fn(Bridge<'_>, D) -> Buffer<u8>,
     client_data: D,
 ) -> Result<O, PanicMessage> {
-    let mut dispatcher = Dispatcher {
-        handle_store: HandleStore::new(handle_counters),
-        server: MarkedTypes(server),
-    };
+    let mut dispatcher =
+        Dispatcher { handle_store: HandleStore::new(handle_counters), server: MarkedTypes(server) };
 
     let mut b = Buffer::new();
     input.encode(&mut b, &mut dispatcher.handle_store);
@@ -296,11 +282,7 @@ impl client::Client<fn(crate::TokenStream) -> crate::TokenStream> {
         server: S,
         input: S::TokenStream,
     ) -> Result<S::TokenStream, PanicMessage> {
-        let client::Client {
-            get_handle_counters,
-            run,
-            f,
-        } = *self;
+        let client::Client { get_handle_counters, run, f } = *self;
         run_server(
             strategy,
             get_handle_counters(),
@@ -321,11 +303,7 @@ impl client::Client<fn(crate::TokenStream, crate::TokenStream) -> crate::TokenSt
         input: S::TokenStream,
         input2: S::TokenStream,
     ) -> Result<S::TokenStream, PanicMessage> {
-        let client::Client {
-            get_handle_counters,
-            run,
-            f,
-        } = *self;
+        let client::Client { get_handle_counters, run, f } = *self;
         run_server(
             strategy,
             get_handle_counters(),