Skip to content

Commit e722949

Browse files
committed
Give some more intrinsics fallback bodies
1 parent 0ebac0d commit e722949

File tree

5 files changed

+23
-24
lines changed

5 files changed

+23
-24
lines changed

Diff for: compiler/rustc_hir_analysis/src/check/intrinsic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ pub fn check_intrinsic_type(
222222
sym::caller_location => (0, 0, vec![], tcx.caller_location_ty()),
223223
sym::assert_inhabited
224224
| sym::assert_zero_valid
225-
| sym::assert_mem_uninitialized_valid => (1, 0, vec![], Ty::new_unit(tcx)),
225+
| sym::assert_mem_uninitialized_valid => (1, 1, vec![], Ty::new_unit(tcx)),
226226
sym::forget => (1, 0, vec![param(0)], Ty::new_unit(tcx)),
227227
sym::transmute | sym::transmute_unchecked => (2, 0, vec![param(0)], param(1)),
228228
sym::prefetch_read_data

Diff for: tests/ui/intrinsics/safe-intrinsic-mismatch.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
extern "rust-intrinsic" {
66
fn size_of<T>() -> usize; //~ ERROR intrinsic safety mismatch
77
//~^ ERROR intrinsic safety mismatch
8-
9-
#[rustc_safe_intrinsic]
10-
fn assume(b: bool); //~ ERROR intrinsic safety mismatch
11-
//~^ ERROR intrinsic safety mismatch
128
}
139

10+
#[rustc_intrinsic]
11+
const fn assume(_b: bool) {} //~ ERROR intrinsic safety mismatch
12+
//~| ERROR intrinsic has wrong type
13+
1414
#[rustc_intrinsic]
1515
const fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {}
1616
//~^ ERROR intrinsic safety mismatch

Diff for: tests/ui/intrinsics/safe-intrinsic-mismatch.stderr

+11-10
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ error: intrinsic safety mismatch between list of intrinsics within the compiler
44
LL | fn size_of<T>() -> usize;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^
66

7-
error: intrinsic safety mismatch between list of intrinsics within the compiler and core library intrinsics for intrinsic `assume`
8-
--> $DIR/safe-intrinsic-mismatch.rs:10:5
9-
|
10-
LL | fn assume(b: bool);
11-
| ^^^^^^^^^^^^^^^^^^
12-
137
error: intrinsic safety mismatch between list of intrinsics within the compiler and core library intrinsics for intrinsic `size_of`
148
--> $DIR/safe-intrinsic-mismatch.rs:6:5
159
|
@@ -19,12 +13,19 @@ LL | fn size_of<T>() -> usize;
1913
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
2014

2115
error: intrinsic safety mismatch between list of intrinsics within the compiler and core library intrinsics for intrinsic `assume`
22-
--> $DIR/safe-intrinsic-mismatch.rs:10:5
16+
--> $DIR/safe-intrinsic-mismatch.rs:11:1
2317
|
24-
LL | fn assume(b: bool);
25-
| ^^^^^^^^^^^^^^^^^^
18+
LL | const fn assume(_b: bool) {}
19+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
20+
21+
error[E0308]: intrinsic has wrong type
22+
--> $DIR/safe-intrinsic-mismatch.rs:11:16
2623
|
27-
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
24+
LL | const fn assume(_b: bool) {}
25+
| ^ expected unsafe fn, found normal fn
26+
|
27+
= note: expected signature `unsafe fn(_)`
28+
found signature `fn(_)`
2829

2930
error: intrinsic safety mismatch between list of intrinsics within the compiler and core library intrinsics for intrinsic `const_deallocate`
3031
--> $DIR/safe-intrinsic-mismatch.rs:15:1

Diff for: tests/ui/reify-intrinsic.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ fn b() {
1313
}
1414

1515
fn c() {
16-
let _ = [
17-
std::intrinsics::likely,
16+
let _: [unsafe extern "rust-intrinsic" fn(bool) -> bool; 2] = [
17+
std::intrinsics::likely, //~ ERROR cannot coerce
1818
std::intrinsics::unlikely,
19-
//~^ ERROR cannot coerce
2019
];
2120
}
2221

Diff for: tests/ui/reify-intrinsic.stderr

+5-6
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ LL | let _ = std::mem::transmute as unsafe extern "rust-intrinsic" fn(isize)
1616
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1717

1818
error[E0308]: cannot coerce intrinsics to function pointers
19-
--> $DIR/reify-intrinsic.rs:18:9
19+
--> $DIR/reify-intrinsic.rs:17:9
2020
|
21-
LL | std::intrinsics::unlikely,
22-
| ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot coerce intrinsics to function pointers
21+
LL | std::intrinsics::likely,
22+
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot coerce intrinsics to function pointers
2323
|
24-
= note: expected fn item `extern "rust-intrinsic" fn(_) -> _ {likely}`
25-
found fn item `extern "rust-intrinsic" fn(_) -> _ {unlikely}`
26-
= note: different fn items have unique types, even if their signatures are the same
24+
= note: expected fn pointer `unsafe extern "rust-intrinsic" fn(_) -> _`
25+
found fn item `fn(_) -> _ {likely}`
2726

2827
error: aborting due to 3 previous errors
2928

0 commit comments

Comments
 (0)