1 // min-llvm-version: 11.0.0
3 // ignore-debug: the debug assertions get in the way
6 // Make sure no bounds checks are emitted when slicing or indexing
7 // with an index from `position()` or `rposition()`.
9 // CHECK-LABEL: @position_slice_to_no_bounds_check
11 pub fn position_slice_to_no_bounds_check(s: &[u8]) -> &[u8] {
13 // CHECK-NOT: slice_index_len_fail
14 if let Some(idx) = s.iter().position(|b| *b == b'\\') {
21 // CHECK-LABEL: @position_slice_from_no_bounds_check
23 pub fn position_slice_from_no_bounds_check(s: &[u8]) -> &[u8] {
25 // CHECK-NOT: slice_index_len_fail
26 if let Some(idx) = s.iter().position(|b| *b == b'\\') {
33 // CHECK-LABEL: @position_index_no_bounds_check
35 pub fn position_index_no_bounds_check(s: &[u8]) -> u8 {
37 // CHECK-NOT: slice_index_len_fail
38 if let Some(idx) = s.iter().position(|b| *b == b'\\') {
44 // CHECK-LABEL: @rposition_slice_to_no_bounds_check
46 pub fn rposition_slice_to_no_bounds_check(s: &[u8]) -> &[u8] {
48 // CHECK-NOT: slice_index_len_fail
49 if let Some(idx) = s.iter().rposition(|b| *b == b'\\') {
56 // CHECK-LABEL: @rposition_slice_from_no_bounds_check
58 pub fn rposition_slice_from_no_bounds_check(s: &[u8]) -> &[u8] {
60 // CHECK-NOT: slice_index_len_fail
61 if let Some(idx) = s.iter().rposition(|b| *b == b'\\') {
68 // CHECK-LABEL: @rposition_index_no_bounds_check
70 pub fn rposition_index_no_bounds_check(s: &[u8]) -> u8 {
72 // CHECK-NOT: slice_index_len_fail
73 if let Some(idx) = s.iter().rposition(|b| *b == b'\\') {