Rustfmt fails

Is there a good place to report places where rustfmt leads to confusing and ugly formatting? I just ran into another example, where cargo fmt turned my code into this:

    get_pairs_block::<_, ()>(leftn,
                             rightn,
                             start,
                             mid,
                             splitbits,
                             mask,
                             end,
                             |(lx, rx), _| {
        // assume for simplicity that lx and rx are unique (i.e not themselves collisions of length n/2)
        let mut lstr =
            get_strings_vec::<Vec<u8>>(leftn, start, 64, lx).into_iter().next().unwrap().1;
        let rstr =
            get_strings_vec::<Vec<u8>>(rightn, mid, 64, rx).into_iter().next().unwrap().1;
        lstr.extend(&rstr);
        results.push(lstr);
    });

In case you can’t tell, that’s a function call with a whole bunch of short arguments, followed by a multiline closure (callback). I’m not sure what the solution is, but I think it would make sense to not insist on every argument being on a separate line like this, especially when the only reason the arguments don’t fit onto one line is due to a closure.

rustfmt’s issue tracker on Github is the best place for reporting problems.

You could set fn_call_width to a large value (e.g. 120) to fit long arguments in a single line (see Configurations.md for more details)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.