|
| 1 | +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT |
| 2 | +// file at the top-level directory of this distribution and at |
| 3 | +// http://rust-lang.org/COPYRIGHT. |
| 4 | +// |
| 5 | +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 6 | +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 7 | +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 8 | +// option. This file may not be copied, modified, or distributed |
| 9 | +// except according to those terms. |
| 10 | + |
| 11 | +#![allow(dead_code)] |
| 12 | +#![allow(unused_unsafe)] |
| 13 | + |
| 14 | +struct Foo { |
| 15 | + a: uint, |
| 16 | + b: *() |
| 17 | +} |
| 18 | + |
| 19 | +fn foo<T>(a: T) -> T { |
| 20 | + a |
| 21 | +} |
| 22 | + |
| 23 | +static BLOCK_INTEGRAL: uint = { 1 }; |
| 24 | +static BLOCK_EXPLICIT_UNIT: () = { () }; |
| 25 | +static BLOCK_IMPLICIT_UNIT: () = { }; |
| 26 | +static BLOCK_FLOAT: f64 = { 1.0 }; |
| 27 | +static BLOCK_ENUM: Option<uint> = { Some(100) }; |
| 28 | +static BLOCK_STRUCT: Foo = { Foo { a: 12, b: 0 as *() } }; |
| 29 | +static BLOCK_UNSAFE: uint = unsafe { 1000 }; |
| 30 | + |
| 31 | +// FIXME: #13970 |
| 32 | +// static BLOCK_FN_INFERRED: fn(uint) -> uint = { foo }; |
| 33 | + |
| 34 | +// FIXME: #13971 |
| 35 | +// static BLOCK_FN: fn(uint) -> uint = { foo::<uint> }; |
| 36 | + |
| 37 | +// FIXME: #13972 |
| 38 | +// static BLOCK_ENUM_CONSTRUCTOR: fn(uint) -> Option<uint> = { Some }; |
| 39 | + |
| 40 | +// FIXME: #13973 |
| 41 | +// static BLOCK_UNSAFE_SAFE_PTR: &'static int = unsafe { &*(0xdeadbeef as *int) }; |
| 42 | +// static BLOCK_UNSAFE_SAFE_PTR_2: &'static int = unsafe { |
| 43 | +// static X: *int = 0xdeadbeef as *int; |
| 44 | +// &*X |
| 45 | +// }; |
| 46 | + |
| 47 | +pub fn main() { |
| 48 | + assert_eq!(BLOCK_INTEGRAL, 1); |
| 49 | + assert_eq!(BLOCK_EXPLICIT_UNIT, ()); |
| 50 | + assert_eq!(BLOCK_IMPLICIT_UNIT, ()); |
| 51 | + assert_eq!(BLOCK_FLOAT, 1.0_f64); |
| 52 | + assert_eq!(BLOCK_STRUCT.a, 12); |
| 53 | + assert_eq!(BLOCK_STRUCT.b, 0 as *()); |
| 54 | + assert_eq!(BLOCK_ENUM, Some(100)); |
| 55 | + assert_eq!(BLOCK_UNSAFE, 1000); |
| 56 | + |
| 57 | + // FIXME: #13970 |
| 58 | + // assert_eq!(BLOCK_FN_INFERRED(300), 300); |
| 59 | + |
| 60 | + // FIXME: #13971 |
| 61 | + // assert_eq!(BLOCK_FN(300), 300); |
| 62 | + |
| 63 | + // FIXME: #13972 |
| 64 | + // assert_eq!(BLOCK_ENUM_CONSTRUCTOR(200), Some(200)); |
| 65 | + |
| 66 | + // FIXME: #13973 |
| 67 | + // assert_eq!(BLOCK_UNSAFE_SAFE_PTR as *int as uint, 0xdeadbeef_u); |
| 68 | + // assert_eq!(BLOCK_UNSAFE_SAFE_PTR_2 as *int as uint, 0xdeadbeef_u); |
| 69 | +} |
0 commit comments