2018-08-30 12:18:55 +00:00
|
|
|
//@ run-pass
|
2018-09-25 21:51:35 +00:00
|
|
|
#![allow(dead_code)]
|
2016-02-15 20:41:16 +00:00
|
|
|
//@ aux-build:issue-17718-aux.rs
|
2014-10-07 04:16:35 +00:00
|
|
|
|
2016-02-15 20:41:16 +00:00
|
|
|
extern crate issue_17718_aux as other;
|
2014-10-07 04:16:35 +00:00
|
|
|
|
2015-05-27 08:18:36 +00:00
|
|
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
2014-10-07 04:16:35 +00:00
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
const C1: usize = 1;
|
2015-05-27 08:18:36 +00:00
|
|
|
const C2: AtomicUsize = AtomicUsize::new(0);
|
2014-10-07 04:16:35 +00:00
|
|
|
const C3: fn() = foo;
|
2015-03-26 00:06:52 +00:00
|
|
|
const C4: usize = C1 * C1 + C1 / C1;
|
|
|
|
const C5: &'static usize = &C4;
|
|
|
|
const C6: usize = {
|
|
|
|
const C: usize = 3;
|
2014-10-07 04:16:35 +00:00
|
|
|
C
|
|
|
|
};
|
|
|
|
|
2015-03-26 00:06:52 +00:00
|
|
|
static S1: usize = 3;
|
2015-05-27 08:18:36 +00:00
|
|
|
static S2: AtomicUsize = AtomicUsize::new(0);
|
2014-10-07 04:16:35 +00:00
|
|
|
|
|
|
|
mod test {
|
2015-03-26 00:06:52 +00:00
|
|
|
static A: usize = 4;
|
|
|
|
static B: &'static usize = &A;
|
|
|
|
static C: &'static usize = &(A);
|
2014-10-07 04:16:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn foo() {}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
assert_eq!(C1, 1);
|
|
|
|
assert_eq!(C3(), ());
|
2015-01-02 07:53:35 +00:00
|
|
|
assert_eq!(C2.fetch_add(1, Ordering::SeqCst), 0);
|
|
|
|
assert_eq!(C2.fetch_add(1, Ordering::SeqCst), 0);
|
2014-10-07 04:16:35 +00:00
|
|
|
assert_eq!(C4, 2);
|
|
|
|
assert_eq!(*C5, 2);
|
|
|
|
assert_eq!(C6, 3);
|
|
|
|
assert_eq!(S1, 3);
|
2015-01-02 07:53:35 +00:00
|
|
|
assert_eq!(S2.fetch_add(1, Ordering::SeqCst), 0);
|
|
|
|
assert_eq!(S2.fetch_add(1, Ordering::SeqCst), 1);
|
2014-10-07 04:16:35 +00:00
|
|
|
|
|
|
|
match 1 {
|
|
|
|
C1 => {}
|
|
|
|
_ => unreachable!(),
|
|
|
|
}
|
|
|
|
|
|
|
|
let _a = C1;
|
|
|
|
let _a = C2;
|
|
|
|
let _a = C3;
|
|
|
|
let _a = C4;
|
|
|
|
let _a = C5;
|
|
|
|
let _a = C6;
|
|
|
|
let _a = S1;
|
|
|
|
|
|
|
|
assert_eq!(other::C1, 1);
|
|
|
|
assert_eq!(other::C3(), ());
|
2015-01-02 07:53:35 +00:00
|
|
|
assert_eq!(other::C2.fetch_add(1, Ordering::SeqCst), 0);
|
|
|
|
assert_eq!(other::C2.fetch_add(1, Ordering::SeqCst), 0);
|
2014-10-07 04:16:35 +00:00
|
|
|
assert_eq!(other::C4, 2);
|
|
|
|
assert_eq!(*other::C5, 2);
|
|
|
|
assert_eq!(other::S1, 3);
|
2015-01-02 07:53:35 +00:00
|
|
|
assert_eq!(other::S2.fetch_add(1, Ordering::SeqCst), 0);
|
|
|
|
assert_eq!(other::S2.fetch_add(1, Ordering::SeqCst), 1);
|
2014-10-07 04:16:35 +00:00
|
|
|
|
|
|
|
let _a = other::C1;
|
|
|
|
let _a = other::C2;
|
|
|
|
let _a = other::C3;
|
|
|
|
let _a = other::C4;
|
|
|
|
let _a = other::C5;
|
|
|
|
|
|
|
|
match 1 {
|
|
|
|
other::C1 => {}
|
|
|
|
_ => unreachable!(),
|
|
|
|
}
|
|
|
|
}
|