Skip to content

Commit 3e8d36a

Browse files
committed
re-bless tests
1 parent 36e4fe5 commit 3e8d36a

5 files changed

Lines changed: 44 additions & 69 deletions

tests/mir-opt/const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-pre-optimizations.after.mir

Lines changed: 0 additions & 18 deletions
This file was deleted.

tests/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff

Lines changed: 0 additions & 44 deletions
This file was deleted.

tests/mir-opt/const_promotion_extern_static.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
//@ skip-filecheck
22
//@ ignore-endian-big
3-
extern "C" {
4-
static X: i32;
5-
}
63
static Y: i32 = 42;
74

85
// EMIT_MIR const_promotion_extern_static.BAR.PromoteTemps.diff
96
// EMIT_MIR const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-pre-optimizations.after.mir
107
static mut BAR: *const &i32 = [&Y].as_ptr();
118

12-
// EMIT_MIR const_promotion_extern_static.FOO.PromoteTemps.diff
13-
// EMIT_MIR const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-pre-optimizations.after.mir
14-
static mut FOO: *const &i32 = [unsafe { &X }].as_ptr();
15-
169
// EMIT_MIR const_promotion_extern_static.BOP.built.after.mir
1710
static BOP: &i32 = &13;
1811

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Regression test for #143174.
2+
3+
#![crate_type = "lib"]
4+
5+
type Fun = unsafe extern "C" fn();
6+
7+
struct Foo(Fun);
8+
9+
static FOO: &Foo = &Foo(BAR);
10+
//~^ ERROR cannot access extern static `BAR` [E0080]
11+
//~| ERROR use of extern static is unsafe and requires unsafe function or block [E0133]
12+
13+
// Formerly part of `tests/mir-opt/const_promotion_extern_static.rs`.
14+
// Promotion of extern statics is now rejected entirely.
15+
static mut BAZ: *const &Fun = [unsafe { &BAR }].as_ptr();
16+
//~^ ERROR dangling pointer
17+
18+
unsafe extern "C" {
19+
static BAR: Fun;
20+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
error[E0080]: cannot access extern static `BAR`
2+
--> $DIR/extern-static-in-static-ice-143174.rs:9:25
3+
|
4+
LL | static FOO: &Foo = &Foo(BAR);
5+
| ^^^ evaluation of `FOO` failed here
6+
7+
error: encountered dangling pointer in final value of mutable static
8+
--> $DIR/extern-static-in-static-ice-143174.rs:15:1
9+
|
10+
LL | static mut BAZ: *const &Fun = [unsafe { &BAR }].as_ptr();
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
13+
error[E0133]: use of extern static is unsafe and requires unsafe function or block
14+
--> $DIR/extern-static-in-static-ice-143174.rs:9:25
15+
|
16+
LL | static FOO: &Foo = &Foo(BAR);
17+
| ^^^ use of extern static
18+
|
19+
= note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
20+
21+
error: aborting due to 3 previous errors
22+
23+
Some errors have detailed explanations: E0080, E0133.
24+
For more information about an error, try `rustc --explain E0080`.

0 commit comments

Comments
 (0)