Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine rustfmt #2325

Merged
merged 1 commit into from
Apr 26, 2024
Merged

Refine rustfmt #2325

merged 1 commit into from
Apr 26, 2024

Conversation

kchibisov
Copy link
Member

That's just a prototype how it should look to apply nightly rustfmt with a bit more involved rules.

There's no intent to do that before the new keyboard API rework.

Comment on lines 6 to 8
use winit::{
event::{Event, KeyboardInput, WindowEvent},
event_loop::EventLoop,
window::WindowBuilder,
};
use winit::event::{Event, KeyboardInput, WindowEvent};
use winit::event_loop::EventLoop;
use winit::window::WindowBuilder;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally quite like this grouping, are we missing an option?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dislike it, I find that it makes merge conflicts harder

Copy link
Member

@maroider maroider Jun 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've personally switched to imports_granularity = "Item" in my current personal project to make my life easier on that front, but it does tend to create massive walls of use statements.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally hate the grouping current winit is using, and personally I don't have it in Wayland backend, since rustfmt doesn't enforce it. It just nearly impossible to read it and rebase. Or maybe I've just used to Module option.

@aloucks
Copy link
Contributor

aloucks commented Jun 13, 2022

For what it's worth, +nightly was originally used as the formatting check, but caused problems for contributors who weren't using nightly Rust. See also: #1074

@daxpedda daxpedda modified the milestone: Version 0.30.0 Feb 9, 2024
@madsmtm
Copy link
Member

madsmtm commented Feb 9, 2024

We agreed to do this in today's meeting, though only after a few of the larger in-flight PRs have been merged.

I raised the concern that users would have to run cargo +nightly fmt, and that their editor would be set to run the stable rustfmt by default. My concerns would be assuaged if we:

  1. Added a note about this to CONTRIBUTING.md, perhaps noting that you can configure rust-analyzer.rustfmt.extraArgs with ["+nightly"] to make this work by default.
  2. Changed the CI step to be called "Check nightly formatting".

Copy link
Member

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the only thing you've changed is rustfmt.toml. Had a look at it, I agree with all the options, though I think you might get trouble with reorder_impl_items until madsmtm/objc2#479 is resolved, so might want to wait with that.

@kchibisov
Copy link
Member Author

The only thing I could change is comment width to 80, so it's a bit more compact, but that's about it.

Copy link
Member

@daxpedda daxpedda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unstable_features is missing.

I would also like to add the following:

I'm also against the following rules because they move away from the default Rust style:

rustfmt.toml Outdated
use_small_heuristics = "Max"
normalize_comments = true
reorder_impl_items = true
use_try_shorthand = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is deprecated, I don't think we need that in Rustfmt.

rustfmt.toml Outdated
use_small_heuristics = "Max"
normalize_comments = true
reorder_impl_items = true
use_try_shorthand = true
force_explicit_abi=true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed, its default is already true.

@kchibisov
Copy link
Member Author

And use_small is the main reason for me to change it, because the code is way easier to read with it, since it's more compact.

@kchibisov kchibisov marked this pull request as ready for review April 26, 2024 09:57
@kchibisov kchibisov force-pushed the new-rustfmt branch 2 times, most recently from 7e2b7f4 to 8d94895 Compare April 26, 2024 11:50
Stable rustfmt lacks a lot of features resulting in worse formatted
code, thus use nightly formatter.
@daxpedda daxpedda merged commit 7b0c7b6 into rust-windowing:master Apr 26, 2024
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants