2 // ignore-debug: the debug assertions get in the way
5 // Make sure no bounds checks are emitted when slicing or indexing
6 // with an index from `position()` or `rposition()`.
8 // CHECK-LABEL: @position_slice_to_no_bounds_check
10 pub fn position_slice_to_no_bounds_check(s: &[u8]) -> &[u8] {
12 // CHECK-NOT: slice_index_len_fail
13 if let Some(idx) = s.iter().position(|b| *b == b'\\') {
20 // CHECK-LABEL: @position_slice_from_no_bounds_check
22 pub fn position_slice_from_no_bounds_check(s: &[u8]) -> &[u8] {
24 // CHECK-NOT: slice_index_len_fail
25 if let Some(idx) = s.iter().position(|b| *b == b'\\') {
32 // CHECK-LABEL: @position_index_no_bounds_check
34 pub fn position_index_no_bounds_check(s: &[u8]) -> u8 {
36 // CHECK-NOT: slice_index_len_fail
37 if let Some(idx) = s.iter().position(|b| *b == b'\\') {
43 // CHECK-LABEL: @rposition_slice_to_no_bounds_check
45 pub fn rposition_slice_to_no_bounds_check(s: &[u8]) -> &[u8] {
47 // CHECK-NOT: slice_index_len_fail
48 if let Some(idx) = s.iter().rposition(|b| *b == b'\\') {
55 // CHECK-LABEL: @rposition_slice_from_no_bounds_check
57 pub fn rposition_slice_from_no_bounds_check(s: &[u8]) -> &[u8] {
59 // CHECK-NOT: slice_index_len_fail
60 if let Some(idx) = s.iter().rposition(|b| *b == b'\\') {
67 // CHECK-LABEL: @rposition_index_no_bounds_check
69 pub fn rposition_index_no_bounds_check(s: &[u8]) -> u8 {
71 // CHECK-NOT: slice_index_len_fail
72 if let Some(idx) = s.iter().rposition(|b| *b == b'\\') {