1 // Copyright 2015 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.
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.
11 // Checks that functional-record-update order-of-eval is as expected
12 // even when no Drop-implementations are involved.
14 use std::sync::atomic::{Ordering, AtomicUsize, ATOMIC_USIZE_INIT};
16 struct W { wrapped: u32 }
17 struct S { f0: W, _f1: i32 }
20 const VAL: u32 = 0x89AB_CDEF;
21 let w = W { wrapped: VAL };
23 f0: { event(0x01); W { wrapped: w.wrapped + 1 } },
25 f0: { event(0x02); w},
29 assert_eq!(s.f0.wrapped, VAL + 1);
30 let actual = event_log();
32 assert!(expect == actual,
33 "expect: 0x{:x} actual: 0x{:x}", expect, actual);
36 static LOG: AtomicUsize = ATOMIC_USIZE_INIT;
38 fn event_log() -> usize {
39 LOG.load(Ordering::SeqCst)
43 let old_log = LOG.load(Ordering::SeqCst);
44 let new_log = (old_log << 8) + tag as usize;
45 LOG.store(new_log, Ordering::SeqCst);