about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-02-25 03:18:04 +0100
committerGitHub <noreply@github.com>2019-02-25 03:18:04 +0100
commitb5cf4ea07fd1a4e5541f47aa6d0b3f0bc709540c (patch)
treebb2acc3f19824f98a69530c59e526925ff10b04d /src
parented73ec0e4cf1dbe11685f1311683d6fd31b7196f (diff)
parent871910a2c6e8624d4ebaa08ce6201b661f8c25f3 (diff)
downloadrust-b5cf4ea07fd1a4e5541f47aa6d0b3f0bc709540c.tar.gz
rust-b5cf4ea07fd1a4e5541f47aa6d0b3f0bc709540c.zip
Rollup merge of #58697 - taiki-e:question-in-macros, r=Centril
Use ? in some macros
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/builder.rs2
-rw-r--r--src/libproc_macro/bridge/client.rs4
-rw-r--r--src/libproc_macro/bridge/mod.rs6
-rw-r--r--src/libproc_macro/bridge/rpc.rs6
-rw-r--r--src/libproc_macro/bridge/server.rs16
-rw-r--r--src/librustc/dep_graph/dep_node.rs2
-rw-r--r--src/librustc/macros.rs10
-rw-r--r--src/librustc_errors/diagnostic_builder.rs6
-rw-r--r--src/librustdoc/clean/cfg.rs4
-rw-r--r--src/libsyntax_ext/proc_macro_server.rs2
10 files changed, 29 insertions, 29 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index 9d037dad9cc..c94d6cb4c1f 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<StepDescription> {
         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 b198bdb1446..6052b4a4d43 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 3173651b039..276edb73009 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<T: Unmark> Unmark for Option<T> {
 }
 
 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 a3bc0d22908..4289f33ffd5 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<S> Encode<S> 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<S, $($($T: Encode<S>),+)*> Encode<S> for $name $(<$($T),+>)* {
+    (enum $name:ident $(<$($T:ident),+>)? { $($variant:ident $(($field:ident))*),* $(,)? }) => {
+        impl<S, $($($T: Encode<S>),+)?> Encode<S> 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 75806eb9d17..f303e3e8288 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: Types>(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<S: Types> Types for MarkedTypes<S> {
             $(type $name = Marked<S::$name, client::$name>;)*
         }
 
         $(impl<S: $name> $name for MarkedTypes<S> {
-            $(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<S: Types> {
 
 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 796739c8721..2f91da4f62e 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 ccae9d3ad5a..8d9d1db5756 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 8a30790174d..0c808a07f9b 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<S: Into<MultiSpan>>(
             &mut self,
             $($name:ident: $ty:ty),*
-            $(,)*
+            $(,)?
         ) -> &mut Self
     ) => {
         $(#[$attrs])*
diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs
index 6a0b6003600..45e1ea2d3a3 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 699539b62f5..4c4b33c0442 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<Self>)>
         };
 
         macro_rules! tt {
-            ($ty:ident { $($field:ident $(: $value:expr)*),+ $(,)* }) => (
+            ($ty:ident { $($field:ident $(: $value:expr)*),+ $(,)? }) => (
                 TokenTree::$ty(self::$ty {
                     $($field $(: $value)*,)*
                     span,