From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/consts/const-needs_drop.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/ui/consts/const-needs_drop.rs (limited to 'tests/ui/consts/const-needs_drop.rs') diff --git a/tests/ui/consts/const-needs_drop.rs b/tests/ui/consts/const-needs_drop.rs new file mode 100644 index 000000000..11ee7084c --- /dev/null +++ b/tests/ui/consts/const-needs_drop.rs @@ -0,0 +1,31 @@ +// run-pass + +use std::mem; + +#[allow(unused_tuple_struct_fields)] +struct Trivial(u8, f32); + +#[allow(unused_tuple_struct_fields)] +struct NonTrivial(u8, String); + +const CONST_U8: bool = mem::needs_drop::(); +const CONST_STRING: bool = mem::needs_drop::(); +const CONST_TRIVIAL: bool = mem::needs_drop::(); +const CONST_NON_TRIVIAL: bool = mem::needs_drop::(); + +static STATIC_U8: bool = mem::needs_drop::(); +static STATIC_STRING: bool = mem::needs_drop::(); +static STATIC_TRIVIAL: bool = mem::needs_drop::(); +static STATIC_NON_TRIVIAL: bool = mem::needs_drop::(); + +fn main() { + assert!(!CONST_U8); + assert!(CONST_STRING); + assert!(!CONST_TRIVIAL); + assert!(CONST_NON_TRIVIAL); + + assert!(!STATIC_U8); + assert!(STATIC_STRING); + assert!(!STATIC_TRIVIAL); + assert!(STATIC_NON_TRIVIAL); +} -- cgit v1.2.3