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.
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 #![feature(const_needs_drop)]
15 struct Trivial(u8, f32);
17 struct NonTrivial(u8, String);
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>();
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>();
31 assert!(CONST_STRING);
32 assert!(!CONST_TRIVIAL);
33 assert!(CONST_NON_TRIVIAL);
36 assert!(STATIC_STRING);
37 assert!(!STATIC_TRIVIAL);
38 assert!(STATIC_NON_TRIVIAL);