Skip to content

Commit b49f528

Browse files
committed
tests: debuginfo: use static mut to avoid constant folding globals.
1 parent d13d74d commit b49f528

File tree

2 files changed

+32
-31
lines changed

2 files changed

+32
-31
lines changed

src/test/debuginfo/basic-types-globals-metadata.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,26 @@
4747
#![allow(dead_code)]
4848
#![omit_gdb_pretty_printer_section]
4949

50-
51-
static B: bool = false;
52-
static I: int = -1;
53-
static C: char = 'a';
54-
static I8: i8 = 68;
55-
static I16: i16 = -16;
56-
static I32: i32 = -32;
57-
static I64: i64 = -64;
58-
static U: uint = 1;
59-
static U8: u8 = 100;
60-
static U16: u16 = 16;
61-
static U32: u32 = 32;
62-
static U64: u64 = 64;
63-
static F32: f32 = 2.5;
64-
static F64: f64 = 3.5;
50+
// N.B. These are `mut` only so they don't constant fold away.
51+
static mut B: bool = false;
52+
static mut I: int = -1;
53+
static mut C: char = 'a';
54+
static mut I8: i8 = 68;
55+
static mut I16: i16 = -16;
56+
static mut I32: i32 = -32;
57+
static mut I64: i64 = -64;
58+
static mut U: uint = 1;
59+
static mut U8: u8 = 100;
60+
static mut U16: u16 = 16;
61+
static mut U32: u32 = 32;
62+
static mut U64: u64 = 64;
63+
static mut F32: f32 = 2.5;
64+
static mut F64: f64 = 3.5;
6565

6666
fn main() {
6767
_zzz(); // #break
6868

69-
let a = (B, I, C, I8, I16, I32, I64, U, U8, U16, U32, U64, F32, F64);
69+
let a = unsafe { (B, I, C, I8, I16, I32, I64, U, U8, U16, U32, U64, F32, F64) };
7070
}
7171

7272
fn _zzz() {()}

src/test/debuginfo/basic-types-globals.rs

+16-15
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,26 @@
5252
#![allow(unused_variables)]
5353
#![omit_gdb_pretty_printer_section]
5454

55-
static B: bool = false;
56-
static I: int = -1;
57-
static C: char = 'a';
58-
static I8: i8 = 68;
59-
static I16: i16 = -16;
60-
static I32: i32 = -32;
61-
static I64: i64 = -64;
62-
static U: uint = 1;
63-
static U8: u8 = 100;
64-
static U16: u16 = 16;
65-
static U32: u32 = 32;
66-
static U64: u64 = 64;
67-
static F32: f32 = 2.5;
68-
static F64: f64 = 3.5;
55+
// N.B. These are `mut` only so they don't constant fold away.
56+
static mut B: bool = false;
57+
static mut I: int = -1;
58+
static mut C: char = 'a';
59+
static mut I8: i8 = 68;
60+
static mut I16: i16 = -16;
61+
static mut I32: i32 = -32;
62+
static mut I64: i64 = -64;
63+
static mut U: uint = 1;
64+
static mut U8: u8 = 100;
65+
static mut U16: u16 = 16;
66+
static mut U32: u32 = 32;
67+
static mut U64: u64 = 64;
68+
static mut F32: f32 = 2.5;
69+
static mut F64: f64 = 3.5;
6970

7071
fn main() {
7172
_zzz(); // #break
7273

73-
let a = (B, I, C, I8, I16, I32, I64, U, U8, U16, U32, U64, F32, F64);
74+
let a = unsafe { (B, I, C, I8, I16, I32, I64, U, U8, U16, U32, U64, F32, F64) };
7475
}
7576

7677
fn _zzz() {()}

0 commit comments

Comments
 (0)