With the --file-lines option I'd expect to be able to partially format a where clause, e.g. only format one or two lines of trait bounds, without modifying any unselected lines. Currently any attempt to partially format a where clause will reformat the whole thing.
Summary
For the following Rust code in test.rs:
fn generic_fn<T>() where
T: Clone,
T: Copy,
T: Default,
{
println!("a");
}
I'd like to format just the last trait bound in the where clause with rustfmt --unstable-features --file-lines '[{"file":"test.rs","range":[4,4]}]' test.rs, without modifying any other lines.
Expected behavior
fn generic_fn<T>() where
T: Clone,
T: Copy,
T: Default,
{
println!("a");
}
Actual behavior
fn generic_fn<T>()
where
T: Clone,
T: Copy,
T: Default,
{
println!("a");
}
Configuration
rustfmt cli options used:
rustfmt --unstable-features --file-lines '[{"file":"test.rs","range":[4,4]}]' test.rs
Meta
Split off from #6868 because where clauses show up in other places than just function signatures. Similar to that issue, the issue here is that rewrite_where_clause doesn't currently try to handle the file-lines config at all. It'll need to be extended to check the selected lines and preserve the original text for lines outside the selected range.
This should be added as a blocker for #3397.
With the
--file-linesoption I'd expect to be able to partially format a where clause, e.g. only format one or two lines of trait bounds, without modifying any unselected lines. Currently any attempt to partially format a where clause will reformat the whole thing.Summary
For the following Rust code in
test.rs:I'd like to format just the last trait bound in the
whereclause withrustfmt --unstable-features --file-lines '[{"file":"test.rs","range":[4,4]}]' test.rs, without modifying any other lines.Expected behavior
Actual behavior
Configuration
rustfmtcli options used:rustfmt --unstable-features --file-lines '[{"file":"test.rs","range":[4,4]}]' test.rsMeta
Split off from #6868 because
whereclauses show up in other places than just function signatures. Similar to that issue, the issue here is thatrewrite_where_clausedoesn't currently try to handle the file-lines config at all. It'll need to be extended to check the selected lines and preserve the original text for lines outside the selected range.This should be added as a blocker for #3397.