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

Improve rustfmt.toml support #51

Merged
merged 5 commits into from
Apr 2, 2024
Merged

Improve rustfmt.toml support #51

merged 5 commits into from
Apr 2, 2024

Conversation

jaybosamiya
Copy link
Collaborator

This PR does a few things related to rustfmt.toml, categorized into stuff that is user-facing, and library API changes.

This should help unblock one major part of #46

User-Facing Changes

  • Improve handling of rustfmt.toml for non-verus! code
    • Rather than picking up rustfmt.toml based on working directory, it is now picked up based on the file being formatted. This now matches the search that rustfmt itself does.

Public verusfmt-as-library API

These changes should basically impact nobody, unless they are depending on verusfmt as a library (unlikely, but technically possible; my guess is that only our test code is the user of verusfmt as a library, with everyone else using it as an executable). Nonetheless, listing them here since they are technically changing the library API.

  • Remove parse_and_format from the public library API
    • The intended usage is now the more extensible verusfmt::run
  • Add support for passing in an explicit rustfmt.toml via the public library API

Note: auto-merge for this PR on accepted-review is enabled.

Previously, it would pick up from the cwd or ancestors, which can be
surprising (and also goes against what rustfmt itself does); with this
commit, we explicitly do the same sort of search that rustfmt does, and
pick up the correct rustfmt.toml, thereby making our execution
independent of where we ran from
@jaybosamiya jaybosamiya requested a review from parno April 1, 2024 23:34
@jaybosamiya jaybosamiya enabled auto-merge April 1, 2024 23:36
@jaybosamiya jaybosamiya merged commit b4d2bc6 into main Apr 2, 2024
8 checks passed
@jaybosamiya jaybosamiya deleted the rustfmt-toml-support branch April 2, 2024 13:57
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.

2 participants