Skip to content

Conversation

@fogodev
Copy link
Collaborator

@fogodev fogodev commented Nov 14, 2024

Based on #113 with some other tweaks. All files already formatted, just introducing this config file so we have a more normalized formatting.

@fogodev fogodev requested a review from rklaehn November 14, 2024 14:18
@fogodev fogodev changed the title Introduce a .rustfmt.toml file with configs for automatic formatting chore: introduce a .rustfmt.toml file with configs for automatic formatting Nov 14, 2024
Copy link
Collaborator

@rklaehn rklaehn left a comment

Choose a reason for hiding this comment

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

This means that cargo fmt will pick up these settings?

I like this much better than having to run a special command!

@rklaehn rklaehn merged commit a949899 into main Nov 14, 2024
14 of 15 checks passed
@rklaehn rklaehn deleted the rustfmt-config-file branch November 14, 2024 15:48
@@ -0,0 +1,15 @@
edition = "2024"
unstable_features = true
Copy link
Contributor

Choose a reason for hiding this comment

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

you can enable unstable features here? TIL, this is indeed much better!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, it forces you to call with cargo +nightly fmt or use the nightly toolchain directly

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, also discovered this. This is a pretty big downside to be fair since now everyone will run into errors with this as it no longer works correctly with normal editor integrations. In the main iroh repo we hooked up an external cargo make format command that can format it fine with stable rust without giving errors. The benefit of that approach is that by default the formatting is close enough so that rust-analyzer etc will do the right thing and folks don't need to be aware of this. Only very occasionally will you run into CI complaining about this and having to manually run cargo make format. I appreciate you still have to install a new tool in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants