-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Add escape-to-raw MIR statement #55716
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
+267
−163
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f27cd60
no more action on ref or cast, but add new MIR statement for escaping…
RalfJung b9a35dc
calling the ptr hooks no longer needs expensive preparation, remove t…
RalfJung f174099
array index accesses are stable places
RalfJung 154835e
only count deref_operand as actual deref, but not all ref-to-place co…
RalfJung 9e3f571
drop glue works with raw ptrs, it must EscapeToRaw
RalfJung b891a81
comment
RalfJung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
array index accesses are stable places
- Loading branch information
commit f174099885fed58c8053cf02bf353b6822897b75
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Retagging (from Stacked Borrows) relies on the array index being a fresh | ||
// temporary, so that side-effects cannot change it. | ||
// Test that this is indeed the case. | ||
|
||
unsafe fn foo(z: *mut usize) -> u32 { | ||
*z = 2; | ||
99 | ||
} | ||
|
||
fn main() { | ||
let mut x = [42, 43, 44]; | ||
let mut y = 1; | ||
let z: *mut usize = &mut y; | ||
x[y] = unsafe { foo(z) }; | ||
} | ||
|
||
// END RUST SOURCE | ||
// START rustc.main.EraseRegions.after.mir | ||
// bb0: { | ||
// ... | ||
// _6 = &mut _2; | ||
// _5 = &mut (*_6); | ||
// _4 = move _5 as *mut usize (Misc); | ||
// _3 = move _4; | ||
// ... | ||
// _8 = _3; | ||
// _7 = const foo(move _8) -> bb1; | ||
// } | ||
// | ||
// bb1: { | ||
// ... | ||
// _9 = _2; | ||
// _10 = Len(_1); | ||
// _11 = Lt(_9, _10); | ||
// assert(move _11, "index out of bounds: the len is move _10 but the index is _9") -> bb2; | ||
// } | ||
// | ||
// bb2: { | ||
// _1[_9] = move _7; | ||
// ... | ||
// return; | ||
// } | ||
// END rustc.main.EraseRegions.after.mir |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.