mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Auto merge of #15268 - HKalbasi:mir, r=HKalbasi
Add write_bytes and ctlz intrinsics
This commit is contained in:
commit
d16d5fcf68
6 changed files with 93 additions and 13 deletions
|
@ -1725,6 +1725,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
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue