Skip to content

MaybeDangling: ensure references fit inside the address space - #160749

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
RalfJung:maybe-dangling-address-space
Aug 10, 2026
Merged

MaybeDangling: ensure references fit inside the address space#160749
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
RalfJung:maybe-dangling-address-space

Conversation

@RalfJung

Copy link
Copy Markdown
Member

In the RFC we left open the question of the exact validity invariant for references inside MaybeDangling. This PR implements the strictest invariant I can think of: we already require references to be aligned, now we also require "addr + size" to be computable without overflow. This ensures that whatever niches we add to references in the future, MaybeDangling preserves those niches.

Cc @rust-lang/opsem @WaffleLapkin

Tracking issue: #118166
r? @oli-obk

  • I did not use an LLM to create a change in this PR.
  • I used an LLM to create a change in this PR, and I have explained below how it was used.

@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

miri is developed in its own repository. If the Miri part of this change can be broken out, consider making this change to rust-lang/miri instead. However, if Miri needs adjusting for rustc changes, just ignore this message.

cc @rust-lang/miri

Some changes occurred to the CTFE machinery

cc @oli-obk, @lcnr

@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 8, 2026
@RalfJungRalfJung mentioned this pull request Aug 8, 2026
9 tasks

@CAD97CAD97 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.

This is the obvious validity requirement, making the relaxation for MaybeDangling simply what's required for the nominal effect. LGTM

r+ (but I don't have r+ perms)

View changes since this review

@WaffleLapkinWaffleLapkin 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.

@rust-bors

rust-borsBot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 0226819 has been approved by WaffleLapkin

It is now in the queue for this repository.

@rust-borsrust-borsBot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 10, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 10, 2026
…ace, r=WaffleLapkin
MaybeDangling: ensure references fit inside the address space
In the RFC we left open the question of the exact validity invariant for references inside `MaybeDangling`. This PR implements the strictest invariant I can think of: we already require references to be aligned, now we also require "addr + size" to be computable without overflow. This ensures that whatever niches we add to references in the future, `MaybeDangling` preserves those niches.
Cc @rust-lang/opsem @WaffleLapkin
Tracking issue: rust-lang#118166
r? @oli-obk
This was referenced Aug 10, 2026
rust-borsBot pushed a commit that referenced this pull request Aug 10, 2026
…uwer
Rollup of 9 pull requests
Successful merges:
- #158404 (trait_solver: normalize next-gen region constraints)
- #160631 (Do not eagerly download rustfmt in bootstrap)
- #160642 (mir: prohibit projection into scalable vec)
- #160749 (MaybeDangling: ensure references fit inside the address space)
- #160791 (Use recognizer functions for enums and tuple structs)
- #160500 (Fix inaccurate description for crate and pathroot)
- #160590 (Docs & bors: Replace mentions of libs-api with libs)
- #160825 (Fix references to unsupported on sys::paths::unix)
- #160852 (Use `remove_dir_all` for `./x clean`)
Failed merges:
- #160829 (bootstrap: Make `main.rs` a stub that calls into the library crate)
@rust-bors
rust-borsBot merged commit cbc9fdd into rust-lang:mainAug 10, 2026
13 checks passed
@rustbotrustbot added this to the 1.99.0 milestone Aug 10, 2026
rust-timer added a commit that referenced this pull request Aug 10, 2026
Rollup merge of #160749 - RalfJung:maybe-dangling-address-space, r=WaffleLapkin
MaybeDangling: ensure references fit inside the address space
In the RFC we left open the question of the exact validity invariant for references inside `MaybeDangling`. This PR implements the strictest invariant I can think of: we already require references to be aligned, now we also require "addr + size" to be computable without overflow. This ensures that whatever niches we add to references in the future, `MaybeDangling` preserves those niches.
Cc @rust-lang/opsem@WaffleLapkin
Tracking issue: #118166
r? @oli-obk
github-actionsBot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Aug 11, 2026
…uwer
Rollup of 9 pull requests
Successful merges:
- rust-lang/rust#158404 (trait_solver: normalize next-gen region constraints)
- rust-lang/rust#160631 (Do not eagerly download rustfmt in bootstrap)
- rust-lang/rust#160642 (mir: prohibit projection into scalable vec)
- rust-lang/rust#160749 (MaybeDangling: ensure references fit inside the address space)
- rust-lang/rust#160791 (Use recognizer functions for enums and tuple structs)
- rust-lang/rust#160500 (Fix inaccurate description for crate and pathroot)
- rust-lang/rust#160590 (Docs & bors: Replace mentions of libs-api with libs)
- rust-lang/rust#160825 (Fix references to unsupported on sys::paths::unix)
- rust-lang/rust#160852 (Use `remove_dir_all` for `./x clean`)
Failed merges:
- rust-lang/rust#160829 (bootstrap: Make `main.rs` a stub that calls into the library crate)
bjorn3 pushed a commit to bjorn3/stdarch that referenced this pull request Aug 13, 2026
…uwer
Rollup of 9 pull requests
Successful merges:
- rust-lang/rust#158404 (trait_solver: normalize next-gen region constraints)
- rust-lang/rust#160631 (Do not eagerly download rustfmt in bootstrap)
- rust-lang/rust#160642 (mir: prohibit projection into scalable vec)
- rust-lang/rust#160749 (MaybeDangling: ensure references fit inside the address space)
- rust-lang/rust#160791 (Use recognizer functions for enums and tuple structs)
- rust-lang/rust#160500 (Fix inaccurate description for crate and pathroot)
- rust-lang/rust#160590 (Docs & bors: Replace mentions of libs-api with libs)
- rust-lang/rust#160825 (Fix references to unsupported on sys::paths::unix)
- rust-lang/rust#160852 (Use `remove_dir_all` for `./x clean`)
Failed merges:
- rust-lang/rust#160829 (bootstrap: Make `main.rs` a stub that calls into the library crate)
@RalfJung
RalfJung deleted the maybe-dangling-address-space branch August 15, 2026 06:49
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 15, 2026
…=saethlin
fix buggy MaybeDangling<&T> validation logic
Fixes a critical regression in rust-lang#160749.
This is what caused the trouble in rust-lang/miri#5252.
r? @oli-obk or @saethlin
rust-timer added a commit that referenced this pull request Aug 15, 2026
Rollup merge of #161125 - RalfJung:MaybeDangling-validity, r=saethlin
fix buggy MaybeDangling<&T> validation logic
Fixes a critical regression in #160749.
This is what caused the trouble in rust-lang/miri#5252.
r? @oli-obk or @saethlin
rust-borsBot pushed a commit that referenced this pull request Aug 15, 2026
Rollup merge of #161125 - RalfJung:MaybeDangling-validity, r=saethlin
fix buggy MaybeDangling<&T> validation logic
Fixes a critical regression in #160749.
This is what caused the trouble in rust-lang/miri#5252.
r? @oli-obk or @saethlin
RalfJung pushed a commit to saethlin/miri that referenced this pull request Aug 16, 2026
fix buggy MaybeDangling<&T> validation logic
Fixes a critical regression in rust-lang/rust#160749.
This is what caused the trouble in rust-lang#5252.
r? @oli-obk or @saethlin
pullBot pushed a commit to LeeeeeeM/miri that referenced this pull request Aug 16, 2026
…uwer
Rollup of 9 pull requests
Successful merges:
- rust-lang/rust#158404 (trait_solver: normalize next-gen region constraints)
- rust-lang/rust#160631 (Do not eagerly download rustfmt in bootstrap)
- rust-lang/rust#160642 (mir: prohibit projection into scalable vec)
- rust-lang/rust#160749 (MaybeDangling: ensure references fit inside the address space)
- rust-lang/rust#160791 (Use recognizer functions for enums and tuple structs)
- rust-lang/rust#160500 (Fix inaccurate description for crate and pathroot)
- rust-lang/rust#160590 (Docs & bors: Replace mentions of libs-api with libs)
- rust-lang/rust#160825 (Fix references to unsupported on sys::paths::unix)
- rust-lang/rust#160852 (Use `remove_dir_all` for `./x clean`)
Failed merges:
- rust-lang/rust#160829 (bootstrap: Make `main.rs` a stub that calls into the library crate)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@RalfJung@rustbot@CAD97@WaffleLapkin@oli-obk