Add write_bytes and ctlz intrinsics

This commit is contained in:
hkalbasi 2023-07-12 01:14:49 +03:30
parent 59420afa46
commit 274e8301c1
6 changed files with 93 additions and 13 deletions

View file

@ -1724,6 +1724,18 @@ fn function_pointer() {
"#,
5,
);
check_number(
r#"
fn add2(x: u8) -> u8 {
x + 2
}
const GOAL: u8 = {
let plus2 = add2 as fn(u8) -> u8;
plus2(3)
};
"#,
5,
);
check_number(
r#"
//- minicore: coerce_unsized, index, slice

View file

@ -510,6 +510,24 @@ fn copy_nonoverlapping() {
);
}
#[test]
fn write_bytes() {
check_number(
r#"
extern "rust-intrinsic" {
fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
}
const GOAL: i32 = unsafe {
let mut x = 2;
write_bytes(&mut x, 5, 1);
x
};
"#,
0x05050505,
);
}
#[test]
fn copy() {
check_number(
@ -545,6 +563,20 @@ fn ctpop() {
);
}
#[test]
fn ctlz() {
check_number(
r#"
extern "rust-intrinsic" {
pub fn ctlz<T: Copy>(x: T) -> T;
}
const GOAL: u8 = ctlz(0b0001_1100_u8);
"#,
3,
);
}
#[test]
fn cttz() {
check_number(