Skip to content

allow references to point to invalid values - #2335

Closed
nia-e wants to merge 1 commit into
rust-lang:masterfrom
nia-e:master
Closed

allow references to point to invalid values#2335
nia-e wants to merge 1 commit into
rust-lang:masterfrom
nia-e:master

Conversation

@nia-e

@nia-e nia-e commented Aug 23, 2026

Copy link
Copy Markdown
Member

Per @rust-lang/opsem FCP in rust-lang/unsafe-code-guidelines#414 (comment), partially unblocking rust-lang/rust#161452. This would mean invalid references are downgraded to being library UB (but invalid values are still lang UB).

@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Aug 23, 2026

r[undefined.validity.reference-box]
* A reference or [`Box<T>`] must be aligned and non-null, it cannot be [dangling], and it must point to a valid value (in case of dynamically sized types, using the actual dynamic type of the pointee as determined by the [metadata]). Note that the last point (about pointing to a valid value) remains a subject of some debate.
* A reference or [`Box<T>`] must be aligned and non-null, and cannot be [dangling].

@RalfJung RalfJung Aug 23, 2026

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.

This is missing the requirement that the pointee type must be inhabited (and there is a bit of subtlety around what exactly "inhabited" means).

View changes since the review

@RalfJung

Copy link
Copy Markdown
Member

#2337 supersedes this PR.

@nia-e nia-e closed this Aug 23, 2026
@rustbot rustbot removed the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Aug 23, 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.

3 participants