diff options
| author | bors <bors@rust-lang.org> | 2015-02-16 16:38:51 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-02-16 16:38:51 +0000 |
| commit | e4e7aa28566d062514a7a1f5534d76b9d82f524a (patch) | |
| tree | 55a2ef204f3faf8da57c84317fd2ca3e9bae80f1 /src/test/debuginfo | |
| parent | c5db290bf6df986a6acd5ce993f278c18e55ca37 (diff) | |
| parent | b49f5281c2125eec67a9c671dae3ba6fb271611a (diff) | |
| download | rust-e4e7aa28566d062514a7a1f5534d76b9d82f524a.tar.gz rust-e4e7aa28566d062514a7a1f5534d76b9d82f524a.zip | |
Auto merge of #21744 - eddyb:rvalue-promotion, r=nikomatsakis
This includes everything necessary for promoting borrows of constant rvalues to `'static`. That is, `&expr` will have the type `&'static T` if `const T: &'static T = &expr;` is valid. There is a small exception, dereferences of raw pointers, as they misbehave. They still "work" in constants as I didn't want to break legitimate uses (are there any?). The qualification done here can be expanded to allow simple CTFE via `const fn`.
Diffstat (limited to 'src/test/debuginfo')
| -rw-r--r-- | src/test/debuginfo/basic-types-globals-metadata.rs | 32 | ||||
| -rw-r--r-- | src/test/debuginfo/basic-types-globals.rs | 31 |
2 files changed, 32 insertions, 31 deletions
diff --git a/src/test/debuginfo/basic-types-globals-metadata.rs b/src/test/debuginfo/basic-types-globals-metadata.rs index e9f801c5f05..91e78c820e6 100644 --- a/src/test/debuginfo/basic-types-globals-metadata.rs +++ b/src/test/debuginfo/basic-types-globals-metadata.rs @@ -47,26 +47,26 @@ #![allow(dead_code)] #![omit_gdb_pretty_printer_section] - -static B: bool = false; -static I: int = -1; -static C: char = 'a'; -static I8: i8 = 68; -static I16: i16 = -16; -static I32: i32 = -32; -static I64: i64 = -64; -static U: uint = 1; -static U8: u8 = 100; -static U16: u16 = 16; -static U32: u32 = 32; -static U64: u64 = 64; -static F32: f32 = 2.5; -static F64: f64 = 3.5; +// N.B. These are `mut` only so they don't constant fold away. +static mut B: bool = false; +static mut I: int = -1; +static mut C: char = 'a'; +static mut I8: i8 = 68; +static mut I16: i16 = -16; +static mut I32: i32 = -32; +static mut I64: i64 = -64; +static mut U: uint = 1; +static mut U8: u8 = 100; +static mut U16: u16 = 16; +static mut U32: u32 = 32; +static mut U64: u64 = 64; +static mut F32: f32 = 2.5; +static mut F64: f64 = 3.5; fn main() { _zzz(); // #break - let a = (B, I, C, I8, I16, I32, I64, U, U8, U16, U32, U64, F32, F64); + let a = unsafe { (B, I, C, I8, I16, I32, I64, U, U8, U16, U32, U64, F32, F64) }; } fn _zzz() {()} diff --git a/src/test/debuginfo/basic-types-globals.rs b/src/test/debuginfo/basic-types-globals.rs index a4d4ddfea53..d37b0f60d3d 100644 --- a/src/test/debuginfo/basic-types-globals.rs +++ b/src/test/debuginfo/basic-types-globals.rs @@ -52,25 +52,26 @@ #![allow(unused_variables)] #![omit_gdb_pretty_printer_section] -static B: bool = false; -static I: int = -1; -static C: char = 'a'; -static I8: i8 = 68; -static I16: i16 = -16; -static I32: i32 = -32; -static I64: i64 = -64; -static U: uint = 1; -static U8: u8 = 100; -static U16: u16 = 16; -static U32: u32 = 32; -static U64: u64 = 64; -static F32: f32 = 2.5; -static F64: f64 = 3.5; +// N.B. These are `mut` only so they don't constant fold away. +static mut B: bool = false; +static mut I: int = -1; +static mut C: char = 'a'; +static mut I8: i8 = 68; +static mut I16: i16 = -16; +static mut I32: i32 = -32; +static mut I64: i64 = -64; +static mut U: uint = 1; +static mut U8: u8 = 100; +static mut U16: u16 = 16; +static mut U32: u32 = 32; +static mut U64: u64 = 64; +static mut F32: f32 = 2.5; +static mut F64: f64 = 3.5; fn main() { _zzz(); // #break - let a = (B, I, C, I8, I16, I32, I64, U, U8, U16, U32, U64, F32, F64); + let a = unsafe { (B, I, C, I8, I16, I32, I64, U, U8, U16, U32, U64, F32, F64) }; } fn _zzz() {()} |
