2018-08-30 12:18:55 +00:00
|
|
|
//@ run-pass
|
2020-03-27 20:56:19 +00:00
|
|
|
#![allow(unused_braces)]
|
2014-05-04 08:39:11 +00:00
|
|
|
#![allow(dead_code)]
|
|
|
|
#![allow(unused_unsafe)]
|
|
|
|
|
|
|
|
struct Foo {
|
2015-01-20 23:43:38 +00:00
|
|
|
a: usize,
|
2014-06-25 19:47:34 +00:00
|
|
|
b: *const ()
|
2014-05-04 08:39:11 +00:00
|
|
|
}
|
|
|
|
|
2014-12-21 23:49:42 +00:00
|
|
|
unsafe impl Sync for Foo {}
|
2014-12-06 16:39:25 +00:00
|
|
|
|
2014-05-04 08:39:11 +00:00
|
|
|
fn foo<T>(a: T) -> T {
|
|
|
|
a
|
|
|
|
}
|
|
|
|
|
2015-01-20 23:43:38 +00:00
|
|
|
static BLOCK_INTEGRAL: usize = { 1 };
|
2014-05-04 08:39:11 +00:00
|
|
|
static BLOCK_EXPLICIT_UNIT: () = { () };
|
|
|
|
static BLOCK_IMPLICIT_UNIT: () = { };
|
|
|
|
static BLOCK_FLOAT: f64 = { 1.0 };
|
2015-01-20 23:43:38 +00:00
|
|
|
static BLOCK_ENUM: Option<usize> = { Some(100) };
|
2019-06-17 10:52:37 +00:00
|
|
|
static BLOCK_STRUCT: Foo = { Foo { a: 12, b: std::ptr::null::<()>() } };
|
2015-01-20 23:43:38 +00:00
|
|
|
static BLOCK_UNSAFE: usize = unsafe { 1000 };
|
2014-05-04 08:39:11 +00:00
|
|
|
|
2015-01-20 23:43:38 +00:00
|
|
|
static BLOCK_FN_INFERRED: fn(usize) -> usize = { foo };
|
2014-05-04 08:39:11 +00:00
|
|
|
|
2015-01-20 23:43:38 +00:00
|
|
|
static BLOCK_FN: fn(usize) -> usize = { foo::<usize> };
|
2014-05-04 08:39:11 +00:00
|
|
|
|
2015-01-20 23:43:38 +00:00
|
|
|
static BLOCK_ENUM_CONSTRUCTOR: fn(usize) -> Option<usize> = { Some };
|
2014-05-04 08:39:11 +00:00
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
assert_eq!(BLOCK_INTEGRAL, 1);
|
|
|
|
assert_eq!(BLOCK_EXPLICIT_UNIT, ());
|
|
|
|
assert_eq!(BLOCK_IMPLICIT_UNIT, ());
|
|
|
|
assert_eq!(BLOCK_FLOAT, 1.0_f64);
|
|
|
|
assert_eq!(BLOCK_STRUCT.a, 12);
|
2019-06-17 10:52:37 +00:00
|
|
|
assert_eq!(BLOCK_STRUCT.b, std::ptr::null::<()>());
|
2014-05-04 08:39:11 +00:00
|
|
|
assert_eq!(BLOCK_ENUM, Some(100));
|
|
|
|
assert_eq!(BLOCK_UNSAFE, 1000);
|
2015-01-20 23:43:38 +00:00
|
|
|
assert_eq!(BLOCK_FN_INFERRED(300), 300);
|
|
|
|
assert_eq!(BLOCK_FN(300), 300);
|
|
|
|
assert_eq!(BLOCK_ENUM_CONSTRUCTOR(200), Some(200));
|
2014-05-04 08:39:11 +00:00
|
|
|
}
|