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

SemVer hazards around changes to static items #15126

Open
obi1kenobi opened this issue Jan 30, 2025 · 1 comment
Open

SemVer hazards around changes to static items #15126

obi1kenobi opened this issue Jan 30, 2025 · 1 comment
Labels
A-semver Area: semver specifications, version matching, etc.

Comments

@obi1kenobi
Copy link
Member

The following SemVer hazards around changes to static items are not yet documented in the SemVer reference page.

Changing whether a static is mutable or immutable

This change is breaking in both directions:

Internal mutability, and possible extern mutation

Moved from rust-lang/reference#1724 (comment)

As of Rust 1.83, some static values can be assigned to const items, with the limitation that the const may not contain anything mutable: https://doc.rust-lang.org/beta/reference/items/constant-items.html#r-items.const.final-value-immutable

There are two possible breaking changes here:

  • a pub static newly becomes internally-mutable
  • a pub static becomes extern, in which case the compiler will conservatively assume it may be mutable

To demonstrate a breaking change via these hazards, consider an assignment of the static to a const akin to:

pub const WITNESS: i64 = THE_STATIC;

This will only work so long as the static is non-extern, not mut, and not internally-mutable. The mut hazard is described above already, and doesn't require a const to demonstrate.

@obi1kenobi
Copy link
Member Author

Meta: if there's a more useful title format I could have used, or if you have any suggestions for other changes I could make to make issues like this more useful and actionable, I'd love to know about them!

From working on cargo-semver-checks, I also have a list of other SemVer hazards that aren't fully described in the SemVer reference. If it would be useful to track them via issues here, I'd be happy to do the work of opening more issues. I appreciate your work and I don't want you all to feel pressured, so I'd only do it if you feel it would be genuinely useful.

@ehuss ehuss added the A-semver Area: semver specifications, version matching, etc. label Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-semver Area: semver specifications, version matching, etc.
Projects
None yet
Development

No branches or pull requests

2 participants