rust-lang / rust-lang/rustfmt

Line break missing with indent_style = "Visual"

Open
#4,026 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

The following code is formatted as follows with rustfmt 1.4.11-nightly (1838235 2019-12-03) and also rustfmt 2.0.0-rc.1-nightly (facba6a5 2020-01-14):

fn main() {
    let global_manager = GlobalManager::new_with_cb(&display,
                                                    global_filter!([WlSeat,
                                                   2,
                                                   move |seat: Main<WlSeat>, _: DispatchData| {
                                                       let seat_data =
                                                           RefCell::new(SeatData::default());
                                                       seat.as_ref()
                                                           .user_data()
                                                           .set(move || seat_data);
                                                       seat.quick_assign(seat_handler);
                                                       seats_2.borrow_mut().push(seat);
                                                   }]));
}

Looks like it forgets to break the line after =, inserting the line break gives the desired result:

fn main() {
    let global_manager =
        GlobalManager::new_with_cb(&display,
                                   global_filter!([WlSeat,
                                                   2,
                                                   move |seat: Main<WlSeat>, _: DispatchData| {
                                                       let seat_data =
                                                           RefCell::new(SeatData::default());
                                                       seat.as_ref()
                                                           .user_data()
                                                           .set(move || seat_data);
                                                       seat.quick_assign(seat_handler);
                                                       seats_2.borrow_mut().push(seat);
                                                   }]));
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the provided Rust snippet using rustfmt 1.4.11-nightly or 2.0.0-rc.1-nightly and the Visual indentation style. Trace the formatting path for the assignment and nested function call; done means rustfmt inserts the line break after = and matches the desired output.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.