]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/const-needs_drop.rs
Gate const core::mem::needs_drop behind const_needs_drop
[rust.git] / src / test / run-pass / const-needs_drop.rs
1 // Copyright 2018 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_needs_drop)]
12
13 use std::mem;
14
15 struct Trivial(u8, f32);
16
17 struct NonTrivial(u8, String);
18
19 const CONST_U8: bool = mem::needs_drop::<u8>();
20 const CONST_STRING: bool = mem::needs_drop::<String>();
21 const CONST_TRIVIAL: bool = mem::needs_drop::<Trivial>();
22 const CONST_NON_TRIVIAL: bool = mem::needs_drop::<NonTrivial>();
23
24 static STATIC_U8: bool = mem::needs_drop::<u8>();
25 static STATIC_STRING: bool = mem::needs_drop::<String>();
26 static STATIC_TRIVIAL: bool = mem::needs_drop::<Trivial>();
27 static STATIC_NON_TRIVIAL: bool = mem::needs_drop::<NonTrivial>();
28
29 fn main() {
30     assert!(!CONST_U8);
31     assert!(CONST_STRING);
32     assert!(!CONST_TRIVIAL);
33     assert!(CONST_NON_TRIVIAL);
34
35     assert!(!STATIC_U8);
36     assert!(STATIC_STRING);
37     assert!(!STATIC_TRIVIAL);
38     assert!(STATIC_NON_TRIVIAL);
39 }