diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-01-31 20:51:29 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-02-12 17:52:05 +0000 |
| commit | 6b73fe2d0977f9b1a98242b8ecf359c7804640e4 (patch) | |
| tree | 568e089ab80fc3415029c5cb7435bcdb3154af86 | |
| parent | 9a0743747f3b587ff0b4ba06bf51d3a079f37e50 (diff) | |
Give const_deallocate a default body
| -rw-r--r-- | compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/mir/intrinsic.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_hir_analysis/src/check/intrinsic.rs | 2 | ||||
| -rw-r--r-- | library/core/src/intrinsics.rs | 31 |
4 files changed, 18 insertions, 25 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs index 210a3da2c5d..476752c7230 100644 --- a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs +++ b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs @@ -1229,11 +1229,6 @@ fn codegen_regular_intrinsic_call<'tcx>( ret.write_cvalue(fx, CValue::by_val(cmp, ret.layout())); } - sym::const_deallocate => { - intrinsic_args!(fx, args => (_ptr, _size, _align); intrinsic); - // nop at runtime. - } - sym::black_box => { intrinsic_args!(fx, args => (a); intrinsic); diff --git a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs index d6a0dc6bbef..e4633acd817 100644 --- a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs +++ b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs @@ -281,11 +281,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } } - sym::const_deallocate => { - // nop at runtime. - return Ok(()); - } - // This requires that atomic intrinsics follow a specific naming pattern: // "atomic_<operation>[_<ordering>]" name if let Some(atomic) = name_str.strip_prefix("atomic_") => { diff --git a/compiler/rustc_hir_analysis/src/check/intrinsic.rs b/compiler/rustc_hir_analysis/src/check/intrinsic.rs index 397112e8db7..6f5584225c1 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsic.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsic.rs @@ -367,7 +367,7 @@ pub fn check_intrinsic_type( } sym::const_deallocate => ( 0, - 0, + 1, vec![Ty::new_mut_ptr(tcx, tcx.types.u8), tcx.types.usize, tcx.types.usize], Ty::new_unit(tcx), ), diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 3a178510e79..2cc01a5390b 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -2368,20 +2368,6 @@ extern "rust-intrinsic" { #[rustc_nounwind] pub fn ptr_guaranteed_cmp<T>(ptr: *const T, other: *const T) -> u8; - /// Deallocates a memory which allocated by `intrinsics::const_allocate` at compile time. - /// At runtime, does nothing. - /// - /// # Safety - /// - /// - The `align` argument must be a power of two. - /// - At compile time, a compile error occurs if this constraint is violated. - /// - At runtime, it is not checked. - /// - If the `ptr` is created in an another const, this intrinsic doesn't deallocate it. - /// - If the `ptr` is pointing to a local variable, this intrinsic doesn't deallocate it. - #[rustc_const_unstable(feature = "const_heap", issue = "79597")] - #[rustc_nounwind] - pub fn const_deallocate(ptr: *mut u8, size: usize, align: usize); - /// Determines whether the raw bytes of the two values are equal. /// /// This is particularly handy for arrays, since it allows things like just @@ -2591,6 +2577,7 @@ pub(crate) const unsafe fn debug_assertions() -> bool { /// - At compile time, a compile error occurs if this constraint is violated. /// - At runtime, it is not checked. #[rustc_const_unstable(feature = "const_heap", issue = "79597")] +#[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_nounwind] #[cfg_attr(not(bootstrap), rustc_intrinsic)] pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 { @@ -2598,6 +2585,22 @@ pub const unsafe fn const_allocate(_size: usize, _align: usize) -> *mut u8 { crate::ptr::null_mut() } +/// Deallocates a memory which allocated by `intrinsics::const_allocate` at compile time. +/// At runtime, does nothing. +/// +/// # Safety +/// +/// - The `align` argument must be a power of two. +/// - At compile time, a compile error occurs if this constraint is violated. +/// - At runtime, it is not checked. +/// - If the `ptr` is created in an another const, this intrinsic doesn't deallocate it. +/// - If the `ptr` is pointing to a local variable, this intrinsic doesn't deallocate it. +#[rustc_const_unstable(feature = "const_heap", issue = "79597")] +#[unstable(feature = "core_intrinsics", issue = "none")] +#[rustc_nounwind] +#[cfg_attr(not(bootstrap), rustc_intrinsic)] +pub const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {} + // Some functions are defined here because they accidentally got made // available in this module on stable. See <https://github.com/rust-lang/rust/issues/15702>. // (`transmute` also falls into this category, but it cannot be wrapped due to the |
