Skip to content

Commit d5b98a7

Browse files
authored
Rollup merge of #75910 - bugadani:testcase, r=oli-obk
Add test for issue #27130 #27130 seems to be fixed by the llvm 11 update. The issue is marked with needs-test, so here it is. As some historical context, the generated code was fine until 1.38, and remained unoptimized from 1.38 up until the current nightly. I've also added a pattern matching version that was fine on 1.45.2.
2 parents fe43918 + 046556e commit d5b98a7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/test/codegen/issue-27130.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// compile-flags: -O
2+
// min-llvm-version: 11.0
3+
4+
#![crate_type = "lib"]
5+
6+
// CHECK-LABEL: @trim_in_place
7+
#[no_mangle]
8+
pub fn trim_in_place(a: &mut &[u8]) {
9+
while a.first() == Some(&42) {
10+
// CHECK-NOT: slice_index_order_fail
11+
*a = &a[1..];
12+
}
13+
}
14+
15+
// CHECK-LABEL: @trim_in_place2
16+
#[no_mangle]
17+
pub fn trim_in_place2(a: &mut &[u8]) {
18+
while let Some(&42) = a.first() {
19+
// CHECK-NOT: slice_index_order_fail
20+
*a = &a[2..];
21+
}
22+
}

0 commit comments

Comments
 (0)