Skip to content

Commit ea9de33

Browse files
authored
Unrolled build for #147166
Rollup merge of #147166 - cyrgani:proc-macro-cleanup-1, r=petrochenkov several small `proc_macro` cleanups
2 parents 42d009c + d7773f6 commit ea9de33

File tree

5 files changed

+14
-54
lines changed

5 files changed

+14
-54
lines changed

library/proc_macro/src/bridge/client.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,16 @@ macro_rules! define_client_handles {
2626
$(
2727
pub(crate) struct $oty {
2828
handle: handle::Handle,
29-
// Prevent Send and Sync impls. `!Send`/`!Sync` is the usual
30-
// way of doing this, but that requires unstable features.
31-
// rust-analyzer uses this code and avoids unstable features.
32-
_marker: PhantomData<*mut ()>,
3329
}
3430

31+
impl !Send for $oty {}
32+
impl !Sync for $oty {}
33+
3534
// Forward `Drop::drop` to the inherent `drop` method.
3635
impl Drop for $oty {
3736
fn drop(&mut self) {
3837
$oty {
3938
handle: self.handle,
40-
_marker: PhantomData,
4139
}.drop();
4240
}
4341
}
@@ -64,7 +62,6 @@ macro_rules! define_client_handles {
6462
fn decode(r: &mut Reader<'_>, s: &mut S) -> Self {
6563
$oty {
6664
handle: handle::Handle::decode(r, s),
67-
_marker: PhantomData,
6865
}
6966
}
7067
}
@@ -74,12 +71,11 @@ macro_rules! define_client_handles {
7471
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
7572
pub(crate) struct $ity {
7673
handle: handle::Handle,
77-
// Prevent Send and Sync impls. `!Send`/`!Sync` is the usual
78-
// way of doing this, but that requires unstable features.
79-
// rust-analyzer uses this code and avoids unstable features.
80-
_marker: PhantomData<*mut ()>,
8174
}
8275

76+
impl !Send for $ity {}
77+
impl !Sync for $ity {}
78+
8379
impl<S> Encode<S> for $ity {
8480
fn encode(self, w: &mut Writer, s: &mut S) {
8581
self.handle.encode(w, s);
@@ -90,7 +86,6 @@ macro_rules! define_client_handles {
9086
fn decode(r: &mut Reader<'_>, s: &mut S) -> Self {
9187
$ity {
9288
handle: handle::Handle::decode(r, s),
93-
_marker: PhantomData,
9489
}
9590
}
9691
}
@@ -144,7 +139,7 @@ macro_rules! define_client_side {
144139

145140
buf.clear();
146141
api_tags::Method::$name(api_tags::$name::$method).encode(&mut buf, &mut ());
147-
reverse_encode!(buf; $($arg),*);
142+
$($arg.encode(&mut buf, &mut ());)*
148143

149144
buf = bridge.dispatch.call(buf);
150145

library/proc_macro/src/bridge/closure.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ use std::marker::PhantomData;
66
pub(super) struct Closure<'a, A, R> {
77
call: unsafe extern "C" fn(*mut Env, A) -> R,
88
env: *mut Env,
9-
// Prevent Send and Sync impls. `!Send`/`!Sync` is the usual way of doing
10-
// this, but that requires unstable features. rust-analyzer uses this code
11-
// and avoids unstable features.
9+
// Prevent Send and Sync impls.
1210
//
1311
// The `'a` lifetime parameter represents the lifetime of `Env`.
1412
_marker: PhantomData<*mut &'a mut ()>,

library/proc_macro/src/bridge/mod.rs

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -119,26 +119,6 @@ macro_rules! with_api_handle_types {
119119
};
120120
}
121121

122-
// FIXME(eddyb) this calls `encode` for each argument, but in reverse,
123-
// to match the ordering in `reverse_decode`.
124-
macro_rules! reverse_encode {
125-
($writer:ident;) => {};
126-
($writer:ident; $first:ident $(, $rest:ident)*) => {
127-
reverse_encode!($writer; $($rest),*);
128-
$first.encode(&mut $writer, &mut ());
129-
}
130-
}
131-
132-
// FIXME(eddyb) this calls `decode` for each argument, but in reverse,
133-
// to avoid borrow conflicts from borrows started by `&mut` arguments.
134-
macro_rules! reverse_decode {
135-
($reader:ident, $s:ident;) => {};
136-
($reader:ident, $s:ident; $first:ident: $first_ty:ty $(, $rest:ident: $rest_ty:ty)*) => {
137-
reverse_decode!($reader, $s; $($rest: $rest_ty),*);
138-
let $first = <$first_ty>::decode(&mut $reader, $s);
139-
}
140-
}
141-
142122
#[allow(unsafe_code)]
143123
mod arena;
144124
#[allow(unsafe_code)]
@@ -180,13 +160,11 @@ pub struct BridgeConfig<'a> {
180160

181161
/// If 'true', always invoke the default panic hook
182162
force_show_panics: bool,
183-
184-
// Prevent Send and Sync impls. `!Send`/`!Sync` is the usual way of doing
185-
// this, but that requires unstable features. rust-analyzer uses this code
186-
// and avoids unstable features.
187-
_marker: marker::PhantomData<*mut ()>,
188163
}
189164

165+
impl !Send for BridgeConfig<'_> {}
166+
impl !Sync for BridgeConfig<'_> {}
167+
190168
#[forbid(unsafe_code)]
191169
#[allow(non_camel_case_types)]
192170
mod api_tags {

library/proc_macro/src/bridge/server.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ macro_rules! define_dispatcher_impl {
178178
$(api_tags::Method::$name(m) => match m {
179179
$(api_tags::$name::$method => {
180180
let mut call_method = || {
181-
reverse_decode!(reader, handle_store; $($arg: $arg_ty),*);
181+
$(let $arg = <$arg_ty>::decode(&mut reader, handle_store);)*
182182
$name::$method(server, $($arg),*)
183183
};
184184
// HACK(eddyb) don't use `panic::catch_unwind` in a panic.
@@ -295,12 +295,7 @@ impl ExecutionStrategy for SameThread {
295295

296296
let mut dispatch = |buf| dispatcher.dispatch(buf);
297297

298-
run_client(BridgeConfig {
299-
input,
300-
dispatch: (&mut dispatch).into(),
301-
force_show_panics,
302-
_marker: marker::PhantomData,
303-
})
298+
run_client(BridgeConfig { input, dispatch: (&mut dispatch).into(), force_show_panics })
304299
}
305300
}
306301

@@ -331,12 +326,7 @@ where
331326
client.recv().expect("server died while client waiting for reply")
332327
};
333328

334-
run_client(BridgeConfig {
335-
input,
336-
dispatch: (&mut dispatch).into(),
337-
force_show_panics,
338-
_marker: marker::PhantomData,
339-
})
329+
run_client(BridgeConfig { input, dispatch: (&mut dispatch).into(), force_show_panics })
340330
});
341331

342332
while let Some(b) = server.recv() {

library/proc_macro/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#![feature(panic_can_unwind)]
2828
#![feature(restricted_std)]
2929
#![feature(rustc_attrs)]
30-
#![feature(stmt_expr_attributes)]
3130
#![feature(extend_one)]
3231
#![recursion_limit = "256"]
3332
#![allow(internal_features)]

0 commit comments

Comments
 (0)