poor formatting of some if/else expressions with hard_tabs = true
Open
@topecongiro is already working on this.
Since Dec 3, 2020.
A-binary-ops
I-poor-formatting
only-with-option
P-low
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
With hard_tabs = true, the formatting of some if/else expressions is shifted one level of indentation to the left. Everything works as expected when hard_tabs = false.
Input
fn main() {
let condition_a = true;
let condition_b = false;
let x = 123.456789
+ if condition_a {
x + y + z + w
} else {
123.456789
}
+ if condition_b {
x - y - z - w
} else {
123.456789
};
}
Output
The issue is the last three lines of the main() function are indented one level less than expected.
fn main() {
let condition_a = true;
let condition_b = false;
let x = 123.456789
+ if condition_a {
x + y + z + w
} else {
123.456789
} + if condition_b {
x - y - z - w
} else {
123.456789
};
}
Expected output
fn main() {
let condition_a = true;
let condition_b = false;
let x = 123.456789
+ if condition_a {
x + y + z + w
} else {
123.456789
} + if condition_b {
x - y - z - w
} else {
123.456789
};
}
Meta
- rustfmt version: rustfmt 1.4.24-stable (eb894d5 2020-11-05)
- From where did you install rustfmt?: rustup
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.
Assessment
This issue has not been assessed yet.