Retain newlines when reordering imports
Open
Nobody has claimed this yet.
A-comments
A-imports
A-whitespace
I-poor-formatting
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
cargo-fmt did this:
diff --git a/async-await-echo/src/main.rs b/async-await-echo/src/main.rs
index 1531b22..a654e92 100644
--- a/async-await-echo/src/main.rs
+++ b/async-await-echo/src/main.rs
@@ -1,16 +1,4 @@
use {
- hyper::{
- // Miscellaneous types from Hyper for working with HTTP.
- Body, Client, Request, Response, Server, Uri,
-
- // This function turns a closure which returns a future into an
- // implementation of the the Hyper `Service` trait, which is an
- // asynchronous function from a generic `Request` to a `Response`.
- service::service_fn,
-
- // A function which runs a future to completion using the Hyper runtime.
- rt::run,
- },
futures::{
// Extension trait for futures 0.1 futures, adding the `.compat()` method
// which allows us to use `.await` on 0.1 futures.
@@ -20,6 +8,22 @@ use {
// `TryFutureExt` adds methods to futures that return `Result` types.
future::{FutureExt, TryFutureExt},
},
+ hyper::{
+ // A function which runs a future to completion using the Hyper runtime.
+ rt::run,
+ // This function turns a closure which returns a future into an
+ // implementation of the the Hyper `Service` trait, which is an
+ // asynchronous function from a generic `Request` to a `Response`.
+ service::service_fn,
+
+ // Miscellaneous types from Hyper for working with HTTP.
+ Body,
+ Client,
+ Request,
+ Response,
+ Server,
+ Uri,
+ },
std::net::SocketAddr,
};
that rt::run, line could use an extra new line, me thinks.
rustfmt 1.4.8-nightly (6b0a4471 2019-09-20)
code is from: https://rust-lang.github.io/async-book/01_getting_started/05_http_server_example.html
Thanks.
PS: someone could probably title this better to describe this case?
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
Reproduce the formatting change using the async-book HTTP server example linked in the issue and the shown import block. Trace the import-reordering behavior that moves rt::run; done means the reorder preserves the intended blank lines and comments rather than collapsing their grouping.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100