rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
99.01k stars 12.79k forks source link

Tracking Issue for Rust 2024: rustfmt enable `overflow_delimited_expr` #123751

Open traviscross opened 7 months ago

traviscross commented 7 months ago

This is a tracking issue for the Rust 2024-relevant parts of:

This issue is for tracking readiness for the Rust 2024 edition.

About tracking issues

Tracking issues are used to record the overall progress of implementation. They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions. A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature. Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.

Steps

cc @rust-lang/style @rust-lang/rustfmt @calebcartwright @pitaj

tmandry commented 7 months ago

It looks like there's no owner driving forward on an implementation, which we need by May 1. If there's no owner of this we should take it out of the style guide for 2024.

@calebcartwright Is this something you can own the implementation of? If not, is there an alternative owner?

calebcartwright commented 7 months ago

It looks like there's no owner driving forward on an implementation, which we need by May 1

Not objecting to this specific deadline, but also first I'm hearing of a May 1st date. Is there a communication channel I should be monitoring?

@calebcartwright Is this something you can own the implementation of? If not, is there an alternative owner?

Sure put my name down. I'm a little puzzled by the overall approach to tracking these, likely due to my own ignorance. The "implementation" is changing a boolean value, so for my own 0.02 this all feels a bit too detailed and granular :shrug:

pitaj commented 7 months ago

Just want to bring up a caveat.

I don't know how well tested the rustfmt feature is. There may or may not be some behavior differences between the current implementation in rustfmt and the specified behavior in the style guide.

ytmimi commented 7 months ago

rustdoc? do you mean rustfmt?

pitaj commented 7 months ago

rustdoc? do you mean rustfmt?

Woops yes, fixed

ytmimi commented 7 months ago

I don't know how well tested the rustfmt feature is. There may or may not be some behavior differences between the current implementation in rustfmt and the specified behavior in the style guide.

looks like there are some tests in rustfmt. Given that overflow_delimited_expr is still unstable I think it wouldn't hurt to double check that the implementation matches what's described in the style guide and maybe add some extra test cases.

ytmimi commented 7 months ago

@pitaj I believe the formatting issues you brought up in https://github.com/rust-lang/rust/pull/114764#issuecomment-1701383635 and https://github.com/rust-lang/rust/pull/114764#issuecomment-1701399540 are still issues for rustfmt unless this is the correct formatting based on the style guide:

running with overflow_delimited_expr=true

fn main() {
vbuf.write(i * 3, Bar(
    Foo { x: 1, y: 2, z: 3 },
    Foo { x: 1, y: 2, z: 3 },
    Foo { x: 1, y: 2, z: 3 },
));

vbuf.write(i + 3, &[
    [h - 0.1, v],
    [h - 0.1, v],
    [h - 0.1, v],
    [h - 0.1, v],
]);
}

into

fn main() {
    vbuf.write(
        i * 3,
        Bar(Foo { x: 1, y: 2, z: 3 }, Foo { x: 1, y: 2, z: 3 }, Foo {
            x: 1,
            y: 2,
            z: 3,
        }),
    );

    vbuf.write(i + 3, &[[h - 0.1, v], [h - 0.1, v], [h - 0.1, v], [
        h - 0.1,
        v,
    ]]);
}
pitaj commented 7 months ago

I consider those cases unfortunate, but they actually do match the behavior as currently specified by the style guide.

I did try my hand at writing up a policy to adjust for those, but it wasn't included in the end.

I think users can use comments to force specific formatting in those cases.

ytmimi commented 7 months ago

How common are those cases? I can image that some users might find this formatting worse than overflow_delimited_expr=false.

@calebcartwright I know that technically the implementation is as simple as flipping a boolean to enable this by default, but I'd also want to stabilize overflow_delimited_expr at the same time so users at least have the option to turn this off.

joshtriplett commented 2 months ago

@pitaj wrote:

I did try my hand at writing up a policy to adjust for those, but it wasn't included in the end.

I don't think I've seen that, and I'd love to. This is still an area I'd love to further improve in future style editions, along with the "this is simple" heuristics.

pitaj commented 2 months ago

My attempt: https://github.com/rust-lang/rust/commit/b754b334e078637f84ae4c20f874b221352ba21f