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

safe transmute: check lifetimes #129217

Merged
merged 1 commit into from
Aug 19, 2024
Merged

Conversation

jswrenn
Copy link
Member

@jswrenn jswrenn commented Aug 17, 2024

Modifies BikeshedIntrinsicFrom to forbid lifetime extensions on references. This static check can be opted out of with the Assume::lifetimes flag.

Fixes #129097

Tracking Issue: #99571

r​? @compiler-errors

@rustbot
Copy link
Collaborator

rustbot commented Aug 17, 2024

r? @fee1-dead

rustbot has assigned @fee1-dead.
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-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 17, 2024
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Modifies `BikeshedIntrinsicFrom` to forbid lifetime extensions on
references. This static check can be opted out of with the
`Assume::lifetimes` flag.

Fixes rust-lang#129097
@jswrenn jswrenn marked this pull request as ready for review August 18, 2024 22:02
#[instrument(level = "debug", skip(tcx, obligation, predicate))]
use rustc_transmute::{Answer, Assume, Condition};

/// Generate sub-obligations for reference-to-reference transmutations.
Copy link
Member

@compiler-errors compiler-errors Aug 19, 2024

Choose a reason for hiding this comment

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

You should document or link to documentation for some sort of specification that explains when two references are safely transmutable.

Copy link
Member

Choose a reason for hiding this comment

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

Or else, it would be nice to pull up these inline comments into some sort of bulleted list here.

@compiler-errors
Copy link
Member

LGTM otherwise

@compiler-errors
Copy link
Member

But I guess I also don't care to block this further

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 19, 2024

📌 Commit 17995d5 has been approved by compiler-errors

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 19, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 19, 2024
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#129194 (Fix bootstrap test `detect_src_and_out` on Windows)
 - rust-lang#129217 (safe transmute: check lifetimes)
 - rust-lang#129223 ( Fix wrong argument for `get_fn_decl`)
 - rust-lang#129235 (Check that `#[may_dangle]` is properly applied)
 - rust-lang#129245 (Fix a typo in `rustc_hir` doc comment)
 - rust-lang#129271 (Prevent double panic in query system, improve diagnostics)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 5cb30b7 into rust-lang:master Aug 19, 2024
6 checks passed
@rustbot rustbot added this to the 1.82.0 milestone Aug 19, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Aug 19, 2024
Rollup merge of rust-lang#129217 - jswrenn:transmute-lifetimes, r=compiler-errors

safe transmute: check lifetimes

Modifies `BikeshedIntrinsicFrom` to forbid lifetime extensions on references. This static check can be opted out of with the `Assume::lifetimes` flag.

Fixes rust-lang#129097

Tracking Issue: rust-lang#99571

 r​? `@compiler-errors`
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-compiler Relevant 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.

BikeshedIntrinsicFrom permits lifetime extension
6 participants