You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When use lines are re-arranged by the formatter, comments are moved to the wrong line.
To Reproduce
cargo new hello_world --bin
cd hello_world
Edit src/main.rs to have these exact lines (order of lines is important)
use std::convert::TryFrom;
use std::fmt;
use std::collections::{Vec, VecDeque}; // testing
fn main() {
println!("Hello, world!");
}
cargo fmt
Check src/main.rs, the //testing comment has been moved from std::collections line to std::fmt line as shown below:
use std::collections::{Vec, VecDeque};
use std::convert::TryFrom;
use std::fmt; // testing
fn main() {
println!("Hello, world!");
}
Expected behavior
The comments in use lines should stay with the same line when lines are re-arranged (I'm assuming it's done in alphabetical order). In the above example it would be:
use std::collections::{Vec, VecDeque}; // testing
use std::convert::TryFrom;
use std::fmt;
Describe the bug
When
use
lines are re-arranged by the formatter, comments are moved to the wrong line.To Reproduce
cargo new hello_world --bin
cd hello_world
src/main.rs
to have these exact lines (order of lines is important)cargo fmt
src/main.rs
, the//testing
comment has been moved fromstd::collections
line tostd::fmt
line as shown below:Expected behavior
The comments in
use
lines should stay with the same line when lines are re-arranged (I'm assuming it's done in alphabetical order). In the above example it would be:Meta
rustfmt 1.4.25-stable (0f29ff6d 2020-11-11)
rustup component add rustfmt
cargo-fmt
I'm running this on Windows 10 (64-bit) host.
The text was updated successfully, but these errors were encountered: