2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2018-09-25 16:51:35 -05:00
|
|
|
#![allow(unused_imports)]
|
2015-03-22 15:13:15 -05:00
|
|
|
|
2014-05-04 03:39:11 -05:00
|
|
|
mod foo {
|
|
|
|
pub trait Value {
|
2015-03-25 19:06:52 -05:00
|
|
|
fn value(&self) -> usize;
|
2014-05-04 03:39:11 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
static BLOCK_USE: usize = {
|
2014-05-04 03:39:11 -05:00
|
|
|
use foo::Value;
|
|
|
|
100
|
|
|
|
};
|
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
static BLOCK_STRUCT_DEF: usize = {
|
2014-05-04 03:39:11 -05:00
|
|
|
struct Foo {
|
2015-03-25 19:06:52 -05:00
|
|
|
a: usize
|
2014-05-04 03:39:11 -05:00
|
|
|
}
|
|
|
|
Foo{ a: 300 }.a
|
|
|
|
};
|
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
static BLOCK_FN_DEF: fn(usize) -> usize = {
|
|
|
|
fn foo(a: usize) -> usize {
|
2014-05-04 03:39:11 -05:00
|
|
|
a + 10
|
|
|
|
}
|
|
|
|
foo
|
|
|
|
};
|
|
|
|
|
2015-03-25 19:06:52 -05:00
|
|
|
static BLOCK_MACRO_RULES: usize = {
|
2014-05-04 03:39:11 -05:00
|
|
|
macro_rules! baz {
|
|
|
|
() => (412)
|
|
|
|
}
|
|
|
|
baz!()
|
|
|
|
};
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
assert_eq!(BLOCK_USE, 100);
|
|
|
|
assert_eq!(BLOCK_STRUCT_DEF, 300);
|
|
|
|
assert_eq!(BLOCK_FN_DEF(390), 400);
|
|
|
|
assert_eq!(BLOCK_MACRO_RULES, 412);
|
|
|
|
}
|