Skip to content

Commit 164b9c3

Browse files
committed
Add more tests
1 parent f35a2bd commit 164b9c3

File tree

2 files changed

+40
-5
lines changed

2 files changed

+40
-5
lines changed

tests/ui/intrinsics/safe-intrinsic-mismatch.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![feature(intrinsics)]
22
#![feature(rustc_attrs)]
3+
#![feature(effects)]
34

45
extern "rust-intrinsic" {
56
fn size_of<T>() -> usize; //~ ERROR intrinsic safety mismatch
@@ -10,4 +11,15 @@ extern "rust-intrinsic" {
1011
//~^ ERROR intrinsic safety mismatch
1112
}
1213

14+
#[rustc_intrinsic]
15+
const fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {}
16+
//~^ ERROR intrinsic safety mismatch
17+
//~| ERROR intrinsic has wrong type
18+
19+
mod foo {
20+
#[rustc_intrinsic]
21+
unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {}
22+
//~^ ERROR wrong number of const parameters
23+
}
24+
1325
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,53 @@
11
error: intrinsic safety mismatch between list of intrinsics within the compiler and core library intrinsics for intrinsic `size_of`
2-
--> $DIR/safe-intrinsic-mismatch.rs:5:5
2+
--> $DIR/safe-intrinsic-mismatch.rs:6:5
33
|
44
LL | fn size_of<T>() -> usize;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^
66

77
error: intrinsic safety mismatch between list of intrinsics within the compiler and core library intrinsics for intrinsic `assume`
8-
--> $DIR/safe-intrinsic-mismatch.rs:9:5
8+
--> $DIR/safe-intrinsic-mismatch.rs:10:5
99
|
1010
LL | fn assume(b: bool);
1111
| ^^^^^^^^^^^^^^^^^^
1212

1313
error: intrinsic safety mismatch between list of intrinsics within the compiler and core library intrinsics for intrinsic `size_of`
14-
--> $DIR/safe-intrinsic-mismatch.rs:5:5
14+
--> $DIR/safe-intrinsic-mismatch.rs:6:5
1515
|
1616
LL | fn size_of<T>() -> usize;
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^
1818
|
1919
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
2020

2121
error: intrinsic safety mismatch between list of intrinsics within the compiler and core library intrinsics for intrinsic `assume`
22-
--> $DIR/safe-intrinsic-mismatch.rs:9:5
22+
--> $DIR/safe-intrinsic-mismatch.rs:10:5
2323
|
2424
LL | fn assume(b: bool);
2525
| ^^^^^^^^^^^^^^^^^^
2626
|
2727
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
2828

29-
error: aborting due to 4 previous errors
29+
error: intrinsic safety mismatch between list of intrinsics within the compiler and core library intrinsics for intrinsic `const_deallocate`
30+
--> $DIR/safe-intrinsic-mismatch.rs:15:1
31+
|
32+
LL | const fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {}
33+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
34+
35+
error[E0308]: intrinsic has wrong type
36+
--> $DIR/safe-intrinsic-mismatch.rs:15:26
37+
|
38+
LL | const fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {}
39+
| ^ expected unsafe fn, found normal fn
40+
|
41+
= note: expected signature `unsafe fn(_, _, _)`
42+
found signature `fn(_, _, _)`
43+
44+
error[E0094]: intrinsic has wrong number of const parameters: found 0, expected 1
45+
--> $DIR/safe-intrinsic-mismatch.rs:21:31
46+
|
47+
LL | unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {}
48+
| ^ expected 1 const parameter
49+
50+
error: aborting due to 7 previous errors
3051

52+
Some errors have detailed explanations: E0094, E0308.
53+
For more information about an error, try `rustc --explain E0094`.

0 commit comments

Comments
 (0)