Inconsistent formating of long method call chains
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
In the following example, the first long method call chain is kept at the outer indentation level, while the second is indented by one:
fn very_very_very_very_very_long_fun_name(x: i32) -> Vec<i32> {
vec![x]
}
fn main() {
let very_very_very_very_very_very_very_very_very_long_var_name = 13;
let all = very_very_very_very_very_long_fun_name(
very_very_very_very_very_very_very_very_very_long_var_name,
)
.iter()
.map(|x| x + very_very_very_very_very_very_long_var_name);
let more = 13;
let other = vec![1, 2, 3]
.iter()
.map(|x| x + very_very_very_very_very_very_long_var_name);
}
I think the first chain is formatted quite badly; everything that's part of let all should be indented by one to indicate that it is part of the same statement.
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 running rustfmt on the Rust example in the issue and compare the indentation of the two method-call chains. Trace the formatter behavior responsible for breaking and indenting chained calls; done means the let all chain is indented consistently with the surrounding statement and the existing contrasting case remains correctly formatted.
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
- Mostly clear
- Newbie friendliness
- 42/100