Skip to content

fix Pointer to reference conversion docs #129652

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

Merged
merged 1 commit into from
Aug 27, 2024
Merged

Conversation

RalfJung
Copy link
Member

The aliasing rules documented in #128157 are wrong, this fixes them.

@rustbot
Copy link
Collaborator

rustbot commented Aug 27, 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 Aug 27, 2024
//! there are several rules that must be followed:
//!
//! * The pointer must be properly aligned.
//!
// some microprocessors may use address 0 for an interrupt vector.
// users of these microprocessors must always read/write address 0 through
// a raw pointer, not a reference.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what the point of this was, it was anyway hidden from users. If we want to give guidance on how to access address 0, this is the wrong place. (I think currently it is always UB to access address 0, even with raw pointers.)

//! uninitialized memory through careful use of `MaybeUninit`,
//! or if the uninitialized memory is entirely contained within
//! padding bytes, since
//! [padding has the same validity invariant as `MaybeUninit`][ucg-pad].
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should repeat the validity rules here, let's just point to the reference instead.

@traviscross
Copy link
Contributor

Looks right to me. Thanks @RalfJung.

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Aug 27, 2024

📌 Commit 143f669 has been approved by traviscross

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 Aug 27, 2024
@traviscross traviscross assigned traviscross and unassigned cuviper Aug 27, 2024
@rust-log-analyzer

This comment has been minimized.

@RalfJung
Copy link
Member Author

Fixed some links.
@bors r=traviscross

@bors
Copy link
Collaborator

bors commented Aug 27, 2024

📌 Commit ab4a743 has been approved by traviscross

It is now in the queue for this repository.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 27, 2024
fix Pointer to reference conversion docs

The aliasing rules documented in rust-lang#128157 are wrong, this fixes them.
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 27, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#129401 (Partially stabilize `feature(new_uninit)`)
 - rust-lang#129581 (exit: explain our expectations for the exit handlers registered in a Rust program)
 - rust-lang#129634 (Fix tidy to allow `edition = "2024"` in `Cargo.toml`)
 - rust-lang#129635 (Use unsafe extern blocks throughout the compiler)
 - rust-lang#129645 (Fix typos in floating-point primitive type docs)
 - rust-lang#129648 (More `unreachable_pub`)
 - rust-lang#129649 (ABI compat check: detect unadjusted ABI mismatches)
 - rust-lang#129652 (fix Pointer to reference conversion docs)

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

Rollup of 8 pull requests

Successful merges:

 - rust-lang#129507 (make it possible to enable const_precise_live_drops per-function)
 - rust-lang#129581 (exit: explain our expectations for the exit handlers registered in a Rust program)
 - rust-lang#129634 (Fix tidy to allow `edition = "2024"` in `Cargo.toml`)
 - rust-lang#129635 (Use unsafe extern blocks throughout the compiler)
 - rust-lang#129645 (Fix typos in floating-point primitive type docs)
 - rust-lang#129648 (More `unreachable_pub`)
 - rust-lang#129649 (ABI compat check: detect unadjusted ABI mismatches)
 - rust-lang#129652 (fix Pointer to reference conversion docs)

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

Rollup of 8 pull requests

Successful merges:

 - rust-lang#129507 (make it possible to enable const_precise_live_drops per-function)
 - rust-lang#129581 (exit: explain our expectations for the exit handlers registered in a Rust program)
 - rust-lang#129634 (Fix tidy to allow `edition = "2024"` in `Cargo.toml`)
 - rust-lang#129635 (Use unsafe extern blocks throughout the compiler)
 - rust-lang#129645 (Fix typos in floating-point primitive type docs)
 - rust-lang#129648 (More `unreachable_pub`)
 - rust-lang#129649 (ABI compat check: detect unadjusted ABI mismatches)
 - rust-lang#129652 (fix Pointer to reference conversion docs)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit ac0cc70 into rust-lang:master Aug 27, 2024
6 checks passed
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Aug 27, 2024
Rollup merge of rust-lang#129652 - RalfJung:ptr-to-ref, r=traviscross

fix Pointer to reference conversion docs

The aliasing rules documented in rust-lang#128157 are wrong, this fixes them.
@rustbot rustbot added this to the 1.82.0 milestone Aug 27, 2024
@RalfJung RalfJung deleted the ptr-to-ref branch August 28, 2024 05:40
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.

6 participants