From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/static/static-drop-scope.rs | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/test/ui/static/static-drop-scope.rs (limited to 'src/test/ui/static/static-drop-scope.rs') diff --git a/src/test/ui/static/static-drop-scope.rs b/src/test/ui/static/static-drop-scope.rs new file mode 100644 index 000000000..e7ea8663d --- /dev/null +++ b/src/test/ui/static/static-drop-scope.rs @@ -0,0 +1,37 @@ +struct WithDtor; + +impl Drop for WithDtor { + fn drop(&mut self) {} +} + +static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor); +//~^ ERROR destructors cannot be evaluated at compile-time +//~| ERROR temporary value dropped while borrowed + +const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor); +//~^ ERROR destructors cannot be evaluated at compile-time +//~| ERROR temporary value dropped while borrowed + +static EARLY_DROP_S: i32 = (WithDtor, 0).1; +//~^ ERROR destructors cannot be evaluated at compile-time + +const EARLY_DROP_C: i32 = (WithDtor, 0).1; +//~^ ERROR destructors cannot be evaluated at compile-time + +const fn const_drop(_: T) {} +//~^ ERROR destructors cannot be evaluated at compile-time + +const fn const_drop2(x: T) { + (x, ()).1 + //~^ ERROR destructors cannot be evaluated at compile-time +} + +const EARLY_DROP_C_OPTION: i32 = (Some(WithDtor), 0).1; +//~^ ERROR destructors cannot be evaluated at compile-time + +const HELPER: Option = Some(WithDtor); + +const EARLY_DROP_C_OPTION_CONSTANT: i32 = (HELPER, 0).1; +//~^ ERROR destructors cannot be evaluated at compile-time + +fn main () {} -- cgit v1.2.3