-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Check type of place base (not projection) for Freeze
in IndirectlyMutableLocals
#65030
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
Changes from 1 commit
64457a1
da0969f
6487ce0
2f89429
895f9c4
91c77e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#![feature(core_intrinsics, rustc_attrs, const_raw_ptr_deref)] | ||
|
||
use std::cell::Cell; | ||
use std::intrinsics::rustc_peek; | ||
|
||
#[rustc_mir(rustc_peek_indirectly_mutable, stop_after_dataflow)] | ||
pub fn mut_ref(flag: bool) -> i32 { | ||
let mut i = 0; | ||
let cell = Cell::new(0); | ||
|
||
if flag { | ||
let p = &mut i; | ||
unsafe { rustc_peek(i) }; | ||
*p = 1; | ||
|
||
let p = &cell; | ||
unsafe { rustc_peek(cell) }; | ||
p.set(2); | ||
} else { | ||
unsafe { rustc_peek(i) }; //~ ERROR rustc_peek: bit not set | ||
unsafe { rustc_peek(cell) }; //~ ERROR rustc_peek: bit not set | ||
|
||
let p = &mut cell; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
unsafe { rustc_peek(cell) }; | ||
*p = Cell::new(3); | ||
} | ||
|
||
unsafe { rustc_peek(i) }; | ||
unsafe { rustc_peek(cell) }; | ||
i + cell.get() | ||
} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
error: rustc_peek: bit not set | ||
--> $DIR/indirect-mutation-1.rs:20:18 | ||
| | ||
LL | unsafe { rustc_peek(i) }; | ||
| ^^^^^^^^^^^^^ | ||
|
||
error: rustc_peek: bit not set | ||
--> $DIR/indirect-mutation-1.rs:21:18 | ||
| | ||
LL | unsafe { rustc_peek(cell) }; | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: stop_after_dataflow ended compilation | ||
|
||
error: aborting due to 3 previous errors | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#![feature(core_intrinsics, rustc_attrs, const_raw_ptr_deref)] | ||
|
||
use std::cell::Cell; | ||
use std::intrinsics::rustc_peek; | ||
|
||
struct Arr { | ||
inner: [Cell<i32>; 0], | ||
_peek: (), | ||
} | ||
|
||
// Zero-sized arrays are never mutable. | ||
#[rustc_mir(rustc_peek_indirectly_mutable, stop_after_dataflow)] | ||
pub fn zst(flag: bool) { | ||
{ | ||
let arr: [i32; 0] = []; | ||
let s: &mut [i32] = &mut arr; | ||
unsafe { rustc_peek(arr) }; //~ ERROR rustc_peek: bit not set | ||
} | ||
|
||
{ | ||
let arr: [Cell<i32>; 0] = []; | ||
let s: &[Cell<i32>] = &arr; | ||
unsafe { rustc_peek(arr) }; //~ ERROR rustc_peek: bit not set | ||
|
||
let ss = &s; | ||
unsafe { rustc_peek(arr) }; //~ ERROR rustc_peek: bit not set | ||
} | ||
} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
error: rustc_peek: bit not set | ||
--> $DIR/indirect-mutation-2.rs:17:18 | ||
| | ||
LL | unsafe { rustc_peek(arr) }; | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
error: rustc_peek: bit not set | ||
--> $DIR/indirect-mutation-2.rs:23:18 | ||
| | ||
LL | unsafe { rustc_peek(arr) }; | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
error: rustc_peek: bit not set | ||
--> $DIR/indirect-mutation-2.rs:26:18 | ||
| | ||
LL | unsafe { rustc_peek(arr) }; | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
error: stop_after_dataflow ended compilation | ||
|
||
error: aborting due to 4 previous errors | ||
|
Uh oh!
There was an error while loading. Please reload this page.