From 6115dcdbdcd6ec0087172829851dfce9a33c59b6 Mon Sep 17 00:00:00 2001
From: topecongiro <seuchida@gmail.com>
Date: Thu, 22 Mar 2018 16:08:57 +0900
Subject: [PATCH 1/2] Remove a space after a colon of metavariable def in macro
 def

---
 src/macros.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/macros.rs b/src/macros.rs
index 784e6c5798b..c8fc0c72ea7 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -568,7 +568,7 @@ impl MacroArgKind {
 
         match *self {
             MacroArgKind::MetaVariable(ty, ref name) => {
-                Some(format!("${}: {}", name, ty.name.as_str()))
+                Some(format!("${}:{}", name, ty.name.as_str()))
             }
             MacroArgKind::Repeat(ref delim_tok, ref args, ref another, ref tok) => {
                 let (lhs, inner, rhs) = rewrite_delimited_inner(delim_tok, args)?;

From ccec777f929c9a3094caa37842367c21387d95a0 Mon Sep 17 00:00:00 2001
From: topecongiro <seuchida@gmail.com>
Date: Thu, 22 Mar 2018 16:09:21 +0900
Subject: [PATCH 2/2] Cargo fmt and update tests

---
 src/cargo-fmt/main.rs          |  2 +-
 src/macros.rs                  |  2 +-
 src/spanned.rs                 |  6 +--
 src/utils.rs                   |  8 ++--
 tests/target/macro_not_expr.rs |  2 +-
 tests/target/macro_rules.rs    | 73 +++++++++++++++++-----------------
 tests/target/macros.rs         |  6 +--
 7 files changed, 49 insertions(+), 50 deletions(-)

diff --git a/src/cargo-fmt/main.rs b/src/cargo-fmt/main.rs
index 855a45568b7..990e2596660 100644
--- a/src/cargo-fmt/main.rs
+++ b/src/cargo-fmt/main.rs
@@ -97,7 +97,7 @@ fn execute() -> i32 {
 }
 
 macro_rules! print_usage {
-    ($print: ident, $opts: ident, $reason: expr) => {{
+    ($print:ident, $opts:ident, $reason:expr) => {{
         let msg = format!("{}\nusage: cargo fmt [options]", $reason);
         $print!(
             "{}\nThis utility formats all bin and lib files of the current crate using rustfmt. \
diff --git a/src/macros.rs b/src/macros.rs
index c8fc0c72ea7..d1679fb9e4f 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -103,7 +103,7 @@ impl Rewrite for MacroArg {
 
 fn parse_macro_arg(parser: &mut Parser) -> Option<MacroArg> {
     macro_rules! parse_macro_arg {
-        ($macro_arg: ident, $parser: ident) => {
+        ($macro_arg:ident, $parser:ident) => {
             let mut cloned_parser = (*parser).clone();
             match cloned_parser.$parser() {
                 Ok(x) => {
diff --git a/src/spanned.rs b/src/spanned.rs
index 6f5a4b1721f..bcbf6bd6060 100644
--- a/src/spanned.rs
+++ b/src/spanned.rs
@@ -20,7 +20,7 @@ pub trait Spanned {
 }
 
 macro_rules! span_with_attrs_lo_hi {
-    ($this: ident, $lo: expr, $hi: expr) => {{
+    ($this:ident, $lo:expr, $hi:expr) => {{
         let attrs = outer_attributes(&$this.attrs);
         if attrs.is_empty() {
             mk_sp($lo, $hi)
@@ -31,13 +31,13 @@ macro_rules! span_with_attrs_lo_hi {
 }
 
 macro_rules! span_with_attrs {
-    ($this: ident) => {
+    ($this:ident) => {
         span_with_attrs_lo_hi!($this, $this.span.lo(), $this.span.hi())
     };
 }
 
 macro_rules! implement_spanned {
-    ($this: ty) => {
+    ($this:ty) => {
         impl Spanned for $this {
             fn span(&self) -> Span {
                 span_with_attrs!(self)
diff --git a/src/utils.rs b/src/utils.rs
index f6d2ff23c34..43ddaedefbe 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -266,7 +266,7 @@ macro_rules! msg {
 // For format_missing and last_pos, need to use the source callsite (if applicable).
 // Required as generated code spans aren't guaranteed to follow on from the last span.
 macro_rules! source {
-    ($this: ident, $sp: expr) => {
+    ($this:ident, $sp:expr) => {
         $sp.source_callsite()
     };
 }
@@ -277,7 +277,7 @@ pub fn mk_sp(lo: BytePos, hi: BytePos) -> Span {
 
 // Return true if the given span does not intersect with file lines.
 macro_rules! out_of_file_lines_range {
-    ($self: ident, $span: expr) => {
+    ($self:ident, $span:expr) => {
         !$self.config.file_lines().is_all()
             && !$self
                 .config
@@ -287,7 +287,7 @@ macro_rules! out_of_file_lines_range {
 }
 
 macro_rules! skip_out_of_file_lines_range {
-    ($self: ident, $span: expr) => {
+    ($self:ident, $span:expr) => {
         if out_of_file_lines_range!($self, $span) {
             return None;
         }
@@ -295,7 +295,7 @@ macro_rules! skip_out_of_file_lines_range {
 }
 
 macro_rules! skip_out_of_file_lines_range_visitor {
-    ($self: ident, $span: expr) => {
+    ($self:ident, $span:expr) => {
         if out_of_file_lines_range!($self, $span) {
             $self.push_rewrite($span, None);
             return;
diff --git a/tests/target/macro_not_expr.rs b/tests/target/macro_not_expr.rs
index c76a6492a9d..45f85ff2c93 100644
--- a/tests/target/macro_not_expr.rs
+++ b/tests/target/macro_not_expr.rs
@@ -1,5 +1,5 @@
 macro_rules! test {
-    ($($t: tt)*) => {};
+    ($($t:tt)*) => {};
 }
 
 fn main() {
diff --git a/tests/target/macro_rules.rs b/tests/target/macro_rules.rs
index 793efcb6b0c..12fdb7b026e 100644
--- a/tests/target/macro_rules.rs
+++ b/tests/target/macro_rules.rs
@@ -2,33 +2,33 @@
 
 macro_rules! m {
     () => {};
-    ($x: ident) => {};
-    ($m1: ident, $m2: ident, $x: ident) => {};
-    ($($beginning: ident),*; $middle: ident; $($end: ident),*) => {};
+    ($x:ident) => {};
+    ($m1:ident, $m2:ident, $x:ident) => {};
+    ($($beginning:ident),*; $middle:ident; $($end:ident),*) => {};
     (
-        $($beginning: ident),*;
-        $middle: ident;
-        $($end: ident),*;
-        $($beginning: ident),*;
-        $middle: ident;
-        $($end: ident),*
+        $($beginning:ident),*;
+        $middle:ident;
+        $($end:ident),*;
+        $($beginning:ident),*;
+        $middle:ident;
+        $($end:ident),*
     ) => {};
-    ($name: ident($($dol: tt $var: ident)*) $($body: tt)*) => {};
+    ($name:ident($($dol:tt $var:ident)*) $($body:tt)*) => {};
     (
-        $($i: ident : $ty: ty, $def: expr, $stb: expr, $($dstring: tt),+);+ $(;)*
-        $($i: ident : $ty: ty, $def: expr, $stb: expr, $($dstring: tt),+);+ $(;)*
+        $($i:ident : $ty:ty, $def:expr, $stb:expr, $($dstring:tt),+);+ $(;)*
+        $($i:ident : $ty:ty, $def:expr, $stb:expr, $($dstring:tt),+);+ $(;)*
     ) => {};
-    ($foo: tt foo[$attr: meta] $name: ident) => {};
-    ($foo: tt[$attr: meta] $name: ident) => {};
-    ($foo: tt &'a[$attr: meta] $name: ident) => {};
-    ($foo: tt foo #[$attr: meta] $name: ident) => {};
-    ($foo: tt #[$attr: meta] $name: ident) => {};
-    ($foo: tt &'a #[$attr: meta] $name: ident) => {};
-    ($x: tt foo bar foo bar foo bar $y: tt => x * y * z $z: tt, $($a: tt),*) => {};
+    ($foo:tt foo[$attr:meta] $name:ident) => {};
+    ($foo:tt[$attr:meta] $name:ident) => {};
+    ($foo:tt &'a[$attr:meta] $name:ident) => {};
+    ($foo:tt foo #[$attr:meta] $name:ident) => {};
+    ($foo:tt #[$attr:meta] $name:ident) => {};
+    ($foo:tt &'a #[$attr:meta] $name:ident) => {};
+    ($x:tt foo bar foo bar foo bar $y:tt => x * y * z $z:tt, $($a:tt),*) => {};
 }
 
 macro_rules! impl_a_method {
-    ($n: ident($a: ident : $ta: ty) -> $ret: ty { $body: expr }) => {
+    ($n:ident($a:ident : $ta:ty) -> $ret:ty { $body:expr }) => {
         fn $n($a: $ta) -> $ret {
             $body
         }
@@ -38,7 +38,7 @@ macro_rules! impl_a_method {
             };
         }
     };
-    ($n: ident($a: ident : $ta: ty, $b: ident : $tb: ty) -> $ret: ty { $body: expr }) => {
+    ($n:ident($a:ident : $ta:ty, $b:ident : $tb:ty) -> $ret:ty { $body:expr }) => {
         fn $n($a: $ta, $b: $tb) -> $ret {
             $body
         }
@@ -49,8 +49,7 @@ macro_rules! impl_a_method {
         }
     };
     (
-        $n: ident($a: ident : $ta: ty, $b: ident : $tb: ty, $c: ident : $tc: ty) ->
-        $ret: ty { $body: expr }
+        $n:ident($a:ident : $ta:ty, $b:ident : $tb:ty, $c:ident : $tc:ty) -> $ret:ty { $body:expr }
     ) => {
         fn $n($a: $ta, $b: $tb, $c: $tc) -> $ret {
             $body
@@ -62,8 +61,8 @@ macro_rules! impl_a_method {
         }
     };
     (
-        $n: ident($a: ident : $ta: ty, $b: ident : $tb: ty, $c: ident : $tc: ty, $d: ident : $td: ty) ->
-        $ret: ty { $body: expr }
+        $n:ident($a:ident : $ta:ty, $b:ident : $tb:ty, $c:ident : $tc:ty, $d:ident : $td:ty) ->
+        $ret:ty { $body:expr }
     ) => {
         fn $n($a: $ta, $b: $tb, $c: $tc, $d: $td) -> $ret {
             $body
@@ -78,7 +77,7 @@ macro_rules! impl_a_method {
 
 macro_rules! m {
     // a
-    ($expr: expr, $($func: ident)*) => {{
+    ($expr:expr, $($func:ident)*) => {{
         let x = $expr;
         $func(x)
     }};
@@ -91,7 +90,7 @@ macro_rules! m {
     (@tag) => {};
 
     // d
-    ($item: ident) => {
+    ($item:ident) => {
         mod macro_item {
             struct $item;
         }
@@ -100,7 +99,7 @@ macro_rules! m {
 
 macro m2 {
     // a
-    ($expr: expr, $($func: ident)*) => {{
+    ($expr:expr, $($func:ident)*) => {{
         let x = $expr;
         $func(x)
     }}
@@ -113,7 +112,7 @@ macro m2 {
     (@tag) => {}
 
     // d
-    ($item: ident) => {
+    ($item:ident) => {
         mod macro_item {
             struct $item;
         }
@@ -156,10 +155,10 @@ macro_rules! m {
 // #2439
 macro_rules! m {
     (
-        $line0_xxxxxxxxxxxxxxxxx: expr,
-        $line1_xxxxxxxxxxxxxxxxx: expr,
-        $line2_xxxxxxxxxxxxxxxxx: expr,
-        $line3_xxxxxxxxxxxxxxxxx: expr,
+        $line0_xxxxxxxxxxxxxxxxx:expr,
+        $line1_xxxxxxxxxxxxxxxxx:expr,
+        $line2_xxxxxxxxxxxxxxxxx:expr,
+        $line3_xxxxxxxxxxxxxxxxx:expr,
     ) => {};
 }
 
@@ -173,7 +172,7 @@ macro_rules! m [
 ];
 
 // #2470
-macro foo($type_name: ident, $docs: expr) {
+macro foo($type_name:ident, $docs:expr) {
     #[allow(non_camel_case_types)]
     #[doc=$docs]
     #[derive(Debug, Clone, Copy)]
@@ -182,13 +181,13 @@ macro foo($type_name: ident, $docs: expr) {
 
 // #2534
 macro_rules! foo {
-    ($a: ident : $b: ty) => {};
-    ($a: ident $b: ident $c: ident) => {};
+    ($a:ident : $b:ty) => {};
+    ($a:ident $b:ident $c:ident) => {};
 }
 
 // #2538
 macro_rules! add_message_to_notes {
-    ($msg: expr) => {{
+    ($msg:expr) => {{
         let mut lines = message.lines();
         notes.push_str(&format!("\n{}: {}", level, lines.next().unwrap()));
         for line in lines {
diff --git a/tests/target/macros.rs b/tests/target/macros.rs
index 8db2fbb60ee..f5d8e11e35e 100644
--- a/tests/target/macros.rs
+++ b/tests/target/macros.rs
@@ -141,7 +141,7 @@ fn issue_1555() {
 
 fn issue1178() {
     macro_rules! foo {
-        (#[$attr: meta] $name: ident) => {};
+        (#[$attr:meta] $name:ident) => {};
     }
 
     foo!(
@@ -246,7 +246,7 @@ fn __bindgen_test_layout_HandleWithDtor_open0_int_close0_instantiation() {
 
 // #878
 macro_rules! try_opt {
-    ($expr: expr) => {
+    ($expr:expr) => {
         match $expr {
             Some(val) => val,
 
@@ -891,7 +891,7 @@ fn macro_in_pattern_position() {
 
 macro foo() {}
 
-pub macro bar($x: ident + $y: expr;) {
+pub macro bar($x:ident + $y:expr;) {
     fn foo($x: Foo) {
         long_function(
             a_long_argument_to_a_long_function_is_what_this_is(AAAAAAAAAAAAAAAAAAAAAAAAAAAA),