]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/const-block-item.rs
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / src / test / run-pass / const-block-item.rs
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
12 mod foo {
13 pub trait Value {
14 fn value(&self) -> usize;
15 }
16 }
17
18 static BLOCK_USE: usize = {
19 use foo::Value;
20 100
21 };
22
23 static BLOCK_STRUCT_DEF: usize = {
24 struct Foo {
25 a: usize
26 }
27 Foo{ a: 300 }.a
28 };
29
30 static BLOCK_FN_DEF: fn(usize) -> usize = {
31 fn foo(a: usize) -> usize {
32 a + 10
33 }
34 foo
35 };
36
37 static BLOCK_MACRO_RULES: usize = {
38 macro_rules! baz {
39 () => (412)
40 }
41 baz!()
42 };
43
44 pub fn main() {
45 assert_eq!(BLOCK_USE, 100);
46 assert_eq!(BLOCK_STRUCT_DEF, 300);
47 assert_eq!(BLOCK_FN_DEF(390), 400);
48 assert_eq!(BLOCK_MACRO_RULES, 412);
49 }