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

ci: use some tricks to format macro bodies #4107

Merged
merged 6 commits into from
Nov 19, 2024

Conversation

tgross35
Copy link
Contributor

We have a lot of syntax contained within macro bodies, which rustfmt doesn't touch. Add a hack that replaces relevant macro invocations with functions, formats, then resets.

@rustbot
Copy link
Collaborator

rustbot commented Nov 18, 2024

r? @JohnTitor

rustbot has assigned @JohnTitor.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 19, 2024
Run `ci/style.sh` with the changes introduced in [1].

[1]: rust-lang#4107
@tgross35 tgross35 force-pushed the format-macro-bodies branch from eee7658 to a0c7f80 Compare November 19, 2024 02:43
@tgross35 tgross35 marked this pull request as ready for review November 19, 2024 02:45
@rustbot
Copy link
Collaborator

rustbot commented Nov 19, 2024

Some changes occurred in OpenBSD module

cc @semarie

Some changes occurred in solarish module

cc @jclulow, @pfmooney

tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 19, 2024
Start with the commit for formatting macro bodies in [1].

[1]: rust-lang#4107
@tgross35
Copy link
Contributor Author

This still isn't ideal, I really wish rustfmt handled something like this out of the box even if unstable. In any case, this is significantly nicer than just having the majority of this codebase unformatted because everything needs a macro wrapper.

Sorry everyone, conflicts ahead 🚢

@tgross35 tgross35 added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Nov 19, 2024
@tgross35 tgross35 enabled auto-merge November 19, 2024 02:50
Currently this only matches `$body` if every line ends with a semicolon.
Make this simpler by just using the `block` matcher.

Additionally, allow a trailing comma.
Apparently we already violate this in a few places, it just doesn't show
up because whitespace doesn't line up with what we expect (lack of
formatting). Just disable it for now so we can format the files.
The script shouldn't need to update `rustfmt` every time it gets run.

Additionally, only pass `--check` when in CI so this script can be used
for invoking the formatter locally.
We have a lot of syntax contained within macro bodies, which `rustfmt`
doesn't touch. Add a hack that replaces relevant macro invocations with
functions, formats, then resets.
Run `ci/style.sh` with the changes introduced in [1].

[1]: rust-lang#4107
Start with the commit for formatting macro bodies in [1].

[1]: rust-lang#4107
@tgross35 tgross35 force-pushed the format-macro-bodies branch from 1782543 to 6269954 Compare November 19, 2024 02:57
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 19, 2024
Currently this only matches `$body` if every line ends with a semicolon.
Make this simpler by just using the `block` matcher.

Additionally, allow a trailing comma.

(backport <rust-lang#4107>)
(cherry picked from commit 0ac42fd)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 19, 2024
Apparently we already violate this in a few places, it just doesn't show
up because whitespace doesn't line up with what we expect (lack of
formatting). Just disable it for now so we can format the files.

(backport <rust-lang#4107>)
(cherry picked from commit 0189456)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 19, 2024
The script shouldn't need to update `rustfmt` every time it gets run.

Additionally, only pass `--check` when in CI so this script can be used
for invoking the formatter locally.

(backport <rust-lang#4107>)
(cherry picked from commit 64ed860)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 19, 2024
We have a lot of syntax contained within macro bodies, which `rustfmt`
doesn't touch. Add a hack that replaces relevant macro invocations with
functions, formats, then resets.

(backport <rust-lang#4107>)
(cherry picked from commit 6ab46bb)
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 19, 2024
Run `ci/style.sh` with the changes introduced in [1].

[1]: rust-lang#4107

(backport <rust-lang#4107>)

This is the `libc-0.2` version of 49cb0ff ("Apply formatting to macro
bodies"), though not a direct cherry pick.
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Nov 19, 2024
Start with the commit for formatting macro bodies in [1].

[1]: rust-lang#4107

(backport <rust-lang#4107>)

This is the `libc-0.2` version of 6269954 ("Introduce a
git-blame-ignore-revs file") with the ignored rev changed to what is
applicable for this branch.
@tgross35 tgross35 added this pull request to the merge queue Nov 19, 2024
Merged via the queue into rust-lang:main with commit 1e356f9 Nov 19, 2024
44 checks passed
@tgross35 tgross35 deleted the format-macro-bodies branch November 19, 2024 04:36
@tgross35 tgross35 added stable-applied This PR has been cherry-picked to libc's stable release branch and removed stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants