Skip to content

bsd: Annotate ELAST constants as unstable#5118

Merged
tgross35 merged 1 commit into
rust-lang:mainfrom
dybucc:elast-deprecation
Jun 19, 2026
Merged

bsd: Annotate ELAST constants as unstable#5118
tgross35 merged 1 commit into
rust-lang:mainfrom
dybucc:elast-deprecation

Conversation

@dybucc

@dybucc dybucc commented May 27, 2026

Copy link
Copy Markdown
Contributor

Description

This set of constants had already been discussed to cause some issues in #3131. This patch deprecates such bug-prone and latest-error symbols such that the interface to the libc crate is not prone to SemVer-breakage as often as the values change upstream.

Note the NetBSD constant was left unmodified as it already had been annotated with a deprecation attribute.

If you yourself want to help out in the deprecation effort for this type of constants across the libc crate, maybe try out the libc-constant-deprecator crate. It's been the tool used to perform the changes that have been submitted in this PR, and it very much welcomes bug reports.

Sources

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are included (see #3131)
  • Tested locally (cd libc-test && cargo test --target mytarget); especially relevant for platforms that may not be checked in CI

@rustbot

rustbot commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in a NetBSD-like module

cc @semarie

Some changes occurred in an OpenBSD module

cc @semarie

@rustbot

This comment has been minimized.

@dybucc dybucc force-pushed the elast-deprecation branch 2 times, most recently from 53d55bf to cd01c4c Compare May 28, 2026 10:45
@rustbot

This comment has been minimized.

@JohnTitor JohnTitor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you should deprecate them for 0.2 and remove them for 1.0. Same for similar your PRs.

View changes since this review

@rustbot

rustbot commented May 31, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@dybucc

dybucc commented May 31, 2026

Copy link
Copy Markdown
Contributor Author

I think you should deprecate them for 0.2 and remove them for 1.0. Same for similar your PRs.

View changes since this review

I don't quite understand what you mean. You mention deprecating for the 0.2 release, and removal for
the 1.0 release, but literally doing that means opening up separate PRs where I target these same
changes for the libc-0.2 branch, and removal (alongside modification of the corresponding *.txt
SemVer files) for the main branch. Just so I don't get things wrong, is that what you're implying?

Also, I left some comments, especially in #5122, that I would like to get external feedback on, if
you don't mind.

@rustbot ready

@JohnTitor

Copy link
Copy Markdown
Member

Adding a deprecation attr for 1.0 doesn't make sense at all. You need to deprecate them for 0.2, see #4343 as an example.

@rustbot author

@dybucc

dybucc commented May 31, 2026

Copy link
Copy Markdown
Contributor Author

Adding a deprecation attr for 1.0 doesn't make sense at all. You need to deprecate them for 0.2,
see #4343 as an example.

@rustbot author

Thanks. Done.

Should I also remove them from the SemVer plain text files?

@rustbot ready

@rustbot

This comment has been minimized.

@JohnTitor

Copy link
Copy Markdown
Member

Should I also remove them from the SemVer plain text files?

No in this PR, let's do that in a PR actually removing them.

@JohnTitor JohnTitor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, but this would make a lot of warnings in the world so cc @tgross35 to be seconded if we're ready to go ahead or not.

View changes since this review

@JohnTitor JohnTitor added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Jun 7, 2026
dybucc added a commit to dybucc/libc that referenced this pull request Jun 8, 2026
This follows from rust-lang#5118, where all these symbols were
deprecated. @JohnTitor then advised for their removal in a separate PR
that was not on track to a stable release.

There have been a few more symbols that had to be altogether removed
because they relied on the now non-existent constants. See the
accompanying PR for details.
dybucc added a commit to dybucc/libc that referenced this pull request Jun 8, 2026
This follows from rust-lang#5118, where all these symbols were deprecated.
@JohnTitor then advised for their removal in a separate PR that was not
on track to a stable release.

There have been a few more symbols that had to be altogether removed
because they relied on the now non-existent constants. See the
accompanying PR for details.
dybucc added a commit to dybucc/libc that referenced this pull request Jun 8, 2026
This follows from rust-lang#5118, where all these symbols were deprecated.
@JohnTitor then advised for their removal in a separate PR that was not
on track to a stable release.

There have been a few more symbols that had to be altogether removed
because they relied on the now non-existent constants. See the
accompanying PR for details.
@rustbot

This comment has been minimized.

@dybucc

dybucc commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

CI actually passes. There seems to be an issue with a glob import that is not used, but this has not
been changed in the patch (it's not even part of it, for that matter.) For some reason, rebasing
onto main with dependabot updates has ended up with a warning across all of my open PRs due to
that one (now apparently unused) import.

dybucc added a commit to dybucc/libc that referenced this pull request Jun 15, 2026
This is a follow up from rust-lang#5118. That PR aimed for deprecation such the
proposed changes were included in the next stable release. This patch
completely removes the symbols for the 1.0 release.
dybucc added a commit to dybucc/libc that referenced this pull request Jun 15, 2026
This follows from rust-lang#5118, where all these symbols were deprecated.
@JohnTitor then advised for their removal in a separate PR that was not
on track to a stable release.

There have been a few more symbols that had to be altogether removed
because they relied on the now non-existent constants. See the
accompanying PR for details.
@dybucc dybucc force-pushed the elast-deprecation branch from 206303b to 5e6c6d6 Compare June 15, 2026 15:29
@rustbot

This comment has been minimized.

dybucc added a commit to dybucc/libc that referenced this pull request Jun 15, 2026
This follows from rust-lang#5118, where all these symbols were deprecated.
@JohnTitor then advised for their removal in a separate PR that was not
on track to a stable release.

There have been a few more symbols that had to be altogether removed
because they relied on the now non-existent constants. See the
accompanying PR for details.
dybucc added a commit to dybucc/libc that referenced this pull request Jun 16, 2026
This follows from rust-lang#5118, where all these symbols were deprecated.
@JohnTitor then advised for their removal in a separate PR that was not
on track to a stable release.

There have been a few more symbols that had to be altogether removed
because they relied on the now non-existent constants. See the
accompanying PR for details.
dybucc added a commit to dybucc/libc that referenced this pull request Jun 16, 2026
This follows from rust-lang#5118, where all these symbols were deprecated.
@JohnTitor then advised for their removal in a separate PR that was not
on track to a stable release.

There have been a few more symbols that had to be altogether removed
because they relied on the now non-existent constants. See the
accompanying PR for details.
@tgross35

Copy link
Copy Markdown
Contributor

I've been mulling this over a lot the past couple of weeks and have been tending to agree with Amanieu's comment in #3131 (comment). That is, I don't think deprecating to remove is the right path here: there are completely valid cases for these constants, e.g. allocating an array that can then be indexed by all possible values of an enum or looping through possible values of a flag. (I've actually needed both of these in the past couple of weeks.)

Would it be possible to find+replace the deprecation notices with a doc comment indicating that these constant values are subject to change? It can just be a terse comment linking to usage guidelines, which I'm adding in #5179 to help address this case.

@JohnTitor I'd like your thoughts here of course, given your concern in #3040 (comment). My thinking is that the failure modes here likely aren't any worse than any other constant like unsupported syscalls or flags - ELAST is just a pointer to some specific errno, you could use the errno regardless of whether or not ELAST tells you which one it is.


If you yourself want to help out in the deprecation effort for this type of constants across the libc crate, maybe try out the libc-constant-deprecator crate. It's been the tool used to perform the changes that have been submitted in this PR, and it very much welcomes bug reports.

That is quite a cool tool! You may want to rename/reframe it as something like "API reviewer" because I assume it is useful beyond libc and could pretty easily do more than deprecate. E.g. add doc comments :) or add #[non_exhaustive] to structs that are already non_exhaustive via a field (which we will eventually want once the rustc bug is fixed).

@rustbot

This comment has been minimized.

@dybucc

dybucc commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Done. From reading what may become the new usage guidelines in #5179, I decided to instead add a new macro for declaring these types of constants that automatically adds the doc comment. I've opened another PR that solely defines the macro.

Should I close the analogous PRs that remove the symbols?

Comment thread src/macros.rs Outdated
Comment on lines +410 to +414
/// This constant, among others often used in C for the purposes of denoting the
/// latest value or limit in a set of constants, is likely to change upstream.
/// For correct usage, see the [crate-level documentation][docs].
///
/// [docs]: index.html#usage-recommendations

@tgross35 tgross35 Jun 19, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we had rust-lang/rust#143549 then that would be one thing, but I'd like to avoid more functionlike macros then necessary because they tend to make things pretty messy. I think the comment can be made to fit on 1-2 lines so it's easier to copy around to all relevant values, something like:

/// This is an end marker constant, its value is likely to change across releases. See
/// [Best Practices](crate::#best-practices) for details.

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done on this PR. Will be updating the rest soon.

@tgross35

Copy link
Copy Markdown
Contributor

Should I close the analogous PRs that remove the symbols?

I think so. My concern is that removing them will break valid code where the only alternatives are going to be strictly worse.

@dybucc dybucc force-pushed the elast-deprecation branch from e70bebb to 8594165 Compare June 19, 2026 06:59
this patch annotates symbols that are known to have been the source of
semver-breaking issues by using a macro for which another pr has been
opened. these issues have been tracked thus far in rust-lang#3131.
@dybucc dybucc force-pushed the elast-deprecation branch from 8594165 to 2415e63 Compare June 19, 2026 07:00
@rustbot

rustbot commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@tgross35 tgross35 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@tgross35 tgross35 changed the title refactor: deprecate ELAST constants bsd: Annotate ELAST constants as unstable Jun 19, 2026
@tgross35 tgross35 enabled auto-merge June 19, 2026 07:03
@tgross35 tgross35 added this pull request to the merge queue Jun 19, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 19, 2026
@tgross35 tgross35 added this pull request to the merge queue Jun 19, 2026
Merged via the queue into rust-lang:main with commit aab67be Jun 19, 2026
151 of 156 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stable-nominated This PR should be considered for cherry-pick to libc's stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants