-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #572 from solson/rustup
Treat ref-to-raw cast like a reborrow: do a special kind of retag
- Loading branch information
Showing
4 changed files
with
32 additions
and
61 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1 +1 @@ | ||
nightly-2018-12-18 | ||
nightly-2018-12-21 |
This file contains 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 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 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 |
---|---|---|
@@ -1,13 +1,14 @@ | ||
// Make sure we cannot use raw ptrs that got transmuted from mutable references | ||
// (i.e, no EscapeToRaw happened). | ||
// We could, in principle, to EscapeToRaw lazily to allow this code, but that | ||
// We could, in principle, do EscapeToRaw lazily to allow this code, but that | ||
// would no alleviate the need for EscapeToRaw (see `ref_raw_int_raw` in | ||
// `run-pass/stacked-borrows.rs`), and thus increase overall complexity. | ||
use std::mem; | ||
|
||
fn main() { | ||
let mut x: i32 = 42; | ||
let raw: *mut i32 = unsafe { mem::transmute(&mut x) }; | ||
let raw = raw as usize as *mut i32; // make sure we killed the tag | ||
let mut x: [i32; 2] = [42, 43]; | ||
let _raw: *mut i32 = unsafe { mem::transmute(&mut x[0]) }; | ||
// `raw` still carries a tag, so we get another pointer to the same location that does not carry a tag | ||
let raw = (&mut x[1] as *mut i32).wrapping_offset(-1); | ||
unsafe { *raw = 13; } //~ ERROR does not exist on the stack | ||
} |