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

Update reference safety requirements #125021

Merged
merged 2 commits into from
May 12, 2024
Merged

Update reference safety requirements #125021

merged 2 commits into from
May 12, 2024

Conversation

joshlf
Copy link
Contributor

@joshlf joshlf commented May 11, 2024

Per #116677 (comment), the language as written promises too much. This PR relaxes the language to be consistent with current semantics. If and when #117945 is implemented, we can revert to the old language.

While we're here, we also require that references be non-null.

cc @RalfJung

Per rust-lang#116677 (comment), the language as written promises too much. This PR relaxes the language to be consistent with current semantics. If and when rust-lang#117945 is implemented, we can revert to the old language.
@rustbot
Copy link
Collaborator

rustbot commented May 11, 2024

r? @cuviper

rustbot has assigned @cuviper.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 11, 2024
@joshlf joshlf changed the title Relax slice safety requirements Relax reference safety requirements May 11, 2024
@RalfJung
Copy link
Member

This is probably good even with #117945, as it avoids having to explain what "dereferenceable for 0 bytes" means.

But maybe we should add that the reference is non-null? This is always true, and will remain so.

@joshlf
Copy link
Contributor Author

joshlf commented May 11, 2024

But maybe we should add that the reference is non-null? This is always true, and will remain so.

Updated the PR.

@joshlf joshlf changed the title Relax reference safety requirements Update reference safety requirements May 11, 2024
@RalfJung
Copy link
Member

Cc @rust-lang/opsem @rust-lang/lang -- I think this just clarifies the existing rules

@bors r+ rollup

@bors
Copy link
Contributor

bors commented May 12, 2024

📌 Commit 15df3d7 has been approved by RalfJung

It is now in the queue for this repository.

@bors bors 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 May 12, 2024
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request May 12, 2024
Update reference safety requirements

Per rust-lang#116677 (comment), the language as written promises too much. This PR relaxes the language to be consistent with current semantics. If and when rust-lang#117945 is implemented, we can revert to the old language.

While we're here, we also require that references be non-null.

cc `@RalfJung`
bors added a commit to rust-lang-ci/rust that referenced this pull request May 12, 2024
…llaumeGomez

Rollup of 4 pull requests

Successful merges:

 - rust-lang#124807 (Migrate `run-make/rustdoc-io-error` to `rmake.rs`)
 - rust-lang#125021 (Update reference safety requirements)
 - rust-lang#125030 (Fix some minor issues from the ui-test auto-porting)
 - rust-lang#125036 (solve: all "non-structural" logging to trace)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request May 12, 2024
…llaumeGomez

Rollup of 4 pull requests

Successful merges:

 - rust-lang#125021 (Update reference safety requirements)
 - rust-lang#125022 (Migrate rustdoc scrape examples ordering)
 - rust-lang#125030 (Fix some minor issues from the ui-test auto-porting)
 - rust-lang#125036 (solve: all "non-structural" logging to trace)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 5087947 into rust-lang:master May 12, 2024
6 checks passed
@rustbot rustbot added this to the 1.80.0 milestone May 12, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 12, 2024
Rollup merge of rust-lang#125021 - joshlf:patch-11, r=RalfJung

Update reference safety requirements

Per rust-lang#116677 (comment), the language as written promises too much. This PR relaxes the language to be consistent with current semantics. If and when rust-lang#117945 is implemented, we can revert to the old language.

While we're here, we also require that references be non-null.

cc ``@RalfJung``
@joshlf joshlf deleted the patch-11 branch May 13, 2024 17:19
@joshlf joshlf mentioned this pull request May 13, 2024
87 tasks
joshlf added a commit to google/zerocopy that referenced this pull request Sep 7, 2024
Now that [1] is completed, zero-sized accesses no longer require
provenance. Per [2], zero-sized references are no longer required to be
dereferenceable, and so may not carry provenance.

This commit updates `Ptr`'s invariants to not require provenance or a
valid allocation when its referent is zero-sized.

[1] rust-lang/rust#117945
[2] rust-lang/rust#125021
joshlf added a commit to google/zerocopy that referenced this pull request Sep 7, 2024
Now that [1] is completed, zero-sized accesses no longer require
provenance. Per [2], zero-sized references are no longer required to be
dereferenceable, and so may not carry provenance.

This commit updates `Ptr`'s invariants to not require provenance or a
valid allocation when its referent is zero-sized.

[1] rust-lang/rust#117945
[2] rust-lang/rust#125021

Closes #874
github-merge-queue bot pushed a commit to google/zerocopy that referenced this pull request Sep 7, 2024
Now that [1] is completed, zero-sized accesses no longer require
provenance. Per [2], zero-sized references are no longer required to be
dereferenceable, and so may not carry provenance.

This commit updates `Ptr`'s invariants to not require provenance or a
valid allocation when its referent is zero-sized.

[1] rust-lang/rust#117945
[2] rust-lang/rust#125021

Closes #874
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library 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