Skip to content

Macro cleanups#4959

Merged
tgross35 merged 3 commits intorust-lang:mainfrom
nnethercote:s
Feb 9, 2026
Merged

Macro cleanups#4959
tgross35 merged 3 commits intorust-lang:mainfrom
nnethercote:s

Conversation

@nnethercote
Copy link
Contributor

I was building rustc with -Zmacro-stats, which drew my attention to the s! macro, and I saw some improvements could be made.

@rustbot

This comment has been minimized.

It's unused. `c_enum!` is now used instead.
It doesn't seem necessary. It dates back to a large commit "Let's just
juggle everything around!" from the very old mega-PR rust-lang#21.
- Fix comments that incorrectly say that `Debug` is part of
  `extra_traits`.
- Use a consistent and sensible ordering for the traits: Clone, Copy,
  Debug; then PartialEq, Eq, Hash.
- Explain `repr` behaviour for `s_paren!`; it's different to `s!` and
  `s_no_extra_traits!`.
- Use `$pub:vis` (instead of a hard-wired `pub`) in `s_paren!` for
  consistency with the other macros.
@nnethercote nnethercote force-pushed the s branch 2 times, most recently from 6d82762 to fc62e18 Compare February 5, 2026 00:56
@tgross35
Copy link
Contributor

tgross35 commented Feb 5, 2026

Most of this looks good but the deprecated change seems to be causing the CI failure. Not sure if there is a good solution there.

@tgross35
Copy link
Contributor

tgross35 commented Feb 5, 2026

Mind posting the before & after macro-stats if you have them handy? I'm curious about the wins.

@nnethercote
Copy link
Contributor Author

I removed the commit removing the allow(deprecated).

I don't have the -Zmacro-stats measurements... these changes will have no effect on them. I just mentioned it in case anyone was wondering why on earth I was looking at these macros :)

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

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

Thank you!

@tgross35 tgross35 added this pull request to the merge queue Feb 9, 2026
@tgross35 tgross35 added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Feb 9, 2026
Merged via the queue into rust-lang:main with commit 7983094 Feb 9, 2026
51 checks passed
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Feb 9, 2026
It doesn't seem necessary. It dates back to a large commit "Let's just
juggle everything around!" from the very old mega-PR rust-lang#21.

(backport <rust-lang#4959>)
(cherry picked from commit 09cb34d)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Feb 9, 2026
- Fix comments that incorrectly say that `Debug` is part of
  `extra_traits`.
- Use a consistent and sensible ordering for the traits: Clone, Copy,
  Debug; then PartialEq, Eq, Hash.
- Explain `repr` behaviour for `s_paren!`; it's different to `s!` and
  `s_no_extra_traits!`.
- Use `$pub:vis` (instead of a hard-wired `pub`) in `s_paren!` for
  consistency with the other macros.

(backport <rust-lang#4959>)
(cherry picked from commit 7983094)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Feb 9, 2026
It doesn't seem necessary. It dates back to a large commit "Let's just
juggle everything around!" from the very old mega-PR rust-lang#21.

[ removed in `e!` as well for the cherry pick since that macro couldn't
  be removed yet on this branch - Trevor ]

(backport <rust-lang#4959>)
(cherry picked from commit 09cb34d)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Feb 9, 2026
- Fix comments that incorrectly say that `Debug` is part of
  `extra_traits`.
- Use a consistent and sensible ordering for the traits: Clone, Copy,
  Debug; then PartialEq, Eq, Hash.
- Explain `repr` behaviour for `s_paren!`; it's different to `s!` and
  `s_no_extra_traits!`.
- Use `$pub:vis` (instead of a hard-wired `pub`) in `s_paren!` for
  consistency with the other macros.

(backport <rust-lang#4959>)
(cherry picked from commit 7983094)
@tgross35 tgross35 mentioned this pull request Feb 9, 2026
github-merge-queue bot pushed a commit that referenced this pull request Feb 9, 2026
It doesn't seem necessary. It dates back to a large commit "Let's just
juggle everything around!" from the very old mega-PR #21.

[ removed in `e!` as well for the cherry pick since that macro couldn't
  be removed yet on this branch - Trevor ]

(backport <#4959>)
(cherry picked from commit 09cb34d)
github-merge-queue bot pushed a commit that referenced this pull request Feb 9, 2026
- Fix comments that incorrectly say that `Debug` is part of
  `extra_traits`.
- Use a consistent and sensible ordering for the traits: Clone, Copy,
  Debug; then PartialEq, Eq, Hash.
- Explain `repr` behaviour for `s_paren!`; it's different to `s!` and
  `s_no_extra_traits!`.
- Use `$pub:vis` (instead of a hard-wired `pub`) in `s_paren!` for
  consistency with the other macros.

(backport <#4959>)
(cherry picked from commit 7983094)
@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 Feb 9, 2026
@nnethercote nnethercote deleted the s branch February 9, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stable-applied This PR has been cherry-picked to libc's stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants