Implement MIR lowering for unsafe binders by compiler-errors · Pull Request #130514 · rust-lang/rust (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation29 Commits3 Checks6 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
This is the final bit of the unsafe binders puzzle. It implements MIR, CTFE, and codegen for unsafe binders, and enforces that (for now) they are Copy
. Later on, I'll introduce a new trait that relaxes this requirement to being "is Copy
or ManuallyDrop<T>
" which more closely models how we treat union fields.
Namely, wrapping unsafe binders is now Rvalue::WrapUnsafeBinder
, which acts much like an Rvalue::Aggregate
. Unwrapping unsafe binders are implemented as a MIR projection ProjectionElem::UnwrapUnsafeBinder
, which acts much like ProjectionElem::Field
.
Tracking:
compiler-errors changed the title
Initial implementation of unsafe binders Initial implementation of unsafe binder types
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Dylan-DPC added S-experimental
Status: Ongoing experiment that does not require reviewing and won't be merged in its current state.
and removed S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request
…, r=oli-obk
Add AST support for unsafe binders
I'm splitting up rust-lang#130514 into pieces. It's impossible for me to keep up with a huge PR like that. I'll land type system support for this next, probably w/o MIR lowering, which will come later.
r? @oli-obk
cc @BoxyUwU
and @lcnr
who also may want to look at this, though this PR doesn't do too much yet
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request
Rollup merge of rust-lang#134140 - compiler-errors:unsafe-binders-ast, r=oli-obk
Add AST support for unsafe binders
I'm splitting up rust-lang#130514 into pieces. It's impossible for me to keep up with a huge PR like that. I'll land type system support for this next, probably w/o MIR lowering, which will come later.
r? @oli-obk
cc @BoxyUwU
and @lcnr
who also may want to look at this, though this PR doesn't do too much yet
This comment has been minimized.
flip1995 pushed a commit to flip1995/rust that referenced this pull request
…, r=oli-obk
Add AST support for unsafe binders
I'm splitting up rust-lang#130514 into pieces. It's impossible for me to keep up with a huge PR like that. I'll land type system support for this next, probably w/o MIR lowering, which will come later.
r? @oli-obk
cc @BoxyUwU
and @lcnr
who also may want to look at this, though this PR doesn't do too much yet
bors added the S-waiting-on-author
Status: This is awaiting some action (such as code changes or more information) from the author.
label
This comment has been minimized.
@@ -0,0 +1,41 @@ |
---|
//@ known-bug: unknown |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test will (after I add a new trait instead of using Copy
) demonstrate that we reason about moves correctly with unsafe binders.
@@ -66,6 +66,10 @@ impl<'tcx> Iterator for Prefixes<'tcx> { |
---|
self.next = Some(cursor_base); |
return Some(cursor); |
} |
ProjectionElem::UnwrapUnsafeBinder(_) => { |
self.next = Some(cursor_base); |
return Some(cursor); |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just roll over unwrapunsafebinder just like with opaquecast?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the contrary, why is it valid to ignore this projection elem? I want to make sure I'm visiting it when tracking moves, right? Or am I misunderstanding how these prefixes are used?
In my brain, unsafe binders are equivalent to structs with a single field, so we should be treating this much like a field elem.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are just used for improving diagnostics, to be able to inform ppl when to split their borrows. It is useful to handle field accesses here, because borrowck can understand that any projection that goes through a field does not conflict with a projection that goes through another field. I unfortunately can't figure out how to make it care about the unsafe wrapper at all, so... 🤷 let's go with this and figure things out when we actually are using unsafe binders a lot and see some real world examples and conflicts.
📌 Commit 442b9a9 has been approved by oli-obk
It is now in the queue for this repository.
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
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request
…oli-obk
Implement MIR lowering for unsafe binders
This is the final bit of the unsafe binders puzzle. It implements MIR, CTFE, and codegen for unsafe binders, and enforces that (for now) they are Copy
. Later on, I'll introduce a new trait that relaxes this requirement to being "is Copy
or ManuallyDrop<T>
" which more closely models how we treat union fields.
Namely, wrapping unsafe binders is now Rvalue::WrapUnsafeBinder
, which acts much like an Rvalue::Aggregate
. Unwrapping unsafe binders are implemented as a MIR projection ProjectionElem::UnwrapUnsafeBinder
, which acts much like ProjectionElem::Field
.
Tracking:
bors added a commit to rust-lang-ci/rust that referenced this pull request
…iaskrgr
Rollup of 7 pull requests
Successful merges:
- rust-lang#130514 (Implement MIR lowering for unsafe binders)
- rust-lang#135684 (docs: Documented Send and Sync requirements for Mutex + MutexGuard)
- rust-lang#135760 (Add
unchecked_disjoint_bitor
per ACP373) - rust-lang#136154 (Use +secure-plt for powerpc-unknown-linux-gnu{,spe})
- rust-lang#136309 (set rustc dylib on manually constructed rustc command)
- rust-lang#136339 (CompileTest: Add Directives to Ignore
arm-unknown-*
Targets) - rust-lang#136368 (Make comma separated lists of anything easier to make for errors)
r? @ghost
@rustbot
modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request
…iaskrgr
Rollup of 6 pull requests
Successful merges:
- rust-lang#130514 (Implement MIR lowering for unsafe binders)
- rust-lang#135684 (docs: Documented Send and Sync requirements for Mutex + MutexGuard)
- rust-lang#136307 (Implement all mix/max functions in a (hopefully) more optimization amendable way)
- rust-lang#136360 (Stabilize
once_wait
) - rust-lang#136364 (document that ptr cmp is unsigned)
- rust-lang#136374 (Add link attribute for Enzyme's LLVMRust FFI)
r? @ghost
@rustbot
modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request
…iaskrgr
Rollup of 6 pull requests
Successful merges:
- rust-lang#130514 (Implement MIR lowering for unsafe binders)
- rust-lang#135684 (docs: Documented Send and Sync requirements for Mutex + MutexGuard)
- rust-lang#136307 (Implement all mix/max functions in a (hopefully) more optimization amendable way)
- rust-lang#136360 (Stabilize
once_wait
) - rust-lang#136364 (document that ptr cmp is unsigned)
- rust-lang#136374 (Add link attribute for Enzyme's LLVMRust FFI)
r? @ghost
@rustbot
modify labels: rollup
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request
Rollup merge of rust-lang#130514 - compiler-errors:unsafe-binders, r=oli-obk
Implement MIR lowering for unsafe binders
This is the final bit of the unsafe binders puzzle. It implements MIR, CTFE, and codegen for unsafe binders, and enforces that (for now) they are Copy
. Later on, I'll introduce a new trait that relaxes this requirement to being "is Copy
or ManuallyDrop<T>
" which more closely models how we treat union fields.
Namely, wrapping unsafe binders is now Rvalue::WrapUnsafeBinder
, which acts much like an Rvalue::Aggregate
. Unwrapping unsafe binders are implemented as a MIR projection ProjectionElem::UnwrapUnsafeBinder
, which acts much like ProjectionElem::Field
.
Tracking:
flip1995 pushed a commit to flip1995/rust that referenced this pull request
…oli-obk
Implement MIR lowering for unsafe binders
This is the final bit of the unsafe binders puzzle. It implements MIR, CTFE, and codegen for unsafe binders, and enforces that (for now) they are Copy
. Later on, I'll introduce a new trait that relaxes this requirement to being "is Copy
or ManuallyDrop<T>
" which more closely models how we treat union fields.
Namely, wrapping unsafe binders is now Rvalue::WrapUnsafeBinder
, which acts much like an Rvalue::Aggregate
. Unwrapping unsafe binders are implemented as a MIR projection ProjectionElem::UnwrapUnsafeBinder
, which acts much like ProjectionElem::Field
.
Tracking:
bjorn3 pushed a commit to bjorn3/rust that referenced this pull request
…oli-obk
Implement MIR lowering for unsafe binders
This is the final bit of the unsafe binders puzzle. It implements MIR, CTFE, and codegen for unsafe binders, and enforces that (for now) they are Copy
. Later on, I'll introduce a new trait that relaxes this requirement to being "is Copy
or ManuallyDrop<T>
" which more closely models how we treat union fields.
Namely, wrapping unsafe binders is now Rvalue::WrapUnsafeBinder
, which acts much like an Rvalue::Aggregate
. Unwrapping unsafe binders are implemented as a MIR projection ProjectionElem::UnwrapUnsafeBinder
, which acts much like ProjectionElem::Field
.
Tracking:
carolynzech added a commit to carolynzech/kani that referenced this pull request
carolynzech added a commit to carolynzech/kani that referenced this pull request
github-merge-queue bot pushed a commit to model-checking/kani that referenced this pull request
github-actions bot pushed a commit to tautschnig/verify-rust-std that referenced this pull request
…, r=oli-obk
Add AST support for unsafe binders
I'm splitting up rust-lang#130514 into pieces. It's impossible for me to keep up with a huge PR like that. I'll land type system support for this next, probably w/o MIR lowering, which will come later.
r? @oli-obk
cc @BoxyUwU
and @lcnr
who also may want to look at this, though this PR doesn't do too much yet
Labels
Area: Rustdoc JSON backend
Project group: Exploit mitigations
Status: Ongoing experiment that does not require reviewing and won't be merged in its current state.
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Relevant to the compiler team, which will review and decide on the PR/issue.
Relevant to the library team, which will review and decide on the PR/issue.
The Rustc Trait System Refactor Initiative (-Znext-solver)