Skip to content

file-lines can't partially format function signatures #6868

@randomPoison

Description

@randomPoison

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEUO-file_linesUnstable option: file_linesneeds-triageThis issue or PR needs triaging to determine its status. Remove label once sufficiently triaged.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions