diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
commit | 64d98f8ee037282c35007b64c2649055c56af1db (patch) | |
tree | 5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_no_migrations.rs | |
parent | Adding debian version 1.67.1+dfsg1-1. (diff) | |
download | rustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_no_migrations.rs')
-rw-r--r-- | tests/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_no_migrations.rs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_no_migrations.rs b/tests/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_no_migrations.rs new file mode 100644 index 000000000..3f184a67f --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_no_migrations.rs @@ -0,0 +1,45 @@ +// run-pass + +#![deny(rust_2021_incompatible_closure_captures)] +#![feature(rustc_attrs)] +#![allow(unused)] +#[rustc_insignificant_dtor] + +struct InsignificantDropPoint { + x: i32, + y: i32, +} + +impl Drop for InsignificantDropPoint { + fn drop(&mut self) {} +} + +struct GenericStruct<T>(T, T); + +// No drop reordering is required as the elements of `t` implement insignificant drop +fn insignificant_drop_does_not_need_migration() { + let t = (InsignificantDropPoint { x: 4, y: 9 }, InsignificantDropPoint { x: 4, y: 9 }); + + let c = || { + let _t = t.0; + }; + + c(); +} + +// Generic struct whose elements don't have significant drops don't need drop reordering +fn generic_struct_with_insignificant_drop_does_not_need_migration() { + let t = + GenericStruct(InsignificantDropPoint { x: 4, y: 9 }, InsignificantDropPoint { x: 4, y: 9 }); + + let c = || { + let _t = t.0; + }; + + c(); +} + +fn main() { + insignificant_drop_does_not_need_migration(); + generic_struct_with_insignificant_drop_does_not_need_migration(); +} |