From 64d98f8ee037282c35007b64c2649055c56af1db Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:03 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/static/static-drop-scope.rs | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/ui/static/static-drop-scope.rs (limited to 'tests/ui/static/static-drop-scope.rs') diff --git a/tests/ui/static/static-drop-scope.rs b/tests/ui/static/static-drop-scope.rs new file mode 100644 index 000000000..34afa9873 --- /dev/null +++ b/tests/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 destructor of +//~| ERROR temporary value dropped while borrowed + +const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor); +//~^ ERROR destructor of +//~| ERROR temporary value dropped while borrowed + +static EARLY_DROP_S: i32 = (WithDtor, 0).1; +//~^ ERROR destructor of + +const EARLY_DROP_C: i32 = (WithDtor, 0).1; +//~^ ERROR destructor of + +const fn const_drop(_: T) {} +//~^ ERROR destructor of + +const fn const_drop2(x: T) { + (x, ()).1 + //~^ ERROR destructor of +} + +const EARLY_DROP_C_OPTION: i32 = (Some(WithDtor), 0).1; +//~^ ERROR destructor of + +const HELPER: Option = Some(WithDtor); + +const EARLY_DROP_C_OPTION_CONSTANT: i32 = (HELPER, 0).1; +//~^ ERROR destructor of + +fn main () {} -- cgit v1.2.3