reorder_impl_items doesn't maintain newlines
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Reproduction information
Example code:
pub struct BeautifulStruct;
impl BeautifulStruct {
/// Another awesome doc
const LMAO: i32 = 42;
/// Awesome doc
const ROFL: i32 = 10;
}
fn main() {
println!("Hello, world!");
}
Content of ~/.config/rusfmt/rustfmt.toml:
reorder_impl_items = true
Output of rustfmt -V: rustfmt 1.4.37-nightly (7c3872e 2021-06-24)
Problem
If I run rustfmt with the settings and the file above, rustfmt changes the file to this:
pub struct BeautifulStruct;
impl BeautifulStruct {
/// Another awesome doc
const LMAO: i32 = 42;
/// Awesome doc
const ROFL: i32 = 10;
}
fn main() {
println!("Hello, world!");
}
But I'd expect to be like this:
pub struct BeautifulStruct;
impl BeautifulStruct {
/// Another awesome doc
const LMAO: i32 = 42;
/// Awesome doc
const ROFL: i32 = 10;
}
fn main() {
println!("Hello, world!");
}
If you don't see the difference: There's a blank line between const LMAO: i32 = 42; and the documentation paragraph /// Awesome doc in my "expectation-example".
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 by reproducing the example with rustfmt and the shown rustfmt.toml setting, focusing on reorder_impl_items and the lost blank line between the two documented constants. Done means the formatted output preserves that blank line while still reordering implementation items.
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