summaryrefslogtreecommitdiff
path: root/tests/ui/mir
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-04-02 12:17:52 +0000
committerbors <bors@rust-lang.org>2023-04-02 12:17:52 +0000
commita5a690cf4bcc53b8e512d51480b00c73b5eaadae (patch)
tree2124c9d547eff55e78dc89dc340b175d09290cb0 /tests/ui/mir
parent11cd4ff34db4dca57acd4782a78a5987bb153608 (diff)
parentce2d52841b30616b3258685439ab13b03520ae10 (diff)
Auto merge of #109008 - clubby789:drop-elaborate-array, r=davidtwco
Drop array patterns using subslices Fixes #109004 Drops contiguous subslices of an array when moving elements out with a pattern, which improves perf for large arrays r? `@compiler-errors`
Diffstat (limited to 'tests/ui/mir')
-rw-r--r--tests/ui/mir/issue-109004-drop-large-array.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/ui/mir/issue-109004-drop-large-array.rs b/tests/ui/mir/issue-109004-drop-large-array.rs
new file mode 100644
index 00000000000..5e3361cef6e
--- /dev/null
+++ b/tests/ui/mir/issue-109004-drop-large-array.rs
@@ -0,0 +1,16 @@
+// check-pass
+
+const SZ: usize = 64_000_000;
+type BigDrop = [String; SZ];
+
+fn f(_dropme: BigDrop) {}
+
+fn f2(_moveme: BigDrop) -> String {
+ let [a, ..] = _moveme;
+ a
+}
+
+fn main() {
+ f(std::array::from_fn(|_| String::new()));
+ f2(std::array::from_fn(|_| String::new()));
+}