Skip to content

Remove "placeholder constants" #3131

Closed as not planned
Closed as not planned

Description

@workingjubilee

It's common for C APIs to define constant values to denote the "last" value in a set of constants, like ELAST or IPPROTO_MAX. This seems prone to weird bugs, and these constants provide very marginal benefit to Rust programmers. Since we're considering some breakage anyways, we should just remove these values where we are made aware of them.

See:

Activity

  1. JohnTitor commented on Mar 3, 2023

    @JohnTitor
    Member

    👍, before 0.3, I'd like to deprecate these values.

  2. JohnTitor commented on Apr 19, 2023

    @JohnTitor
    Member

    Noticed that we have a lot of *MAX consts and deprecating manually is quite hard. We could write a script but it can cause a false positive, hmm. For now, I've edited the PR template to mention this concern.

  3. added a commit that references this issue on Apr 19, 2023
  4. Amanieu commented on Mar 15, 2024

    @Amanieu
    Member

    An alternative to deleting these placeholder constants would be to still provide them but not make any guarantees about their value moving forward. This means that we would be free to change the value of these constants without it being considered a breaking change.

    CI tests should specifically exclude these, although it would be nice to make CI fail only if our value for such constants is lower than the one on the system.

  5. added this to the 1.0 milestone on Aug 12, 2024
  6. added
    E-mediumE-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate.
    and removed on Aug 29, 2024
  7. 60 remaining items

  8. dybucc commented on Jul 10, 2026

    @dybucc
    Contributor

    a bunch of constants got annotated with doc comments in 1 2 3 4 5 6, and the new usage guidelines mention that these symbols are likely to change without libc releasing a breaking release 7.

    i'm wondering if this issue needs rewording or otherwise repurposing?

    Footnotes

    1. linux_l4re: annotate unstable *NUM constants #5123 ↩

    2. Annotate unstable *MAX constants #5122 ↩

    3. unix: annotate unstable *COUNT constants #5121 ↩

    4. Annotate unstable *LAST constants #5120 ↩

    5. freebsd: annotate unstable RAND_MAX #5119 ↩

    6. bsd: Annotate ELAST constants as unstable #5118 ↩

    7. https://github.com/rust-lang/libc/blob/70c67fe2ec83eda97646b49cab2bcbd1603a65ea/src/lib.rs#L134 ↩

  9. tgross35 commented on Jul 21, 2026

    @tgross35
    Member

    These constants have valid uses that make them not worth removing, so we're going to keep them around. We have a bit in the usage guidelines to help users avoid issues here.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugE-mediumE-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate.breakage-candidate

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions