Skip to content

Commit 74380b3

Browse files
authored
Rollup merge of #62068 - ia0:fix_meta_var, r=petrochenkov
Fix meta-variable binding errors in macros The errors are either: - The meta-variable used in the right-hand side is not bound (or defined) in the left-hand side. - The meta-variable used in the right-hand side does not repeat with the same kleene operator as its binder in the left-hand side. Either it does not repeat enough, or it uses a different operator somewhere. This change should have no semantic impact. Found by #62008
2 parents 07c82e1 + b8106b5 commit 74380b3

File tree

16 files changed

+46
-46
lines changed

16 files changed

+46
-46
lines changed

src/libcore/fmt/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2070,19 +2070,19 @@ macro_rules! tuple {
20702070
() => ();
20712071
( $($name:ident,)+ ) => (
20722072
#[stable(feature = "rust1", since = "1.0.0")]
2073-
impl<$($name:Debug),*> Debug for ($($name,)*) where last_type!($($name,)+): ?Sized {
2073+
impl<$($name:Debug),+> Debug for ($($name,)+) where last_type!($($name,)+): ?Sized {
20742074
#[allow(non_snake_case, unused_assignments)]
20752075
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
20762076
let mut builder = f.debug_tuple("");
2077-
let ($(ref $name,)*) = *self;
2077+
let ($(ref $name,)+) = *self;
20782078
$(
20792079
builder.field(&$name);
2080-
)*
2080+
)+
20812081

20822082
builder.finish()
20832083
}
20842084
}
2085-
peel! { $($name,)* }
2085+
peel! { $($name,)+ }
20862086
)
20872087
}
20882088

src/libcore/hash/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -617,11 +617,11 @@ mod impls {
617617

618618
( $($name:ident)+) => (
619619
#[stable(feature = "rust1", since = "1.0.0")]
620-
impl<$($name: Hash),*> Hash for ($($name,)*) where last_type!($($name,)+): ?Sized {
620+
impl<$($name: Hash),+> Hash for ($($name,)+) where last_type!($($name,)+): ?Sized {
621621
#[allow(non_snake_case)]
622622
fn hash<S: Hasher>(&self, state: &mut S) {
623-
let ($(ref $name,)*) = *self;
624-
$($name.hash(state);)*
623+
let ($(ref $name,)+) = *self;
624+
$($name.hash(state);)+
625625
}
626626
}
627627
);

src/libcore/iter/traits/accum.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ macro_rules! integer_sum_product {
7272
($($a:ty)*) => (
7373
integer_sum_product!(@impls 0, 1,
7474
#[stable(feature = "iter_arith_traits", since = "1.12.0")],
75-
$($a)+);
75+
$($a)*);
7676
integer_sum_product!(@impls Wrapping(0), Wrapping(1),
7777
#[stable(feature = "wrapping_iter_arith", since = "1.14.0")],
78-
$(Wrapping<$a>)+);
78+
$(Wrapping<$a>)*);
7979
);
8080
}
8181

src/libcore/macros.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ macro_rules! panic {
1515
$crate::panic!($msg)
1616
);
1717
($fmt:expr, $($arg:tt)+) => ({
18-
$crate::panicking::panic_fmt(format_args!($fmt, $($arg)*),
18+
$crate::panicking::panic_fmt(format_args!($fmt, $($arg)+),
1919
&(file!(), line!(), __rust_unstable_column!()))
2020
});
2121
}
@@ -558,7 +558,7 @@ macro_rules! unreachable {
558558
#[stable(feature = "rust1", since = "1.0.0")]
559559
macro_rules! unimplemented {
560560
() => (panic!("not yet implemented"));
561-
($($arg:tt)+) => (panic!("not yet implemented: {}", format_args!($($arg)*)));
561+
($($arg:tt)+) => (panic!("not yet implemented: {}", format_args!($($arg)+)));
562562
}
563563

564564
/// Indicates unfinished code.
@@ -617,7 +617,7 @@ macro_rules! unimplemented {
617617
#[unstable(feature = "todo_macro", issue = "59277")]
618618
macro_rules! todo {
619619
() => (panic!("not yet implemented"));
620-
($($arg:tt)+) => (panic!("not yet implemented: {}", format_args!($($arg)*)));
620+
($($arg:tt)+) => (panic!("not yet implemented: {}", format_args!($($arg)+)));
621621
}
622622

623623
/// Creates an array of [`MaybeUninit`].

src/libcore/ptr/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2725,12 +2725,12 @@ macro_rules! fnptr_impls_safety_abi {
27252725

27262726
macro_rules! fnptr_impls_args {
27272727
($($Arg: ident),+) => {
2728-
fnptr_impls_safety_abi! { extern "Rust" fn($($Arg),*) -> Ret, $($Arg),* }
2729-
fnptr_impls_safety_abi! { extern "C" fn($($Arg),*) -> Ret, $($Arg),* }
2730-
fnptr_impls_safety_abi! { extern "C" fn($($Arg),* , ...) -> Ret, $($Arg),* }
2731-
fnptr_impls_safety_abi! { unsafe extern "Rust" fn($($Arg),*) -> Ret, $($Arg),* }
2732-
fnptr_impls_safety_abi! { unsafe extern "C" fn($($Arg),*) -> Ret, $($Arg),* }
2733-
fnptr_impls_safety_abi! { unsafe extern "C" fn($($Arg),* , ...) -> Ret, $($Arg),* }
2728+
fnptr_impls_safety_abi! { extern "Rust" fn($($Arg),+) -> Ret, $($Arg),+ }
2729+
fnptr_impls_safety_abi! { extern "C" fn($($Arg),+) -> Ret, $($Arg),+ }
2730+
fnptr_impls_safety_abi! { extern "C" fn($($Arg),+ , ...) -> Ret, $($Arg),+ }
2731+
fnptr_impls_safety_abi! { unsafe extern "Rust" fn($($Arg),+) -> Ret, $($Arg),+ }
2732+
fnptr_impls_safety_abi! { unsafe extern "C" fn($($Arg),+) -> Ret, $($Arg),+ }
2733+
fnptr_impls_safety_abi! { unsafe extern "C" fn($($Arg),+ , ...) -> Ret, $($Arg),+ }
27342734
};
27352735
() => {
27362736
// No variadic functions with 0 parameters

src/libproc_macro/bridge/rpc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ macro_rules! rpc_encode_decode {
5959
}
6060
};
6161
(enum $name:ident $(<$($T:ident),+>)? { $($variant:ident $(($field:ident))*),* $(,)? }) => {
62-
impl<S, $($($T: Encode<S>),+)?> Encode<S> for $name $(<$($T),+>)* {
62+
impl<S, $($($T: Encode<S>),+)?> Encode<S> for $name $(<$($T),+>)? {
6363
fn encode(self, w: &mut Writer, s: &mut S) {
6464
// HACK(eddyb): `Tag` enum duplicated between the
6565
// two impls as there's no other place to stash it.
@@ -79,8 +79,8 @@ macro_rules! rpc_encode_decode {
7979
}
8080
}
8181

82-
impl<S, $($($T: for<'s> DecodeMut<'a, 's, S>),+)*> DecodeMut<'a, '_, S>
83-
for $name $(<$($T),+>)*
82+
impl<S, $($($T: for<'s> DecodeMut<'a, 's, S>),+)?> DecodeMut<'a, '_, S>
83+
for $name $(<$($T),+>)?
8484
{
8585
fn decode(r: &mut Reader<'a>, s: &mut S) -> Self {
8686
// HACK(eddyb): `Tag` enum duplicated between the

src/librustc/middle/weak_lang_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl<'tcx> TyCtxt<'tcx> {
147147
let lang_items = self.lang_items();
148148
let did = Some(item_def_id);
149149

150-
$(lang_items.$name() == did)||+
150+
$(lang_items.$name() == did)||*
151151
}
152152
}
153153

src/librustc_codegen_llvm/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ macro_rules! builder_methods_for_value_instructions {
110110
unsafe {
111111
llvm::$llvm_capi(self.llbuilder, $($arg,)* UNNAMED)
112112
}
113-
})*
113+
})+
114114
}
115115
}
116116

src/librustc_data_structures/indexed_vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ macro_rules! newtype_index {
423423
(@derives [$($derives:ident,)*]
424424
@attrs [$(#[$attrs:meta])*]
425425
@type [$type:ident]
426-
@max [$_max:expr]
426+
@max [$max:expr]
427427
@vis [$v:vis]
428428
@debug_format [$debug_format:tt]
429429
$(#[doc = $doc:expr])*

src/librustc_lint/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ fn get_type_suggestion(t: Ty<'_>, val: u128, negative: bool) -> Option<String> {
219219
return Some(format!("{:?}", $itypes))
220220
})*
221221
None
222-
},)*
222+
},)+
223223
_ => None
224224
}
225225
}

0 commit comments

Comments
 (0)