Skip to content

Commit e52fbff

Browse files
authored
Rollup merge of rust-lang#111525 - scottmcm:slice-position-tweak, r=Mark-Simulacrum
Stop checking for the absence of something that doesn't exist A couple of codegen tests are doing ``` // CHECK-NOT: slice_index_len_fail ``` However, that function no longer exists: [the only places](https://github.com/search?q=repo%3Arust-lang%2Frust+slice_index_len_fail&type=code) it occurs in the repo are in those tests. So this PR updates the tests to check for the absense of the functions that are actually used today to panic for out-of-bounds indexing.
2 parents c93c298 + a9570a3 commit e52fbff

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

tests/codegen/binary-search-index-no-bound-check.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
#[no_mangle]
1010
pub fn binary_search_index_no_bounds_check(s: &[u8]) -> u8 {
1111
// CHECK-NOT: panic
12-
// CHECK-NOT: slice_index_len_fail
12+
// CHECK-NOT: slice_start_index_len_fail
13+
// CHECK-NOT: slice_end_index_len_fail
14+
// CHECK-NOT: panic_bounds_check
1315
if let Ok(idx) = s.binary_search(&b'\\') {
1416
s[idx]
1517
} else {

tests/codegen/issues/issue-73396-bounds-check-after-position.rs

+24-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
#[no_mangle]
1010
pub fn position_slice_to_no_bounds_check(s: &[u8]) -> &[u8] {
1111
// CHECK-NOT: panic
12-
// CHECK-NOT: slice_index_len_fail
12+
// CHECK-NOT: slice_start_index_len_fail
13+
// CHECK-NOT: slice_end_index_len_fail
14+
// CHECK-NOT: panic_bounds_check
15+
// CHECK-NOT: unreachable
1316
if let Some(idx) = s.iter().position(|b| *b == b'\\') {
1417
&s[..idx]
1518
} else {
@@ -21,7 +24,10 @@ pub fn position_slice_to_no_bounds_check(s: &[u8]) -> &[u8] {
2124
#[no_mangle]
2225
pub fn position_slice_from_no_bounds_check(s: &[u8]) -> &[u8] {
2326
// CHECK-NOT: panic
24-
// CHECK-NOT: slice_index_len_fail
27+
// CHECK-NOT: slice_start_index_len_fail
28+
// CHECK-NOT: slice_end_index_len_fail
29+
// CHECK-NOT: panic_bounds_check
30+
// CHECK-NOT: unreachable
2531
if let Some(idx) = s.iter().position(|b| *b == b'\\') {
2632
&s[idx..]
2733
} else {
@@ -33,7 +39,10 @@ pub fn position_slice_from_no_bounds_check(s: &[u8]) -> &[u8] {
3339
#[no_mangle]
3440
pub fn position_index_no_bounds_check(s: &[u8]) -> u8 {
3541
// CHECK-NOT: panic
36-
// CHECK-NOT: slice_index_len_fail
42+
// CHECK-NOT: slice_start_index_len_fail
43+
// CHECK-NOT: slice_end_index_len_fail
44+
// CHECK-NOT: panic_bounds_check
45+
// CHECK-NOT: unreachable
3746
if let Some(idx) = s.iter().position(|b| *b == b'\\') {
3847
s[idx]
3948
} else {
@@ -44,7 +53,10 @@ pub fn position_index_no_bounds_check(s: &[u8]) -> u8 {
4453
#[no_mangle]
4554
pub fn rposition_slice_to_no_bounds_check(s: &[u8]) -> &[u8] {
4655
// CHECK-NOT: panic
47-
// CHECK-NOT: slice_index_len_fail
56+
// CHECK-NOT: slice_start_index_len_fail
57+
// CHECK-NOT: slice_end_index_len_fail
58+
// CHECK-NOT: panic_bounds_check
59+
// CHECK-NOT: unreachable
4860
if let Some(idx) = s.iter().rposition(|b| *b == b'\\') {
4961
&s[..idx]
5062
} else {
@@ -56,7 +68,10 @@ pub fn rposition_slice_to_no_bounds_check(s: &[u8]) -> &[u8] {
5668
#[no_mangle]
5769
pub fn rposition_slice_from_no_bounds_check(s: &[u8]) -> &[u8] {
5870
// CHECK-NOT: panic
59-
// CHECK-NOT: slice_index_len_fail
71+
// CHECK-NOT: slice_start_index_len_fail
72+
// CHECK-NOT: slice_end_index_len_fail
73+
// CHECK-NOT: panic_bounds_check
74+
// CHECK-NOT: unreachable
6075
if let Some(idx) = s.iter().rposition(|b| *b == b'\\') {
6176
&s[idx..]
6277
} else {
@@ -68,7 +83,10 @@ pub fn rposition_slice_from_no_bounds_check(s: &[u8]) -> &[u8] {
6883
#[no_mangle]
6984
pub fn rposition_index_no_bounds_check(s: &[u8]) -> u8 {
7085
// CHECK-NOT: panic
71-
// CHECK-NOT: slice_index_len_fail
86+
// CHECK-NOT: slice_start_index_len_fail
87+
// CHECK-NOT: slice_end_index_len_fail
88+
// CHECK-NOT: panic_bounds_check
89+
// CHECK-NOT: unreachable
7290
if let Some(idx) = s.iter().rposition(|b| *b == b'\\') {
7391
s[idx]
7492
} else {

0 commit comments

Comments
 (0)