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/compile-fail/check-static-values-constraints.rs | |
| 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/compile-fail/check-static-values-constraints.rs')
| -rw-r--r-- | src/test/compile-fail/check-static-values-constraints.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/test/compile-fail/check-static-values-constraints.rs b/src/test/compile-fail/check-static-values-constraints.rs index 7c4f9ada2d3..0180bccbca4 100644 --- a/src/test/compile-fail/check-static-values-constraints.rs +++ b/src/test/compile-fail/check-static-values-constraints.rs @@ -99,7 +99,7 @@ static STATIC10: UnsafeStruct = UnsafeStruct; struct MyOwned; static STATIC11: Box<MyOwned> = box MyOwned; -//~^ ERROR statics are not allowed to have custom pointers +//~^ ERROR allocations are not allowed in statics // The following examples test that mutable structs are just forbidden // to have types with destructors @@ -117,16 +117,17 @@ static mut STATIC14: SafeStruct = SafeStruct { //~^ ERROR mutable statics are not allowed to have destructors field1: SafeEnum::Variant1, field2: SafeEnum::Variant4("str".to_string()) +//~^ ERROR static contains unimplemented expression type }; static STATIC15: &'static [Box<MyOwned>] = &[ - box MyOwned, //~ ERROR statics are not allowed to have custom pointers - box MyOwned, //~ ERROR statics are not allowed to have custom pointers + box MyOwned, //~ ERROR allocations are not allowed in statics + box MyOwned, //~ ERROR allocations are not allowed in statics ]; static STATIC16: (&'static Box<MyOwned>, &'static Box<MyOwned>) = ( - &box MyOwned, //~ ERROR statics are not allowed to have custom pointers - &box MyOwned, //~ ERROR statics are not allowed to have custom pointers + &box MyOwned, //~ ERROR allocations are not allowed in statics + &box MyOwned, //~ ERROR allocations are not allowed in statics ); static mut STATIC17: SafeEnum = SafeEnum::Variant1; @@ -134,9 +135,9 @@ static mut STATIC17: SafeEnum = SafeEnum::Variant1; static STATIC19: Box<isize> = box 3; -//~^ ERROR statics are not allowed to have custom pointers +//~^ ERROR allocations are not allowed in statics pub fn main() { let y = { static x: Box<isize> = box 3; x }; - //~^ ERROR statics are not allowed to have custom pointers + //~^ ERROR allocations are not allowed in statics } |
