]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/issue-17718.rs
Imported Upstream version 1.0.0~beta
[rustc.git] / src / test / run-pass / issue-17718.rs
CommitLineData
1a4d82fc
JJ
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// aux-build:issue-17718.rs
12
c34b1796
AL
13// pretty-expanded FIXME #23616
14
15#![feature(core)]
16
17extern crate issue_17718 as other;
1a4d82fc 18
85aaf69f 19use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
1a4d82fc 20
c34b1796 21const C1: usize = 1;
85aaf69f 22const C2: AtomicUsize = ATOMIC_USIZE_INIT;
1a4d82fc 23const C3: fn() = foo;
c34b1796
AL
24const C4: usize = C1 * C1 + C1 / C1;
25const C5: &'static usize = &C4;
26const C6: usize = {
27 const C: usize = 3;
1a4d82fc
JJ
28 C
29};
30
c34b1796 31static S1: usize = 3;
85aaf69f 32static S2: AtomicUsize = ATOMIC_USIZE_INIT;
1a4d82fc
JJ
33
34mod test {
c34b1796
AL
35 static A: usize = 4;
36 static B: &'static usize = &A;
37 static C: &'static usize = &(A);
1a4d82fc
JJ
38}
39
40fn foo() {}
41
42fn main() {
43 assert_eq!(C1, 1);
44 assert_eq!(C3(), ());
45 assert_eq!(C2.fetch_add(1, Ordering::SeqCst), 0);
46 assert_eq!(C2.fetch_add(1, Ordering::SeqCst), 0);
47 assert_eq!(C4, 2);
48 assert_eq!(*C5, 2);
49 assert_eq!(C6, 3);
50 assert_eq!(S1, 3);
51 assert_eq!(S2.fetch_add(1, Ordering::SeqCst), 0);
52 assert_eq!(S2.fetch_add(1, Ordering::SeqCst), 1);
53
54 match 1 {
55 C1 => {}
56 _ => unreachable!(),
57 }
58
59 let _a = C1;
60 let _a = C2;
61 let _a = C3;
62 let _a = C4;
63 let _a = C5;
64 let _a = C6;
65 let _a = S1;
66
67 assert_eq!(other::C1, 1);
68 assert_eq!(other::C3(), ());
69 assert_eq!(other::C2.fetch_add(1, Ordering::SeqCst), 0);
70 assert_eq!(other::C2.fetch_add(1, Ordering::SeqCst), 0);
71 assert_eq!(other::C4, 2);
72 assert_eq!(*other::C5, 2);
73 assert_eq!(other::S1, 3);
74 assert_eq!(other::S2.fetch_add(1, Ordering::SeqCst), 0);
75 assert_eq!(other::S2.fetch_add(1, Ordering::SeqCst), 1);
76
77 let _a = other::C1;
78 let _a = other::C2;
79 let _a = other::C3;
80 let _a = other::C4;
81 let _a = other::C5;
82
83 match 1 {
84 other::C1 => {}
85 _ => unreachable!(),
86 }
87}