We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2f0ad2a commit 80faf20Copy full SHA for 80faf20
tests/codegen/box-default-debug-copies.rs
@@ -0,0 +1,25 @@
1
+//@ compile-flags: -Copt-level=0
2
+
3
+// Test to make sure that `<Box<T>>::default` does not create too many copies of `T` on the stack.
4
+// in debug mode. This regressed in dd0620b86721ae8cae86736443acd3f72ba6fc32 to
5
+// four `T` allocas.
6
+//
7
+// See https://github.com/rust-lang/rust/issues/136043 for more context.
8
9
+#![crate_type = "lib"]
10
11
+#[allow(dead_code)]
12
+pub struct Thing([u8; 1000000]);
13
14
+impl Default for Thing {
15
+ fn default() -> Self {
16
+ Thing([0; 1000000])
17
+ }
18
+}
19
20
+// CHECK-COUNT-4: %{{.*}} = alloca {{.*}}1000000
21
+// CHECK-NOT: %{{.*}} = alloca {{.*}}1000000
22
+#[no_mangle]
23
+pub fn box_default_single_copy() -> Box<Thing> {
24
+ Box::default()
25
0 commit comments