My code needs two passes to be formatted correctly
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproduction in src/openapi/router.rs and run rustfmt 1.4.38-nightly on the shown change. Compare the first and second formatting passes, focusing on the macro arm where the unsupported-method warning changes from }, to }. Done means one rustfmt pass produces stable output for this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100