Added rustfmt rules and aspects.#722
Conversation
0d4773e to
13d8065
Compare
|
@hlopko This is still in a draft phase but would love to get your thoughts on this approach for |
|
I don't yet understand why When should I use I LGTMed the formatting PR, please merge and sync this one so there are only relevant files to review. Thank you! |
This aspect is used to gather information about a target for use with a Again, one of my goals is to have a workflow where users can easily apply rustfmt fixes but not be unable to determine that their code successfully compiles or their tests pass. Using |
dce99fc to
04e4db5
Compare
|
@hlopko Maybe https://github.com/UebelAndre/rules_rust/blob/fmt/docs/rust_fmt.md could clear some things up? |
|
I've updated the rustfmt can parse the edition from a |
6f121d7 to
15cd729
Compare
I didn't realize I could use the output groups to control what actions were run. I thought it was an all or nothing process. It seems that by having creating |
I dislike the use of |
Hurrah! Yeah, the general idea is the aspect registers more optional actions that could be run, and the |
If we're having to enumerate the lintable targets in the Then again, at least the way my org would be likely to use this is we'd replace |
I wasn't even sure adding a rule like this was a good idea. How do you pass test targets into it? I'd definitely want to make sure my |
illicitonion
left a comment
There was a problem hiding this comment.
This looks great!
Am I understanding right that there are now two independent ways of running rustfmt? One is to use an aspect + output_group, and the other is to make a rustfmt_test target which depends on all of the targets you want to rustfmt, which will allow bazel test target to do the checking with no aspect flag needed?
Correct. I just updated the PR description. You can run |
illicitonion
left a comment
There was a problem hiding this comment.
This looks great to me!
This pull request implements the following new rules
rustfmt_aspect: An aspect for parsing information from rust targets for use in therustfmtrule.rustfmt_test: A test rule for checking the formatting of a list of targets.The intended use of these rules is to have users define a
--@rules_rust//:rustfmt.toml=flag in their.bazelrcfile and begin to run the@rules_rust//tools/rustfmttarget to start formatting rust source files. I strongly feel that formatting errors should be an opt-in failure mode to keep iterating on changes fast and free from distracting (non-functional) failures. This is why there are two outuput groups forrustfmt_aspect,rustfmt_manifest(non fatal), andrustfmt_checks(fatal). To make sure formatting is totally up to date, users can use therustfmt_aspectwith therustfmt_checksoutput group in CI to have all source targets checked. To test targets individually, therustfmt_testrule can be used for more granular control.Closes #634
Closes #87