diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs
index 571f35a2031d2..cdbf9b6f92e22 100644
--- a/src/liballoc/collections/vec_deque.rs
+++ b/src/liballoc/collections/vec_deque.rs
@@ -2389,7 +2389,7 @@ __impl_slice_eq1! { VecDeque, &'b [B] }
__impl_slice_eq1! { VecDeque, &'b mut [B] }
macro_rules! array_impls {
- ($($N: expr)+) => {
+ ($($N: expr),+) => {
$(
__impl_slice_eq1! { VecDeque, [B; $N] }
__impl_slice_eq1! { VecDeque, &'b [B; $N] }
@@ -2399,10 +2399,10 @@ macro_rules! array_impls {
}
array_impls! {
- 0 1 2 3 4 5 6 7 8 9
- 10 11 12 13 14 15 16 17 18 19
- 20 21 22 23 24 25 26 27 28 29
- 30 31 32
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
+ 30, 31, 32
}
#[stable(feature = "rust1", since = "1.0.0")]
diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs
index f7a0bbdceafc9..155dd0c976f5e 100644
--- a/src/liballoc/vec.rs
+++ b/src/liballoc/vec.rs
@@ -2065,7 +2065,7 @@ __impl_slice_eq1! { Cow<'a, [A]>, &'b mut [B], Clone }
__impl_slice_eq1! { Cow<'a, [A]>, Vec, Clone }
macro_rules! array_impls {
- ($($N: expr)+) => {
+ ($($N: expr),+) => {
$(
// NOTE: some less important impls are omitted to reduce code bloat
__impl_slice_eq1! { Vec, [B; $N] }
@@ -2079,10 +2079,10 @@ macro_rules! array_impls {
}
array_impls! {
- 0 1 2 3 4 5 6 7 8 9
- 10 11 12 13 14 15 16 17 18 19
- 20 21 22 23 24 25 26 27 28 29
- 30 31 32
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
+ 30, 31, 32
}
/// Implements comparison of vectors, lexicographically.
diff --git a/src/libcore/array.rs b/src/libcore/array.rs
index 3d24f8902bd83..fb57fa3a9132e 100644
--- a/src/libcore/array.rs
+++ b/src/libcore/array.rs
@@ -116,7 +116,7 @@ macro_rules! __impl_slice_eq2 {
// macro for implementing n-element array functions and operations
macro_rules! array_impls {
- ($($N:expr)+) => {
+ ($($N:expr),+) => {
$(
#[stable(feature = "rust1", since = "1.0.0")]
impl AsRef<[T]> for [T; $N] {
@@ -257,10 +257,10 @@ macro_rules! array_impls {
}
array_impls! {
- 0 1 2 3 4 5 6 7 8 9
- 10 11 12 13 14 15 16 17 18 19
- 20 21 22 23 24 25 26 27 28 29
- 30 31 32
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
+ 30, 31, 32
}
// The Default impls cannot be generated using the array_impls! macro because
diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs
index 46bb580dcddb1..e771ba451ef93 100644
--- a/src/libcore/clone.rs
+++ b/src/libcore/clone.rs
@@ -158,7 +158,7 @@ mod impls {
use super::Clone;
macro_rules! impl_clone {
- ($($t:ty)*) => {
+ ($($t:ty),*) => {
$(
#[stable(feature = "rust1", since = "1.0.0")]
impl Clone for $t {
@@ -172,10 +172,10 @@ mod impls {
}
impl_clone! {
- usize u8 u16 u32 u64 u128
- isize i8 i16 i32 i64 i128
- f32 f64
- bool char
+ usize, u8, u16, u32, u64, u128,
+ isize, i8, i16, i32, i64, i128,
+ f32, f64,
+ bool, char
}
#[unstable(feature = "never_type", issue = "35121")]
diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs
index 33881de30527e..02fc4979f723a 100644
--- a/src/libcore/cmp.rs
+++ b/src/libcore/cmp.rs
@@ -863,7 +863,7 @@ mod impls {
use cmp::Ordering::{self, Less, Greater, Equal};
macro_rules! partial_eq_impl {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
impl PartialEq for $t {
#[inline]
@@ -883,20 +883,20 @@ mod impls {
}
partial_eq_impl! {
- bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64
+ bool, char, usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128, f32, f64
}
macro_rules! eq_impl {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
impl Eq for $t {}
)*)
}
- eq_impl! { () bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
+ eq_impl! { (), bool, char, usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128 }
macro_rules! partial_ord_impl {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
impl PartialOrd for $t {
#[inline]
@@ -936,10 +936,10 @@ mod impls {
}
}
- partial_ord_impl! { f32 f64 }
+ partial_ord_impl! { f32, f64 }
macro_rules! ord_impl {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
impl PartialOrd for $t {
#[inline]
@@ -982,7 +982,7 @@ mod impls {
}
}
- ord_impl! { char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
+ ord_impl! { char, usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128 }
#[unstable(feature = "never_type", issue = "35121")]
impl PartialEq for ! {
diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs
index 55addd86bc1ce..02d76cb39d01e 100644
--- a/src/libcore/iter/range.rs
+++ b/src/libcore/iter/range.rs
@@ -72,7 +72,7 @@ macro_rules! step_identical_methods {
}
macro_rules! step_impl_unsigned {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
#[unstable(feature = "step_trait",
reason = "likely to be replaced by finer-grained traits",
issue = "42168")]
@@ -145,7 +145,7 @@ macro_rules! step_impl_signed {
}
macro_rules! step_impl_no_between {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
#[unstable(feature = "step_trait",
reason = "likely to be replaced by finer-grained traits",
issue = "42168")]
@@ -165,7 +165,7 @@ macro_rules! step_impl_no_between {
)*)
}
-step_impl_unsigned!(usize u8 u16);
+step_impl_unsigned!(usize, u8, u16);
#[cfg(not(target_pointer_witdth = "16"))]
step_impl_unsigned!(u32);
#[cfg(target_pointer_witdth = "16")]
@@ -182,32 +182,32 @@ step_impl_signed!([i64: u64]);
// If the target pointer width is not 64-bits, we
// assume here that it is less than 64-bits.
#[cfg(not(target_pointer_width = "64"))]
-step_impl_no_between!(u64 i64);
-step_impl_no_between!(u128 i128);
+step_impl_no_between!(u64, i64);
+step_impl_no_between!(u128, i128);
macro_rules! range_exact_iter_impl {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
impl ExactSizeIterator for ops::Range<$t> { }
)*)
}
macro_rules! range_incl_exact_iter_impl {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
#[stable(feature = "inclusive_range", since = "1.26.0")]
impl ExactSizeIterator for ops::RangeInclusive<$t> { }
)*)
}
macro_rules! range_trusted_len_impl {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl TrustedLen for ops::Range<$t> { }
)*)
}
macro_rules! range_incl_trusted_len_impl {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
#[unstable(feature = "trusted_len", issue = "37572")]
unsafe impl TrustedLen for ops::RangeInclusive<$t> { }
)*)
@@ -276,15 +276,15 @@ impl Iterator for ops::Range {
// Range<{u,i}64> and RangeInclusive<{u,i}{32,64,size}> are excluded
// because they cannot guarantee having a length <= usize::MAX, which is
// required by ExactSizeIterator.
-range_exact_iter_impl!(usize u8 u16 u32 isize i8 i16 i32);
-range_incl_exact_iter_impl!(u8 u16 i8 i16);
+range_exact_iter_impl!(usize, u8, u16, u32, isize, i8, i16, i32);
+range_incl_exact_iter_impl!(u8, u16, i8, i16);
// These macros generate `TrustedLen` impls.
//
// They need to guarantee that .size_hint() is either exact, or that
// the upper bound is None when it does not fit the type limits.
-range_trusted_len_impl!(usize isize u8 i8 u16 i16 u32 i32 i64 u64);
-range_incl_trusted_len_impl!(usize isize u8 i8 u16 i16 u32 i32 i64 u64);
+range_trusted_len_impl!(usize, isize, u8, i8, u16, i16, u32, i32, i64, u64);
+range_incl_trusted_len_impl!(usize, isize, u8, i8, u16, i16, u32, i32, i64, u64);
#[stable(feature = "rust1", since = "1.0.0")]
impl DoubleEndedIterator for ops::Range {
diff --git a/src/libcore/iter/traits.rs b/src/libcore/iter/traits.rs
index f95f8e7dbcbb6..5c357cf655e52 100644
--- a/src/libcore/iter/traits.rs
+++ b/src/libcore/iter/traits.rs
@@ -772,7 +772,7 @@ pub trait Product: Sized {
// NB: explicitly use Add and Mul here to inherit overflow checks
macro_rules! integer_sum_product {
- (@impls $zero:expr, $one:expr, #[$attr:meta], $($a:ty)*) => ($(
+ (@impls $zero:expr, $one:expr, #[$attr:meta], $($a:ty),*) => ($(
#[$attr]
impl Sum for $a {
fn sum>(iter: I) -> $a {
@@ -801,13 +801,13 @@ macro_rules! integer_sum_product {
}
}
)*);
- ($($a:ty)*) => (
+ ($($a:ty),*) => (
integer_sum_product!(@impls 0, 1,
#[stable(feature = "iter_arith_traits", since = "1.12.0")],
- $($a)+);
+ $($a),+);
integer_sum_product!(@impls Wrapping(0), Wrapping(1),
#[stable(feature = "wrapping_iter_arith", since = "1.14.0")],
- $(Wrapping<$a>)+);
+ $(Wrapping<$a>),+);
);
}
@@ -843,7 +843,7 @@ macro_rules! float_sum_product {
)*)
}
-integer_sum_product! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize }
+integer_sum_product! { i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize }
float_sum_product! { f32 f64 }
/// An iterator adapter that produces output as long as the underlying
diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs
index 662a8ddd96862..32cee0d346003 100644
--- a/src/libcore/marker.rs
+++ b/src/libcore/marker.rs
@@ -664,7 +664,7 @@ mod copy_impls {
use super::Copy;
macro_rules! impl_copy {
- ($($t:ty)*) => {
+ ($($t:ty),*) => {
$(
#[stable(feature = "rust1", since = "1.0.0")]
impl Copy for $t {}
@@ -673,10 +673,10 @@ mod copy_impls {
}
impl_copy! {
- usize u8 u16 u32 u64 u128
- isize i8 i16 i32 i64 i128
- f32 f64
- bool char
+ usize, u8, u16, u32, u64, u128,
+ isize, i8, i16, i32, i64, i128,
+ f32, f64,
+ bool, char
}
#[unstable(feature = "never_type", issue = "35121")]
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index 772502cc800e8..9d03548249784 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -4421,7 +4421,7 @@ pub enum FpCategory {
}
macro_rules! from_str_radix_int_impl {
- ($($t:ty)*) => {$(
+ ($($t:ty),*) => {$(
#[stable(feature = "rust1", since = "1.0.0")]
impl FromStr for $t {
type Err = ParseIntError;
@@ -4431,7 +4431,7 @@ macro_rules! from_str_radix_int_impl {
}
)*}
}
-from_str_radix_int_impl! { isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128 }
+from_str_radix_int_impl! { isize, i8, i16, i32, i64, i128, usize, u8, u16, u32, u64, u128 }
/// The error type returned when a checked integral type conversion fails.
#[unstable(feature = "try_from", issue = "33417")]
@@ -4662,7 +4662,7 @@ trait FromStrRadixHelper: PartialOrd + Copy {
}
macro_rules! doit {
- ($($t:ty)*) => ($(impl FromStrRadixHelper for $t {
+ ($($t:ty),*) => ($(impl FromStrRadixHelper for $t {
#[inline]
fn min_value() -> Self { Self::min_value() }
#[inline]
@@ -4683,7 +4683,7 @@ macro_rules! doit {
}
})*)
}
-doit! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize }
+doit! { i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize }
fn from_str_radix(src: &str, radix: u32) -> Result {
use self::IntErrorKind::*;
diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs
index 1c826c2fa76bd..e5a74ec72c7a2 100644
--- a/src/libcore/num/wrapping.rs
+++ b/src/libcore/num/wrapping.rs
@@ -128,7 +128,7 @@ sh_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
// FIXME(30524): impl Op for Wrapping, impl OpAssign for Wrapping
macro_rules! wrapping_impl {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
impl Add for Wrapping<$t> {
type Output = Wrapping<$t>;
@@ -323,10 +323,10 @@ macro_rules! wrapping_impl {
)*)
}
-wrapping_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
+wrapping_impl! { usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128 }
macro_rules! wrapping_int_impl {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
impl Wrapping<$t> {
doc_comment! {
concat!("Returns the smallest value that can be represented by this integer type.
@@ -685,10 +685,10 @@ assert_eq!(Wrapping(3i8).pow(6), Wrapping(-39));
)*)
}
-wrapping_int_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
+wrapping_int_impl! { usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128 }
macro_rules! wrapping_int_impl_signed {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
impl Wrapping<$t> {
doc_comment! {
concat!("Returns the number of leading zeros in the binary representation of `self`.
@@ -814,10 +814,10 @@ assert!(!Wrapping(10", stringify!($t), ").is_negative());
)*)
}
-wrapping_int_impl_signed! { isize i8 i16 i32 i64 i128 }
+wrapping_int_impl_signed! { isize, i8, i16, i32, i64, i128 }
macro_rules! wrapping_int_impl_unsigned {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
impl Wrapping<$t> {
doc_comment! {
concat!("Returns the number of leading zeros in the binary representation of `self`.
@@ -891,7 +891,7 @@ assert_eq!(Wrapping(200_u8).next_power_of_two(), Wrapping(0));
)*)
}
-wrapping_int_impl_unsigned! { usize u8 u16 u32 u64 u128 }
+wrapping_int_impl_unsigned! { usize, u8, u16, u32, u64, u128 }
mod shift_max {
#![allow(non_upper_case_globals)]
diff --git a/src/libcore/ops/arith.rs b/src/libcore/ops/arith.rs
index a1bc5463f7333..d0c5aead345a8 100644
--- a/src/libcore/ops/arith.rs
+++ b/src/libcore/ops/arith.rs
@@ -100,7 +100,7 @@ pub trait Add {
}
macro_rules! add_impl {
- ($($t:ty)*) => ($(
+ ($($t:ty), *) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
impl Add for $t {
type Output = $t;
@@ -114,7 +114,7 @@ macro_rules! add_impl {
)*)
}
-add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
+add_impl! { usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128, f32, f64 }
/// The subtraction operator `-`.
///
@@ -198,7 +198,7 @@ pub trait Sub {
}
macro_rules! sub_impl {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
impl Sub for $t {
type Output = $t;
@@ -212,7 +212,7 @@ macro_rules! sub_impl {
)*)
}
-sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
+sub_impl! { usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128, f32, f64 }
/// The multiplication operator `*`.
///
@@ -318,7 +318,7 @@ pub trait Mul {
}
macro_rules! mul_impl {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
impl Mul for $t {
type Output = $t;
@@ -332,7 +332,7 @@ macro_rules! mul_impl {
)*)
}
-mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
+mul_impl! { usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128, f32, f64 }
/// The division operator `/`.
///
@@ -442,7 +442,7 @@ pub trait Div {
}
macro_rules! div_impl_integer {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
/// This operation rounds towards zero, truncating any
/// fractional part of the exact result.
#[stable(feature = "rust1", since = "1.0.0")]
@@ -457,10 +457,10 @@ macro_rules! div_impl_integer {
)*)
}
-div_impl_integer! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
+div_impl_integer! { usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128 }
macro_rules! div_impl_float {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
impl Div for $t {
type Output = $t;
@@ -473,7 +473,7 @@ macro_rules! div_impl_float {
)*)
}
-div_impl_float! { f32 f64 }
+div_impl_float! { f32, f64 }
/// The remainder operator `%`.
///
@@ -527,7 +527,7 @@ pub trait Rem {
}
macro_rules! rem_impl_integer {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
/// This operation satisfies `n % d == n - (n / d) * d`. The
/// result has the same sign as the left operand.
#[stable(feature = "rust1", since = "1.0.0")]
@@ -542,11 +542,10 @@ macro_rules! rem_impl_integer {
)*)
}
-rem_impl_integer! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
-
+rem_impl_integer! { usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128 }
macro_rules! rem_impl_float {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
impl Rem for $t {
type Output = $t;
@@ -559,7 +558,7 @@ macro_rules! rem_impl_float {
)*)
}
-rem_impl_float! { f32 f64 }
+rem_impl_float! { f32, f64 }
/// The unary negation operator `-`.
///
@@ -614,7 +613,7 @@ pub trait Neg {
macro_rules! neg_impl_core {
- ($id:ident => $body:expr, $($t:ty)*) => ($(
+ ($id:ident => $body:expr, $($t:ty),*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
impl Neg for $t {
type Output = $t;
@@ -629,19 +628,19 @@ macro_rules! neg_impl_core {
}
macro_rules! neg_impl_numeric {
- ($($t:ty)*) => { neg_impl_core!{ x => -x, $($t)*} }
+ ($($t:ty),*) => { neg_impl_core!{ x => -x, $($t),*} }
}
#[allow(unused_macros)]
macro_rules! neg_impl_unsigned {
- ($($t:ty)*) => {
+ ($($t:ty),*) => {
neg_impl_core!{ x => {
!x.wrapping_add(1)
- }, $($t)*} }
+ }, $($t),*} }
}
// neg_impl_unsigned! { usize u8 u16 u32 u64 }
-neg_impl_numeric! { isize i8 i16 i32 i64 i128 f32 f64 }
+neg_impl_numeric! { isize, i8, i16, i32, i64, i128, f32, f64 }
/// The addition assignment operator `+=`.
///
@@ -685,7 +684,7 @@ pub trait AddAssign {
}
macro_rules! add_assign_impl {
- ($($t:ty)+) => ($(
+ ($($t:ty),+) => ($(
#[stable(feature = "op_assign_traits", since = "1.8.0")]
impl AddAssign for $t {
#[inline]
@@ -697,7 +696,7 @@ macro_rules! add_assign_impl {
)+)
}
-add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
+add_assign_impl! { usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128, f32, f64 }
/// The subtraction assignment operator `-=`.
///
@@ -741,7 +740,7 @@ pub trait SubAssign {
}
macro_rules! sub_assign_impl {
- ($($t:ty)+) => ($(
+ ($($t:ty),+) => ($(
#[stable(feature = "op_assign_traits", since = "1.8.0")]
impl SubAssign for $t {
#[inline]
@@ -753,7 +752,7 @@ macro_rules! sub_assign_impl {
)+)
}
-sub_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
+sub_assign_impl! { usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128, f32, f64 }
/// The multiplication assignment operator `*=`.
///
@@ -788,7 +787,7 @@ pub trait MulAssign {
}
macro_rules! mul_assign_impl {
- ($($t:ty)+) => ($(
+ ($($t:ty),+) => ($(
#[stable(feature = "op_assign_traits", since = "1.8.0")]
impl MulAssign for $t {
#[inline]
@@ -800,7 +799,7 @@ macro_rules! mul_assign_impl {
)+)
}
-mul_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
+mul_assign_impl! { usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128, f32, f64 }
/// The division assignment operator `/=`.
///
@@ -835,7 +834,7 @@ pub trait DivAssign {
}
macro_rules! div_assign_impl {
- ($($t:ty)+) => ($(
+ ($($t:ty),+) => ($(
#[stable(feature = "op_assign_traits", since = "1.8.0")]
impl DivAssign for $t {
#[inline]
@@ -846,7 +845,7 @@ macro_rules! div_assign_impl {
)+)
}
-div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
+div_assign_impl! { usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128, f32, f64 }
/// The remainder assignment operator `%=`.
///
@@ -885,7 +884,7 @@ pub trait RemAssign {
}
macro_rules! rem_assign_impl {
- ($($t:ty)+) => ($(
+ ($($t:ty),+) => ($(
#[stable(feature = "op_assign_traits", since = "1.8.0")]
impl RemAssign for $t {
#[inline]
@@ -896,4 +895,4 @@ macro_rules! rem_assign_impl {
)+)
}
-rem_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
+rem_assign_impl! { usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128, f32, f64 }
diff --git a/src/libcore/ops/bit.rs b/src/libcore/ops/bit.rs
index 3900f365b0ab1..eff561aea8bdf 100644
--- a/src/libcore/ops/bit.rs
+++ b/src/libcore/ops/bit.rs
@@ -52,7 +52,7 @@ pub trait Not {
}
macro_rules! not_impl {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
impl Not for $t {
type Output = $t;
@@ -65,7 +65,7 @@ macro_rules! not_impl {
)*)
}
-not_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
+not_impl! { bool, usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128 }
/// The bitwise AND operator `&`.
///
@@ -136,7 +136,7 @@ pub trait BitAnd {
}
macro_rules! bitand_impl {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
impl BitAnd for $t {
type Output = $t;
@@ -149,7 +149,7 @@ macro_rules! bitand_impl {
)*)
}
-bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
+bitand_impl! { bool, usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128 }
/// The bitwise OR operator `|`.
///
@@ -220,7 +220,7 @@ pub trait BitOr {
}
macro_rules! bitor_impl {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
impl BitOr for $t {
type Output = $t;
@@ -233,7 +233,7 @@ macro_rules! bitor_impl {
)*)
}
-bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
+bitor_impl! { bool, usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128 }
/// The bitwise XOR operator `^`.
///
@@ -307,7 +307,7 @@ pub trait BitXor {
}
macro_rules! bitxor_impl {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
#[stable(feature = "rust1", since = "1.0.0")]
impl BitXor for $t {
type Output = $t;
@@ -320,7 +320,7 @@ macro_rules! bitxor_impl {
)*)
}
-bitxor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
+bitxor_impl! { bool, usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128 }
/// The left shift operator `<<`. Note that because this trait is implemented
/// for all integer types with multiple right-hand-side types, Rust's type
@@ -412,7 +412,7 @@ macro_rules! shl_impl {
}
macro_rules! shl_impl_all {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
shl_impl! { $t, u8 }
shl_impl! { $t, u16 }
shl_impl! { $t, u32 }
@@ -429,7 +429,7 @@ macro_rules! shl_impl_all {
)*)
}
-shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 isize i128 }
+shl_impl_all! { u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, isize, i128 }
/// The right shift operator `>>`. Note that because this trait is implemented
/// for all integer types with multiple right-hand-side types, Rust's type
@@ -521,7 +521,7 @@ macro_rules! shr_impl {
}
macro_rules! shr_impl_all {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
shr_impl! { $t, u8 }
shr_impl! { $t, u16 }
shr_impl! { $t, u32 }
@@ -538,7 +538,7 @@ macro_rules! shr_impl_all {
)*)
}
-shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
+shr_impl_all! { u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize }
/// The bitwise AND assignment operator `&=`.
///
@@ -615,7 +615,7 @@ pub trait BitAndAssign {
}
macro_rules! bitand_assign_impl {
- ($($t:ty)+) => ($(
+ ($($t:ty),+) => ($(
#[stable(feature = "op_assign_traits", since = "1.8.0")]
impl BitAndAssign for $t {
#[inline]
@@ -626,7 +626,7 @@ macro_rules! bitand_assign_impl {
)+)
}
-bitand_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
+bitand_assign_impl! { bool, usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128 }
/// The bitwise OR assignment operator `|=`.
///
@@ -664,7 +664,7 @@ pub trait BitOrAssign {
}
macro_rules! bitor_assign_impl {
- ($($t:ty)+) => ($(
+ ($($t:ty),+) => ($(
#[stable(feature = "op_assign_traits", since = "1.8.0")]
impl BitOrAssign for $t {
#[inline]
@@ -675,7 +675,7 @@ macro_rules! bitor_assign_impl {
)+)
}
-bitor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
+bitor_assign_impl! { bool, usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128 }
/// The bitwise XOR assignment operator `^=`.
///
@@ -713,7 +713,7 @@ pub trait BitXorAssign {
}
macro_rules! bitxor_assign_impl {
- ($($t:ty)+) => ($(
+ ($($t:ty),+) => ($(
#[stable(feature = "op_assign_traits", since = "1.8.0")]
impl BitXorAssign for $t {
#[inline]
@@ -724,7 +724,7 @@ macro_rules! bitxor_assign_impl {
)+)
}
-bitxor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
+bitxor_assign_impl! { bool, usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128 }
/// The left shift assignment operator `<<=`.
///
@@ -775,7 +775,7 @@ macro_rules! shl_assign_impl {
}
macro_rules! shl_assign_impl_all {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
shl_assign_impl! { $t, u8 }
shl_assign_impl! { $t, u16 }
shl_assign_impl! { $t, u32 }
@@ -792,7 +792,7 @@ macro_rules! shl_assign_impl_all {
)*)
}
-shl_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
+shl_assign_impl_all! { u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize }
/// The right shift assignment operator `>>=`.
///
@@ -843,7 +843,7 @@ macro_rules! shr_assign_impl {
}
macro_rules! shr_assign_impl_all {
- ($($t:ty)*) => ($(
+ ($($t:ty),*) => ($(
shr_assign_impl! { $t, u8 }
shr_assign_impl! { $t, u16 }
shr_assign_impl! { $t, u32 }
@@ -860,4 +860,4 @@ macro_rules! shr_assign_impl_all {
)*)
}
-shr_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
+shr_assign_impl_all! { u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize }
diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs
index 8a6b212020b4e..8e48faa2c0a3d 100644
--- a/src/libcore/slice/mod.rs
+++ b/src/libcore/slice/mod.rs
@@ -5016,7 +5016,7 @@ impl SliceOrd for [u8] {
trait BytewiseEquality { }
macro_rules! impl_marker_for {
- ($traitname:ident, $($ty:ty)*) => {
+ ($traitname:ident, $($ty:ty),*) => {
$(
impl $traitname for $ty { }
)*
@@ -5024,7 +5024,7 @@ macro_rules! impl_marker_for {
}
impl_marker_for!(BytewiseEquality,
- u8 i8 u16 i16 u32 i32 u64 i64 usize isize char bool);
+ u8, i8, u16, i16, u32, i32, u64, i64, usize, isize, char, bool);
#[doc(hidden)]
unsafe impl<'a, T> TrustedRandomAccess for Iter<'a, T> {
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs
index 805aa9bef227d..97dfc3ce5ffac 100644
--- a/src/libsyntax/ext/tt/macro_rules.rs
+++ b/src/libsyntax/ext/tt/macro_rules.rs
@@ -760,6 +760,50 @@ fn check_matcher_core(sess: &ParseSess,
new.add_one_maybe(TokenTree::Token(sp.entire(), u.clone()));
&new
} else {
+ if let (
+ Some(tok),
+ Some(TokenTree::MetaVarDecl(sp, name, frag_spec)),
+ ) = (seq_rep.tts.first(), seq_rep.tts.last()) {
+ match is_in_follow(tok, &frag_spec.as_str()) {
+ Err(_) | Ok(true) => {} // handled elsewhere
+ Ok(false) => {
+ let tok_sp = tok.span();
+ let next = if *sp == tok_sp {
+ "itself".to_owned()
+ } else {
+ format!("`{}`", quoted_tt_to_string(tok))
+ };
+ let mut err = sess.span_diagnostic.struct_span_err(
+ *sp,
+ &format!(
+ "`${name}:{frag}` is followed (through repetition) by \
+ {next}, which is not allowed for `{frag}` fragments",
+ name=name,
+ frag=frag_spec,
+ next=next,
+ ),
+ );
+ if *sp == tok_sp {
+ err.span_label(
+ *sp,
+ "this fragment is followed by itself without a valid \
+ separator",
+ );
+ } else {
+ err.span_label(
+ *sp,
+ "this fragment is followed by the first fragment in this \
+ repetition without a valid separator",
+ );
+ err.span_label(
+ tok_sp,
+ "this is the first fragment in the evaluated repetition",
+ );
+ }
+ err.emit();
+ }
+ }
+ }
&suffix_first
};
diff --git a/src/test/ui/issues/issue-42755.rs b/src/test/ui/issues/issue-42755.rs
index a8458ccacc3c0..7bdb728b05b3b 100644
--- a/src/test/ui/issues/issue-42755.rs
+++ b/src/test/ui/issues/issue-42755.rs
@@ -10,7 +10,9 @@
macro_rules! foo {
- ($($p:vis)*) => {} //~ ERROR repetition matches empty token tree
+ ($($p:vis)*) => {}
+ //~^ ERROR `$p:vis` is followed (through repetition) by itself, which is not allowed for `vis`
+ //~| ERROR repetition matches empty token tree
}
foo!(a);
diff --git a/src/test/ui/issues/issue-42755.stderr b/src/test/ui/issues/issue-42755.stderr
index bdbb99de4608f..46c6678533785 100644
--- a/src/test/ui/issues/issue-42755.stderr
+++ b/src/test/ui/issues/issue-42755.stderr
@@ -1,8 +1,14 @@
+error: `$p:vis` is followed (through repetition) by itself, which is not allowed for `vis` fragments
+ --> $DIR/issue-42755.rs:13:8
+ |
+LL | ($($p:vis)*) => {}
+ | ^^^^^^ this fragment is followed by itself without a valid separator
+
error: repetition matches empty token tree
--> $DIR/issue-42755.rs:13:7
|
-LL | ($($p:vis)*) => {} //~ ERROR repetition matches empty token tree
+LL | ($($p:vis)*) => {}
| ^^^^^^^^
-error: aborting due to previous error
+error: aborting due to 2 previous errors
diff --git a/src/test/ui/macros/incorrrect-repetition-2.rs b/src/test/ui/macros/incorrrect-repetition-2.rs
new file mode 100644
index 0000000000000..86a71c05f7ae3
--- /dev/null
+++ b/src/test/ui/macros/incorrrect-repetition-2.rs
@@ -0,0 +1,4 @@
+macro_rules! foo {
+ ($($a:expr)*) => {};
+ //~^ ERROR `$a:expr` is followed (through repetition) by itself, which is not allowed for
+}
diff --git a/src/test/ui/macros/incorrrect-repetition-2.stderr b/src/test/ui/macros/incorrrect-repetition-2.stderr
new file mode 100644
index 0000000000000..50f1da38e788f
--- /dev/null
+++ b/src/test/ui/macros/incorrrect-repetition-2.stderr
@@ -0,0 +1,13 @@
+error: `$a:expr` is followed (through repetition) by itself, which is not allowed for `expr` fragments
+ --> $DIR/incorrrect-repetition-2.rs:2:8
+ |
+LL | ($($a:expr)*) => {};
+ | ^^^^^^^ this fragment is followed by itself without a valid separator
+
+error[E0601]: `main` function not found in crate `incorrrect_repetition_2`
+ |
+ = note: consider adding a `main` function to `$DIR/incorrrect-repetition-2.rs`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0601`.
diff --git a/src/test/ui/macros/incorrrect-repetition.rs b/src/test/ui/macros/incorrrect-repetition.rs
new file mode 100644
index 0000000000000..2606af0d9abc8
--- /dev/null
+++ b/src/test/ui/macros/incorrrect-repetition.rs
@@ -0,0 +1,8 @@
+macro_rules! sneaky {
+ ($($i:ident $e:expr)*) => {}
+ //~^ ERROR `$e:expr` is followed (through repetition) by `$i:ident`, which is not allowed for
+}
+
+fn main() {
+ sneaky!(a b c d);
+}
diff --git a/src/test/ui/macros/incorrrect-repetition.stderr b/src/test/ui/macros/incorrrect-repetition.stderr
new file mode 100644
index 0000000000000..56ad21b962e89
--- /dev/null
+++ b/src/test/ui/macros/incorrrect-repetition.stderr
@@ -0,0 +1,10 @@
+error: `$e:expr` is followed (through repetition) by `$i:ident`, which is not allowed for `expr` fragments
+ --> $DIR/incorrrect-repetition.rs:2:17
+ |
+LL | ($($i:ident $e:expr)*) => {}
+ | -------- ^^^^^^^ this fragment is followed by the first fragment in this repetition without a valid separator
+ | |
+ | this is the first fragment in the evaluated repetition
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/macros/macro-input-future-proofing.rs b/src/test/ui/macros/macro-input-future-proofing.rs
index e5fdba63b0f15..949828f6b9aa2 100644
--- a/src/test/ui/macros/macro-input-future-proofing.rs
+++ b/src/test/ui/macros/macro-input-future-proofing.rs
@@ -23,11 +23,16 @@ macro_rules! errors_everywhere {
($pa:pat $pb:pat $ty:ty ,) => ();
//~^ ERROR `$pa:pat` is followed by `$pb:pat`, which is not allowed
//~^^ ERROR `$pb:pat` is followed by `$ty:ty`, which is not allowed
- ($($ty:ty)* -) => (); //~ ERROR `$ty:ty` is followed by `-`
- ($($a:ty, $b:ty)* -) => (); //~ ERROR `$b:ty` is followed by `-`
+ ($ty:ty -) => (); //~ ERROR `$ty:ty` is followed by `-`
+ ($a:ty, $b:ty -) => (); //~ ERROR `$b:ty` is followed by `-`
($($ty:ty)-+) => (); //~ ERROR `$ty:ty` is followed by `-`, which is not allowed for `ty`
- ( $($a:expr)* $($b:tt)* ) => { };
+ ( $a:expr $($b:tt)* ) => { };
//~^ ERROR `$a:expr` is followed by `$b:tt`, which is not allowed for `expr` fragments
+ ( $($a:expr)* $($b:tt)* ) => { };
+ //~^ ERROR `$a:expr` is followed (through repetition) by itself, which is not allowed for
+ //~| ERROR `$a:expr` is followed by `$b:tt`, which is not allowed for `expr` fragments
+ ( $($a:expr),* $($b:tt)* ) => { };
+ //~^ ERROR `$a:expr` may be followed by `$b:tt`, which is not allowed for `expr` fragments
}
fn main() { }
diff --git a/src/test/ui/macros/macro-input-future-proofing.stderr b/src/test/ui/macros/macro-input-future-proofing.stderr
index aed7a8a119ced..2da019fddbf79 100644
--- a/src/test/ui/macros/macro-input-future-proofing.stderr
+++ b/src/test/ui/macros/macro-input-future-proofing.stderr
@@ -29,16 +29,16 @@ LL | ($pa:pat $pb:pat $ty:ty ,) => ();
| ^^^^^^
error: `$ty:ty` is followed by `-`, which is not allowed for `ty` fragments
- --> $DIR/macro-input-future-proofing.rs:26:17
+ --> $DIR/macro-input-future-proofing.rs:26:13
|
-LL | ($($ty:ty)* -) => (); //~ ERROR `$ty:ty` is followed by `-`
- | ^
+LL | ($ty:ty -) => (); //~ ERROR `$ty:ty` is followed by `-`
+ | ^
error: `$b:ty` is followed by `-`, which is not allowed for `ty` fragments
- --> $DIR/macro-input-future-proofing.rs:27:23
+ --> $DIR/macro-input-future-proofing.rs:27:19
|
-LL | ($($a:ty, $b:ty)* -) => (); //~ ERROR `$b:ty` is followed by `-`
- | ^
+LL | ($a:ty, $b:ty -) => (); //~ ERROR `$b:ty` is followed by `-`
+ | ^
error: `$ty:ty` is followed by `-`, which is not allowed for `ty` fragments
--> $DIR/macro-input-future-proofing.rs:28:7
@@ -47,10 +47,28 @@ LL | ($($ty:ty)-+) => (); //~ ERROR `$ty:ty` is followed by `-`, which is no
| ^^^^^^^^
error: `$a:expr` is followed by `$b:tt`, which is not allowed for `expr` fragments
- --> $DIR/macro-input-future-proofing.rs:29:21
+ --> $DIR/macro-input-future-proofing.rs:29:17
+ |
+LL | ( $a:expr $($b:tt)* ) => { };
+ | ^^^^^
+
+error: `$a:expr` is followed (through repetition) by itself, which is not allowed for `expr` fragments
+ --> $DIR/macro-input-future-proofing.rs:31:9
+ |
+LL | ( $($a:expr)* $($b:tt)* ) => { };
+ | ^^^^^^^ this fragment is followed by itself without a valid separator
+
+error: `$a:expr` is followed by `$b:tt`, which is not allowed for `expr` fragments
+ --> $DIR/macro-input-future-proofing.rs:31:21
|
LL | ( $($a:expr)* $($b:tt)* ) => { };
| ^^^^^
-error: aborting due to 9 previous errors
+error: `$a:expr` may be followed by `$b:tt`, which is not allowed for `expr` fragments
+ --> $DIR/macro-input-future-proofing.rs:34:22
+ |
+LL | ( $($a:expr),* $($b:tt)* ) => { };
+ | ^^^^^
+
+error: aborting due to 12 previous errors