Skip to content

Commit 6b73fe2

Browse files
committed
Give const_deallocate a default body
1 parent 9a07437 commit 6b73fe2

File tree

4 files changed

+18
-25
lines changed

4 files changed

+18
-25
lines changed

compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -1229,11 +1229,6 @@ fn codegen_regular_intrinsic_call<'tcx>(
12291229
ret.write_cvalue(fx, CValue::by_val(cmp, ret.layout()));
12301230
}
12311231

1232-
sym::const_deallocate => {
1233-
intrinsic_args!(fx, args => (_ptr, _size, _align); intrinsic);
1234-
// nop at runtime.
1235-
}
1236-
12371232
sym::black_box => {
12381233
intrinsic_args!(fx, args => (a); intrinsic);
12391234

compiler/rustc_codegen_ssa/src/mir/intrinsic.rs

-5
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
281281
}
282282
}
283283

284-
sym::const_deallocate => {
285-
// nop at runtime.
286-
return Ok(());
287-
}
288-
289284
// This requires that atomic intrinsics follow a specific naming pattern:
290285
// "atomic_<operation>[_<ordering>]"
291286
name if let Some(atomic) = name_str.strip_prefix("atomic_") => {

compiler/rustc_hir_analysis/src/check/intrinsic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ pub fn check_intrinsic_type(
367367
}
368368
sym::const_deallocate => (
369369
0,
370-
0,
370+
1,
371371
vec![Ty::new_mut_ptr(tcx, tcx.types.u8), tcx.types.usize, tcx.types.usize],
372372
Ty::new_unit(tcx),
373373
),

library/core/src/intrinsics.rs

+17-14
Original file line numberDiff line numberDiff line change
@@ -2368,20 +2368,6 @@ extern "rust-intrinsic" {
23682368
#[rustc_nounwind]
23692369
pub fn ptr_guaranteed_cmp<T>(ptr: *const T, other: *const T) -> u8;
23702370

2371-
/// Deallocates a memory which allocated by `intrinsics::const_allocate` at compile time.
2372-
/// At runtime, does nothing.
2373-
///
2374-
/// # Safety
2375-
///
2376-
/// - The `align` argument must be a power of two.
2377-
/// - At compile time, a compile error occurs if this constraint is violated.
2378-
/// - At runtime, it is not checked.
2379-
/// - If the `ptr` is created in an another const, this intrinsic doesn't deallocate it.
2380-
/// - If the `ptr` is pointing to a local variable, this intrinsic doesn't deallocate it.
2381-
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
2382-
#[rustc_nounwind]
2383-
pub fn const_deallocate(ptr: *mut u8, size: usize, align: usize);
2384-
23852371
/// Determines whether the raw bytes of the two values are equal.
23862372
///
23872373
/// This is particularly handy for arrays, since it allows things like just
@@ -2591,13 +2577,30 @@ pub(crate) const unsafe fn debug_assertions() -> bool {
25912577
/// - At compile time, a compile error occurs if this constraint is violated.
25922578
/// - At runtime, it is not checked.
25932579
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
2580+
#[unstable(feature = "core_intrinsics", issue = "none")]
25942581
#[rustc_nounwind]
25952582
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
25962583
pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 {
25972584
// const eval overrides this function, but runtime code should always just return null pointers.
25982585
crate::ptr::null_mut()
25992586
}
26002587

2588+
/// Deallocates a memory which allocated by `intrinsics::const_allocate` at compile time.
2589+
/// At runtime, does nothing.
2590+
///
2591+
/// # Safety
2592+
///
2593+
/// - The `align` argument must be a power of two.
2594+
/// - At compile time, a compile error occurs if this constraint is violated.
2595+
/// - At runtime, it is not checked.
2596+
/// - If the `ptr` is created in an another const, this intrinsic doesn't deallocate it.
2597+
/// - If the `ptr` is pointing to a local variable, this intrinsic doesn't deallocate it.
2598+
#[rustc_const_unstable(feature = "const_heap", issue = "79597")]
2599+
#[unstable(feature = "core_intrinsics", issue = "none")]
2600+
#[rustc_nounwind]
2601+
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
2602+
pub const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {}
2603+
26012604
// Some functions are defined here because they accidentally got made
26022605
// available in this module on stable. See <https://github.com/rust-lang/rust/issues/15702>.
26032606
// (`transmute` also falls into this category, but it cannot be wrapped due to the

0 commit comments

Comments
 (0)