Skip to content

My code needs two passes to be formatted correctly #5193

@msrd0

Description

@msrd0

When making the following change from https://github.com/msrd0/gotham_restful/tree/5181b4b448003a06e01d50609371a9578db9d067, rustfmt (rustfmt 1.4.38-nightly (5e57faa 2022-01-19)) needs two passes to correctly format the code:

My Change:

$ git diff src/openapi/router.rs |cat
diff --git a/src/openapi/router.rs b/src/openapi/router.rs
index dbcecb8a5..ec5fdcc21 100644
--- a/src/openapi/router.rs
+++ b/src/openapi/router.rs
@@ -137,8 +137,7 @@ macro_rules! implOpenapiRouter {
 					Method::PATCH => item.patch = Some(op),
 					Method::TRACE => item.trace = Some(op),
 					method => warn!(
-						"Ignoring unsupported method '{}' in OpenAPI Specification",
-						method
+						"Ignoring unsupported method '{method}' in OpenAPI Specification"
 					)
 				};
 				(self.0).openapi_builder.add_path(path, item);

First Pass of rustfmt:

$ git diff src/openapi/router.rs |cat
diff --git a/src/openapi/router.rs b/src/openapi/router.rs
index dbcecb8a5..e81e0640f 100644
--- a/src/openapi/router.rs
+++ b/src/openapi/router.rs
@@ -136,10 +136,9 @@ macro_rules! implOpenapiRouter {
 					Method::HEAD => item.head = Some(op),
 					Method::PATCH => item.patch = Some(op),
 					Method::TRACE => item.trace = Some(op),
-					method => warn!(
-						"Ignoring unsupported method '{}' in OpenAPI Specification",
-						method
-					)
+					method => {
+						warn!("Ignoring unsupported method '{method}' in OpenAPI Specification")
+					},
 				};
 				(self.0).openapi_builder.add_path(path, item);
 

Second Pass of rustfmt:

$ git diff src/openapi/router.rs |cat
diff --git a/src/openapi/router.rs b/src/openapi/router.rs
index dbcecb8a5..33937d612 100644
--- a/src/openapi/router.rs
+++ b/src/openapi/router.rs
@@ -136,10 +136,9 @@ macro_rules! implOpenapiRouter {
 					Method::HEAD => item.head = Some(op),
 					Method::PATCH => item.patch = Some(op),
 					Method::TRACE => item.trace = Some(op),
-					method => warn!(
-						"Ignoring unsupported method '{}' in OpenAPI Specification",
-						method
-					)
+					method => {
+						warn!("Ignoring unsupported method '{method}' in OpenAPI Specification")
+					}
 				};
 				(self.0).openapi_builder.add_path(path, item);
 

Notice the }, was changed to } in the second pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-matchesArea: match arms, patterns, blocks, etcC-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEonly-with-optionRequires a non-default option value to reproduce

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions