Skip to content

Commit 93db30a

Browse files
authoredApr 25, 2022
Rollup merge of #96149 - est31:remove_unused_macro_matchers, r=petrochenkov
Remove unused macro rules Removes rules of internal macros that weren't triggered.
2 parents 51b8684 + 3c1e166 commit 93db30a

File tree

7 files changed

+0
-58
lines changed

7 files changed

+0
-58
lines changed
 

‎compiler/rustc_errors/src/diagnostic_builder.rs

-13
Original file line numberDiff line numberDiff line change
@@ -255,19 +255,6 @@ impl EmissionGuarantee for ! {
255255
/// instead of a `&DiagnosticBuilder<'a>`. This `forward!` macro makes
256256
/// it easy to declare such methods on the builder.
257257
macro_rules! forward {
258-
// Forward pattern for &self -> &Self
259-
(
260-
$(#[$attrs:meta])*
261-
pub fn $n:ident(&self, $($name:ident: $ty:ty),* $(,)?) -> &Self
262-
) => {
263-
$(#[$attrs])*
264-
#[doc = concat!("See [`Diagnostic::", stringify!($n), "()`].")]
265-
pub fn $n(&self, $($name: $ty),*) -> &Self {
266-
self.diagnostic.$n($($name),*);
267-
self
268-
}
269-
};
270-
271258
// Forward pattern for &mut self -> &mut Self
272259
(
273260
$(#[$attrs:meta])*

‎compiler/rustc_middle/src/ty/codec.rs

-3
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,6 @@ macro_rules! impl_arena_allocatable_decoder {
453453
}
454454
}
455455
};
456-
([$ignore:ident $(, $attrs:ident)*]$args:tt) => {
457-
impl_arena_allocatable_decoder!([$($attrs),*]$args);
458-
};
459456
}
460457

461458
macro_rules! impl_arena_allocatable_decoders {

‎compiler/rustc_serialize/src/serialize.rs

-1
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,6 @@ macro_rules! peel {
498498
/// Therefore, the recursion depth is the binary logarithm of the number of
499499
/// tokens to count, and the expanded tree is likewise very small.
500500
macro_rules! count {
501-
() => (0usize);
502501
($one:tt) => (1usize);
503502
($($pairs:tt $_p:tt)*) => (count!($($pairs)*) << 1usize);
504503
($odd:tt $($rest:tt)*) => (count!($($rest)*) | 1usize);

‎compiler/rustc_target/src/spec/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -2249,10 +2249,6 @@ impl ToJson for Target {
22492249
let name = (stringify!($attr)).replace("_", "-");
22502250
d.insert(name, self.$attr.to_json());
22512251
}};
2252-
($attr:ident, $key_name:expr) => {{
2253-
let name = $key_name;
2254-
d.insert(name.into(), self.$attr.to_json());
2255-
}};
22562252
}
22572253

22582254
macro_rules! target_option_val {

‎library/core/src/internal_macros.rs

-24
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
// implements the unary operator "op &T"
22
// based on "op T" where T is expected to be `Copy`able
33
macro_rules! forward_ref_unop {
4-
(impl $imp:ident, $method:ident for $t:ty) => {
5-
forward_ref_unop!(impl $imp, $method for $t,
6-
#[stable(feature = "rust1", since = "1.0.0")]);
7-
};
84
(impl const $imp:ident, $method:ident for $t:ty) => {
95
forward_ref_unop!(impl const $imp, $method for $t,
106
#[stable(feature = "rust1", since = "1.0.0")]);
@@ -38,10 +34,6 @@ macro_rules! forward_ref_unop {
3834
// implements binary operators "&T op U", "T op &U", "&T op &U"
3935
// based on "T op U" where T and U are expected to be `Copy`able
4036
macro_rules! forward_ref_binop {
41-
(impl $imp:ident, $method:ident for $t:ty, $u:ty) => {
42-
forward_ref_binop!(impl $imp, $method for $t, $u,
43-
#[stable(feature = "rust1", since = "1.0.0")]);
44-
};
4537
(impl const $imp:ident, $method:ident for $t:ty, $u:ty) => {
4638
forward_ref_binop!(impl const $imp, $method for $t, $u,
4739
#[stable(feature = "rust1", since = "1.0.0")]);
@@ -230,22 +222,6 @@ macro_rules! cfg_if {
230222
}
231223
};
232224

233-
// match if/else chains lacking a final `else`
234-
(
235-
if #[cfg( $i_meta:meta )] { $( $i_tokens:tt )* }
236-
$(
237-
else if #[cfg( $e_meta:meta )] { $( $e_tokens:tt )* }
238-
)*
239-
) => {
240-
cfg_if! {
241-
@__items () ;
242-
(( $i_meta ) ( $( $i_tokens )* )) ,
243-
$(
244-
(( $e_meta ) ( $( $e_tokens )* )) ,
245-
)*
246-
}
247-
};
248-
249225
// Internal and recursive macro to emit all the items
250226
//
251227
// Collects all the previous cfgs in a list at the beginning, so they can be

‎library/core/tests/num/ops.rs

-12
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,6 @@ macro_rules! impls_defined {
4343
}
4444

4545
macro_rules! test_op {
46-
($fn_name:ident, $op:ident::$method:ident($lhs:literal, $rhs:literal), $result:literal, $($t:ty),+) => {
47-
#[test]
48-
fn $fn_name() {
49-
impls_defined!($op, $method($lhs, $rhs), $result, $($t),+);
50-
}
51-
};
52-
($fn_name:ident, $op:ident::$method:ident(&mut $lhs:literal, $rhs:literal), $result:literal, $($t:ty),+) => {
53-
#[test]
54-
fn $fn_name() {
55-
impls_defined!($op, $method(&mut $lhs, $rhs), $result, $($t),+);
56-
}
57-
};
5846
($fn_name:ident, $op:ident::$method:ident($lhs:literal), $result:literal, $($t:ty),+) => {
5947
#[test]
6048
fn $fn_name() {

‎library/proc_macro/src/quote.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ macro_rules! quote_tt {
1212
({$($t:tt)*}) => { Group::new(Delimiter::Brace, quote!($($t)*)) };
1313
(,) => { Punct::new(',', Spacing::Alone) };
1414
(.) => { Punct::new('.', Spacing::Alone) };
15-
(:) => { Punct::new(':', Spacing::Alone) };
1615
(;) => { Punct::new(';', Spacing::Alone) };
1716
(!) => { Punct::new('!', Spacing::Alone) };
1817
(<) => { Punct::new('<', Spacing::Alone) };

0 commit comments

Comments
 (0)
Please sign in to comment.