2023-10-16 12:36:39 -05:00
|
|
|
// skip-filecheck
|
2023-04-25 23:14:33 -05:00
|
|
|
// compile-flags: -O -C debuginfo=0 -Zmir-opt-level=2
|
|
|
|
// only-64bit
|
2023-08-24 06:46:37 -05:00
|
|
|
// ignore-debug the standard library debug assertions leak into this test
|
2023-06-08 02:18:34 -05:00
|
|
|
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
|
2023-04-25 23:14:33 -05:00
|
|
|
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
|
|
|
|
use std::ops::Range;
|
|
|
|
|
|
|
|
// EMIT_MIR slice_index.slice_index_usize.PreCodegen.after.mir
|
|
|
|
pub fn slice_index_usize(slice: &[u32], index: usize) -> u32 {
|
|
|
|
slice[index]
|
|
|
|
}
|
|
|
|
|
|
|
|
// EMIT_MIR slice_index.slice_get_mut_usize.PreCodegen.after.mir
|
|
|
|
pub fn slice_get_mut_usize(slice: &mut [u32], index: usize) -> Option<&mut u32> {
|
|
|
|
slice.get_mut(index)
|
|
|
|
}
|
|
|
|
|
|
|
|
// EMIT_MIR slice_index.slice_index_range.PreCodegen.after.mir
|
|
|
|
pub fn slice_index_range(slice: &[u32], index: Range<usize>) -> &[u32] {
|
|
|
|
&slice[index]
|
|
|
|
}
|
|
|
|
|
|
|
|
// EMIT_MIR slice_index.slice_get_unchecked_mut_range.PreCodegen.after.mir
|
|
|
|
pub unsafe fn slice_get_unchecked_mut_range(slice: &mut [u32], index: Range<usize>) -> &mut [u32] {
|
|
|
|
slice.get_unchecked_mut(index)
|
|
|
|
}
|