diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 9d037dad9ccbd..c94d6cb4c1f5a 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -326,7 +326,7 @@ pub enum Kind { impl<'a> Builder<'a> { fn get_step_descriptions(kind: Kind) -> Vec { macro_rules! describe { - ($($rule:ty),+ $(,)*) => {{ + ($($rule:ty),+ $(,)?) => {{ vec![$(StepDescription::from::<$rule>()),+] }}; } diff --git a/src/libproc_macro/bridge/client.rs b/src/libproc_macro/bridge/client.rs index b198bdb144699..6052b4a4d43f4 100644 --- a/src/libproc_macro/bridge/client.rs +++ b/src/libproc_macro/bridge/client.rs @@ -222,8 +222,8 @@ impl fmt::Debug for Span { macro_rules! define_client_side { ($($name:ident { - $(fn $method:ident($($arg:ident: $arg_ty:ty),* $(,)*) $(-> $ret_ty:ty)*;)* - }),* $(,)*) => { + $(fn $method:ident($($arg:ident: $arg_ty:ty),* $(,)?) $(-> $ret_ty:ty)*;)* + }),* $(,)?) => { $(impl $name { $(pub(crate) fn $method($($arg: $arg_ty),*) $(-> $ret_ty)* { Bridge::with(|bridge| { diff --git a/src/libproc_macro/bridge/mod.rs b/src/libproc_macro/bridge/mod.rs index 3173651b03951..276edb7300986 100644 --- a/src/libproc_macro/bridge/mod.rs +++ b/src/libproc_macro/bridge/mod.rs @@ -225,8 +225,8 @@ mod api_tags { macro_rules! declare_tags { ($($name:ident { - $(fn $method:ident($($arg:ident: $arg_ty:ty),* $(,)*) $(-> $ret_ty:ty)*;)* - }),* $(,)*) => { + $(fn $method:ident($($arg:ident: $arg_ty:ty),* $(,)?) $(-> $ret_ty:ty)*;)* + }),* $(,)?) => { $( pub(super) enum $name { $($method),* @@ -307,7 +307,7 @@ impl Unmark for Option { } macro_rules! mark_noop { - ($($ty:ty),* $(,)*) => { + ($($ty:ty),* $(,)?) => { $( impl Mark for $ty { type Unmarked = Self; diff --git a/src/libproc_macro/bridge/rpc.rs b/src/libproc_macro/bridge/rpc.rs index a3bc0d2290846..4289f33ffd5eb 100644 --- a/src/libproc_macro/bridge/rpc.rs +++ b/src/libproc_macro/bridge/rpc.rs @@ -53,7 +53,7 @@ macro_rules! rpc_encode_decode { } } }; - (struct $name:ident { $($field:ident),* $(,)* }) => { + (struct $name:ident { $($field:ident),* $(,)? }) => { impl Encode for $name { fn encode(self, w: &mut Writer, s: &mut S) { $(self.$field.encode(w, s);)* @@ -68,8 +68,8 @@ macro_rules! rpc_encode_decode { } } }; - (enum $name:ident $(<$($T:ident),+>)* { $($variant:ident $(($field:ident))*),* $(,)* }) => { - impl),+)*> Encode for $name $(<$($T),+>)* { + (enum $name:ident $(<$($T:ident),+>)? { $($variant:ident $(($field:ident))*),* $(,)? }) => { + impl),+)?> Encode for $name $(<$($T),+>)* { fn encode(self, w: &mut Writer, s: &mut S) { // HACK(eddyb): `Tag` enum duplicated between the // two impls as there's no other place to stash it. diff --git a/src/libproc_macro/bridge/server.rs b/src/libproc_macro/bridge/server.rs index 75806eb9d1760..f303e3e828834 100644 --- a/src/libproc_macro/bridge/server.rs +++ b/src/libproc_macro/bridge/server.rs @@ -39,14 +39,14 @@ macro_rules! associated_item { macro_rules! declare_server_traits { ($($name:ident { - $(fn $method:ident($($arg:ident: $arg_ty:ty),* $(,)*) $(-> $ret_ty:ty)*;)* - }),* $(,)*) => { + $(fn $method:ident($($arg:ident: $arg_ty:ty),* $(,)?) $(-> $ret_ty:ty)?;)* + }),* $(,)?) => { pub trait Types { $(associated_item!(type $name);)* } $(pub trait $name: Types { - $(associated_item!(fn $method(&mut self, $($arg: $arg_ty),*) $(-> $ret_ty)*);)* + $(associated_item!(fn $method(&mut self, $($arg: $arg_ty),*) $(-> $ret_ty)?);)* })* pub trait Server: Types $(+ $name)* {} @@ -59,14 +59,14 @@ pub(super) struct MarkedTypes(S); macro_rules! define_mark_types_impls { ($($name:ident { - $(fn $method:ident($($arg:ident: $arg_ty:ty),* $(,)*) $(-> $ret_ty:ty)*;)* - }),* $(,)*) => { + $(fn $method:ident($($arg:ident: $arg_ty:ty),* $(,)?) $(-> $ret_ty:ty)?;)* + }),* $(,)?) => { impl Types for MarkedTypes { $(type $name = Marked;)* } $(impl $name for MarkedTypes { - $(fn $method(&mut self, $($arg: $arg_ty),*) $(-> $ret_ty)* { + $(fn $method(&mut self, $($arg: $arg_ty),*) $(-> $ret_ty)? { <_>::mark($name::$method(&mut self.0, $($arg.unmark()),*)) })* })* @@ -81,8 +81,8 @@ struct Dispatcher { macro_rules! define_dispatcher_impl { ($($name:ident { - $(fn $method:ident($($arg:ident: $arg_ty:ty),* $(,)*) $(-> $ret_ty:ty)*;)* - }),* $(,)*) => { + $(fn $method:ident($($arg:ident: $arg_ty:ty),* $(,)?) $(-> $ret_ty:ty)?;)* + }),* $(,)?) => { // FIXME(eddyb) `pub` only for `ExecutionStrategy` below. pub trait DispatcherTrait { // HACK(eddyb) these are here to allow `Self::$name` to work below. diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 796739c872174..2f91da4f62e3d 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -111,7 +111,7 @@ macro_rules! define_dep_nodes { (<$tcx:tt> $( [$($attr:ident),* ] - $variant:ident $(( $tuple_arg_ty:ty $(,)* ))* + $variant:ident $(( $tuple_arg_ty:ty $(,)? ))* $({ $($struct_arg_name:ident : $struct_arg_ty:ty),* })* ,)* ) => ( diff --git a/src/librustc/macros.rs b/src/librustc/macros.rs index ccae9d3ad5a82..8d9d1db5756b8 100644 --- a/src/librustc/macros.rs +++ b/src/librustc/macros.rs @@ -257,7 +257,7 @@ macro_rules! CloneTypeFoldableAndLiftImpls { macro_rules! BraceStructLiftImpl { (impl<$($p:tt),*> Lift<$tcx:tt> for $s:path { type Lifted = $lifted:ty; - $($field:ident),* $(,)* + $($field:ident),* $(,)? } $(where $($wc:tt)*)*) => { impl<$($p),*> $crate::ty::Lift<$tcx> for $s $(where $($wc)*)* @@ -327,7 +327,7 @@ macro_rules! EnumLiftImpl { #[macro_export] macro_rules! BraceStructTypeFoldableImpl { (impl<$($p:tt),*> TypeFoldable<$tcx:tt> for $s:path { - $($field:ident),* $(,)* + $($field:ident),* $(,)? } $(where $($wc:tt)*)*) => { impl<$($p),*> $crate::ty::fold::TypeFoldable<$tcx> for $s $(where $($wc)*)* @@ -354,7 +354,7 @@ macro_rules! BraceStructTypeFoldableImpl { #[macro_export] macro_rules! TupleStructTypeFoldableImpl { (impl<$($p:tt),*> TypeFoldable<$tcx:tt> for $s:path { - $($field:ident),* $(,)* + $($field:ident),* $(,)? } $(where $($wc:tt)*)*) => { impl<$($p),*> $crate::ty::fold::TypeFoldable<$tcx> for $s $(where $($wc)*)* @@ -426,7 +426,7 @@ macro_rules! EnumTypeFoldableImpl { }; (@FoldVariants($this:expr, $folder:expr) - input( ($variant:path) { $($variant_arg:ident),* $(,)* } , $($input:tt)*) + input( ($variant:path) { $($variant_arg:ident),* $(,)? } , $($input:tt)*) output( $($output:tt)*) ) => { EnumTypeFoldableImpl!( @FoldVariants($this, $folder) @@ -480,7 +480,7 @@ macro_rules! EnumTypeFoldableImpl { }; (@VisitVariants($this:expr, $visitor:expr) - input( ($variant:path) { $($variant_arg:ident),* $(,)* } , $($input:tt)*) + input( ($variant:path) { $($variant_arg:ident),* $(,)? } , $($input:tt)*) output( $($output:tt)*) ) => { EnumTypeFoldableImpl!( @VisitVariants($this, $visitor) diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs index 8a30790174d45..0c808a07f9bac 100644 --- a/src/librustc_errors/diagnostic_builder.rs +++ b/src/librustc_errors/diagnostic_builder.rs @@ -36,7 +36,7 @@ macro_rules! forward { // Forward pattern for &self -> &Self ( $(#[$attrs:meta])* - pub fn $n:ident(&self, $($name:ident: $ty:ty),* $(,)*) -> &Self + pub fn $n:ident(&self, $($name:ident: $ty:ty),* $(,)?) -> &Self ) => { $(#[$attrs])* pub fn $n(&self, $($name: $ty),*) -> &Self { @@ -48,7 +48,7 @@ macro_rules! forward { // Forward pattern for &mut self -> &mut Self ( $(#[$attrs:meta])* - pub fn $n:ident(&mut self, $($name:ident: $ty:ty),* $(,)*) -> &mut Self + pub fn $n:ident(&mut self, $($name:ident: $ty:ty),* $(,)?) -> &mut Self ) => { $(#[$attrs])* pub fn $n(&mut self, $($name: $ty),*) -> &mut Self { @@ -64,7 +64,7 @@ macro_rules! forward { pub fn $n:ident>( &mut self, $($name:ident: $ty:ty),* - $(,)* + $(,)? ) -> &mut Self ) => { $(#[$attrs])* diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs index 6a0b600360014..45e1ea2d3a39d 100644 --- a/src/librustdoc/clean/cfg.rs +++ b/src/librustdoc/clean/cfg.rs @@ -431,7 +431,7 @@ mod test { } macro_rules! dummy_meta_item_list { - ($name:ident, [$($list:ident),* $(,)*]) => { + ($name:ident, [$($list:ident),* $(,)?]) => { MetaItem { ident: Path::from_ident(Ident::from_str(stringify!($name))), node: MetaItemKind::List(vec![ @@ -445,7 +445,7 @@ mod test { } }; - ($name:ident, [$($list:expr),* $(,)*]) => { + ($name:ident, [$($list:expr),* $(,)?]) => { MetaItem { ident: Path::from_ident(Ident::from_str(stringify!($name))), node: MetaItemKind::List(vec![ diff --git a/src/libsyntax_ext/proc_macro_server.rs b/src/libsyntax_ext/proc_macro_server.rs index 699539b62f515..4c4b33c04422b 100644 --- a/src/libsyntax_ext/proc_macro_server.rs +++ b/src/libsyntax_ext/proc_macro_server.rs @@ -69,7 +69,7 @@ impl FromInternal<(TreeAndJoint, &'_ ParseSess, &'_ mut Vec)> }; macro_rules! tt { - ($ty:ident { $($field:ident $(: $value:expr)*),+ $(,)* }) => ( + ($ty:ident { $($field:ident $(: $value:expr)*),+ $(,)? }) => ( TokenTree::$ty(self::$ty { $($field $(: $value)*,)* span,