Auto merge of #68494 - matthewjasper:internal-static-ptrs, r=nikomatsakis
Make pointers to statics internal Closes #67611 r? @nikomatsakis
This commit is contained in:
commit
c2d141df59
5 changed files with 89 additions and 33 deletions
|
|
@ -0,0 +1,33 @@
|
|||
// build-pass
|
||||
// edition:2018
|
||||
|
||||
static mut A: [i32; 5] = [1, 2, 3, 4, 5];
|
||||
|
||||
fn is_send_sync<T: Send + Sync>(_: T) {}
|
||||
|
||||
async fn fun() {
|
||||
let u = unsafe { A[async { 1 }.await] };
|
||||
unsafe {
|
||||
match A {
|
||||
i if async { true }.await => (),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let index_block = async {
|
||||
let u = unsafe { A[async { 1 }.await] };
|
||||
};
|
||||
let match_block = async {
|
||||
unsafe {
|
||||
match A {
|
||||
i if async { true }.await => (),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
};
|
||||
is_send_sync(index_block);
|
||||
is_send_sync(match_block);
|
||||
is_send_sync(fun());
|
||||
}
|
||||
29
src/test/ui/generator/static-mut-reference-across-yield.rs
Normal file
29
src/test/ui/generator/static-mut-reference-across-yield.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
// build-pass
|
||||
#![feature(generators)]
|
||||
|
||||
static mut A: [i32; 5] = [1, 2, 3, 4, 5];
|
||||
|
||||
fn is_send_sync<T: Send + Sync>(_: T) {}
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
let gen_index = static || {
|
||||
let u = A[{
|
||||
yield;
|
||||
1
|
||||
}];
|
||||
};
|
||||
let gen_match = static || match A {
|
||||
i if {
|
||||
yield;
|
||||
true
|
||||
} =>
|
||||
{
|
||||
()
|
||||
}
|
||||
_ => (),
|
||||
};
|
||||
is_send_sync(gen_index);
|
||||
is_send_sync(gen_match);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue