file-lines can't partially format function signatures
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
With the --file-lines option I'd expect to be able to partially format a function's signature, e.g. only format one argument while leaving the rest of the signature as-is. But any attempt to format the function signature formats the whole thing.
Summary
For the following code in test.rs:
fn long_fn_decl(
arg: i32,
arg2: i32,
arg3: i32,
)
{
println!("a");
}
I would like to use --file-lines '[{"file":"test.rs","range":[2,4]}]' to format just the arguments to the function, without modifying any other lines.
Expected behavior
fn long_fn_decl(
arg: i32,
arg2: i32,
arg3: i32,
)
{
println!("a");
}
Actual behavior
fn long_fn_decl(arg: i32, arg2: i32, arg3: i32) {
println!("a");
}
Configuration
rustfmt cli options used:
rustfmt --unstable-features --file-lines '[{"file":"test.rs","range":[2,4]}]' test.rs
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 command in the issue using the provided test.rs input and --file-lines range. Trace the rustfmt handling for partial ranges and add regression coverage for formatting only the selected function arguments; done means the expected indentation changes while the rest of the signature and body remain unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100