summaryrefslogtreecommitdiffstats
path: root/tests/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_no_migrations.rs
diff options
context:
space:
mode:
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.rs45
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();
+}