]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/issue-27997.rs
rustdoc: pretty-print Unevaluated expressions in types.
[rust.git] / src / test / run-pass / issue-27997.rs
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.
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 #![feature(const_fn)]
12
13 use std::sync::atomic::{Ordering, AtomicUsize};
14
15 use std::mem;
16 struct S<U,V> {
17     _u: U,
18     size_of_u: usize,
19     _v: V,
20     size_of_v: usize
21 }
22
23 impl<U, V> S<U, V> {
24     fn new(u: U, v: V) -> Self {
25         S {
26             _u: u,
27             size_of_u: mem::size_of::<U>(),
28             _v: v,
29             size_of_v: mem::size_of::<V>()
30         }
31     }
32 }
33
34 static COUNT: AtomicUsize = AtomicUsize::new(0);
35
36 impl<V, U> Drop for S<U, V> {
37     fn drop(&mut self) {
38         assert_eq!(mem::size_of::<U>(), self.size_of_u);
39         assert_eq!(mem::size_of::<V>(), self.size_of_v);
40         COUNT.store(COUNT.load(Ordering::SeqCst)+1, Ordering::SeqCst);
41     }
42 }
43
44 fn main() {
45     assert_eq!(COUNT.load(Ordering::SeqCst), 0);
46     { S::new(0u8, 1u16); }
47     assert_eq!(COUNT.load(Ordering::SeqCst), 1);
48 }