Skip to content

add borrow model test for mixed-mutability static#5103

Merged
RalfJung merged 1 commit into
rust-lang:masterfrom
RalfJung:mixed-mutability-static
Jun 11, 2026
Merged

add borrow model test for mixed-mutability static#5103
RalfJung merged 1 commit into
rust-lang:masterfrom
RalfJung:mixed-mutability-static

Conversation

@RalfJung

@RalfJung RalfJung commented Jun 11, 2026

Copy link
Copy Markdown
Member

I actually don't understand why this is UB in Tree Borrows -- somehow "precise interior mutable" tracking seems to be kicking in?
This came up in rust-lang/rust#156789

Cc @JoJoDeveloping

@rustbot rustbot added the S-waiting-on-review Status: Waiting for a review to complete label Jun 11, 2026
@RalfJung

Copy link
Copy Markdown
Member Author

Ah. The MIR has this:

_2 = const {alloc1: &(i32, Atomic<i32>)};

With our new "implicit retag during assignment", this shared reference gets reborrowed and (with precise UnsafeCell tracking) it becomes immutable.

I think this was not UB before the "implicit retag" PR.
Seems useful to have this test so we notice if this ever changes.

@RalfJung RalfJung added this pull request to the merge queue Jun 11, 2026
Merged via the queue into rust-lang:master with commit d8f29b8 Jun 11, 2026
14 checks passed
@RalfJung RalfJung deleted the mixed-mutability-static branch June 11, 2026 13:10
@rustbot rustbot removed the S-waiting-on-review Status: Waiting for a review to complete label Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants