Skip to content

Macro matchers inconsistently having whitespace removed after , #2755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sgrif opened this issue May 30, 2018 · 0 comments · Fixed by #4246
Closed

Macro matchers inconsistently having whitespace removed after , #2755

sgrif opened this issue May 30, 2018 · 0 comments · Fixed by #4246

Comments

@sgrif
Copy link

sgrif commented May 30, 2018

It seems that rustfmt is sometimes trying to remove whitespace after , when it appears in macro matchers, but not always. Diff from Diesel:

--- a/diesel/src/expression/operators.rs
+++ b/diesel/src/expression/operators.rs
@@ -106,30 +106,18 @@ macro_rules! __diesel_operator_body {
 #[macro_export]
 #[doc(hidden)]
 macro_rules! __diesel_operator_to_sql {
-    (
-        notation = infix,
-        operator_expr = $op:expr,
-        field_exprs = ($left:expr, $right:expr),
-    ) => {
+    (notation = infix,operator_expr = $op:expr,field_exprs = ($left:expr, $right:expr),) => {
         $left;
         $op;
         $right;
     };

-    (
-        notation = postfix,
-        operator_expr = $op:expr,
-        field_exprs = ($expr:expr),
-    ) => {
+    (notation = postfix,operator_expr = $op:expr,field_exprs = ($expr:expr),) => {
         $expr;
         $op;
     };

-    (
-        notation = prefix,
-        operator_expr = $op:expr,
-        field_exprs = ($expr:expr),
-    ) => {
+    (notation = prefix,operator_expr = $op:expr,field_exprs = ($expr:expr),) => {
         $op;
         $expr;
     };
@@ -258,7 +246,7 @@ macro_rules! diesel_postfix_operator {
         diesel_postfix_operator!($name, $operator, $crate::sql_types::Bool);
     };

-    ($name:ident, $operator:expr, backend: $backend:ty) => {
+    ($name:ident, $operator:expr,backend: $backend:ty) => {
         diesel_postfix_operator!($name, $operator, $crate::sql_types::Bool, backend: $backend);
     };

@@ -275,7 +263,7 @@ macro_rules! diesel_postfix_operator {
         );
     };

-    ($name:ident, $operator:expr, $return_ty:ty, backend: $backend:ty) => {
+    ($name:ident, $operator:expr, $return_ty:ty,backend: $backend:ty) => {
         __diesel_operator_body!(
             notation = postfix,
             struct_name = $name,
@@ -303,7 +291,7 @@ macro_rules! diesel_prefix_operator {
         diesel_prefix_operator!($name, $operator, $crate::sql_types::Bool);
     };

-    ($name:ident, $operator:expr, backend: $backend:ty) => {
+    ($name:ident, $operator:expr,backend: $backend:ty) => {
         diesel_prefix_operator!($name, $operator, $crate::sql_types::Bool, backend: $backend);
--- a/diesel/src/macros/mod.rs
+++ b/diesel/src/macros/mod.rs
@@ -839,7 +839,7 @@ macro_rules! __diesel_table_impl {
 #[macro_export]
 #[doc(hidden)]
 macro_rules! __diesel_table_query_source_impl {
-    ($table_struct:ident, public, $table_name:expr) => {
+    ($table_struct:ident,public, $table_name:expr) => {
         impl QuerySource for $table_struct {
             type FromClause = Identifier<'static>;
             type DefaultSelection = <Self as Table>::AllColumns;
@@ -966,12 +966,13 @@ macro_rules! joinable_inner {
     };

     (
-        left_table_ty = $left_table_ty:ty,
-        right_table_ty = $right_table_ty:ty,
-        right_table_expr = $right_table_expr:expr,
-        foreign_key = $foreign_key:path,
-        primary_key_ty = $primary_key_ty:ty,
-        primary_key_expr = $primary_key_expr:expr,
+        left_table_ty =
+        $left_table_ty:ty,right_table_ty =
+        $right_table_ty:ty,right_table_expr =
+        $right_table_expr:expr,foreign_key =
+        $foreign_key:path,primary_key_ty =
+        $primary_key_ty:ty,primary_key_expr =
+        $primary_key_expr:expr,
     ) => {
         impl $crate::JoinTo<$right_table_ty> for $left_table_ty {
             type FromClause = $right_table_ty;
@nrc nrc added the p-low label Jun 24, 2018
ayazhafiz added a commit to ayazhafiz/rustfmt that referenced this issue Jun 8, 2020
Adds regression tests for the following issues which seem to be fixed on
master:

Closes rust-lang#1762
Closes rust-lang#2201
Closes rust-lang#2388
Closes rust-lang#2672
Closes rust-lang#2755
Closes rust-lang#2947
Closes rust-lang#2978
Closes rust-lang#3148
Closes rust-lang#3206

@topecongiro @calebcartwright appologies for the large number of issues
in this commit; if you prefer I can split it up into 2+.
ayazhafiz added a commit to ayazhafiz/rustfmt that referenced this issue Jun 9, 2020
Adds regression tests for the following issues which seem to be fixed on
master:

Closes rust-lang#1762
Closes rust-lang#2388
Closes rust-lang#2672
Closes rust-lang#2755
Closes rust-lang#2947
Closes rust-lang#2978
Closes rust-lang#3148
Closes rust-lang#3206

@topecongiro @calebcartwright appologies for the large number of issues
in this commit; if you prefer I can split it up into 2+.
calebcartwright pushed a commit that referenced this issue Jun 9, 2020
* Prune stale issues

Adds regression tests for the following issues which seem to be fixed on
master:

Closes #1762
Closes #2388
Closes #2672
Closes #2755
Closes #2947
Closes #2978
Closes #3148
Closes #3206

@topecongiro @calebcartwright appologies for the large number of issues
in this commit; if you prefer I can split it up into 2+.

* fixup! Prune stale issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants