Skip to content

Commit c0559d4

Browse files
committed
Add unmarked test
This adds a codegen test which once annotated can check that the optimization is applied in the case expected. I'm not sure how to annotate it, though, so I've left it unmarked.
1 parent f8141a8 commit c0559d4

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

library/core/src/array/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ impl<T, const N: usize> [T; N] {
479479
// ManuallyDrop::new(..), and implicitly know that it will be a `dst` variant
480480
// from where
481481
unsafe {
482-
let v = f(src_dst[i].src.read());
482+
let v = f(src_dst[i].src.assume_init_read());
483483
src_dst[i].dst = ManuallyDrop::new(v);
484484
}
485485
guard.initialized += 1;

src/test/codegen/array-map.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// compile-flags: -O
2+
3+
#![crate_type = "lib"]
4+
#![feature(array_map)]
5+
6+
// CHECK-LABEL: @array_inc
7+
// CHECK-NOT: alloca
8+
#[no_mangle]
9+
pub fn array_inc(x: [u8; 1000]) -> [u8; 1000] {
10+
x.map(|v| v + 1)
11+
}
12+
13+
// CHECK-LABEL: @array_inc_cast
14+
// CHECK: alloca
15+
#[no_mangle]
16+
pub fn array_inc_cast(x: [u8; 1000]) -> [u16; 1000] {
17+
x.map(|v| v as u16 + 1)
18+
}

0 commit comments

Comments
 (0)