Skip to content

Commit 77a7ee7

Browse files
committed
memory_encryption: rewrite const_fn calls to re-use old feature
1 parent 29e9466 commit 77a7ee7

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

Cargo.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ bit_field = "0.10.1"
2424
bitflags = "2.3.2"
2525
volatile = "0.4.4"
2626
rustversion = "1.0.5"
27-
const_fn = "0.4.11"
27+
const_fn = { optional = true, version = "0.4.11" }
2828

2929
[features]
3030
default = ["nightly", "instructions"]
@@ -33,7 +33,6 @@ memory_encryption = []
3333
nightly = ["const_fn", "step_trait", "abi_x86_interrupt", "asm_const"]
3434
abi_x86_interrupt = []
3535
# deprecated, no longer needed
36-
const_fn = []
3736
asm_const = []
3837
step_trait = []
3938
doc_auto_cfg = []

src/addr.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use crate::structures::mem_encrypt::ENC_BIT_MASK;
55
use crate::structures::paging::page_table::PageTableLevel;
66
use crate::structures::paging::{PageOffset, PageTableIndex};
77
use bit_field::BitField;
8-
use const_fn::const_fn;
98
use core::convert::TryFrom;
109
use core::fmt;
1110
#[cfg(feature = "step_trait")]
@@ -446,7 +445,7 @@ impl PhysAddr {
446445
/// If the `memory_encryption` feature is available and has been enabled, this function also
447446
/// panics fails if the encryption bit is manually set in the address.
448447
#[inline]
449-
#[const_fn(cfg(not(feature = "memory_encryption")))]
448+
#[cfg_attr(all(not(feature = "memory_encryption"), feature = "const_fn"), const_fn::const_fn)]
450449
pub const fn new(addr: u64) -> Self {
451450
// TODO: Replace with .ok().expect(msg) when that works on stable.
452451
match Self::try_new(addr) {
@@ -471,7 +470,7 @@ impl PhysAddr {
471470
/// If the `memory_encryption` feature is available and has been enabled, this also fails if the
472471
/// encryption bit is manually set in the address.
473472
#[inline]
474-
#[const_fn(cfg(not(feature = "memory_encryption")))]
473+
#[cfg_attr(all(not(feature = "memory_encryption"), feature = "const_fn"), const_fn::const_fn)]
475474
pub const fn try_new(addr: u64) -> Result<Self, PhysAddrNotValid> {
476475
let p = Self::new_truncate(addr);
477476
if p.0 == addr {

src/structures/paging/page_table.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use super::{PageSize, PhysFrame, Size4KiB};
44
use crate::addr::PhysAddr;
55
use bitflags::bitflags;
6-
use const_fn::const_fn;
76
use core::fmt;
87
#[cfg(feature = "step_trait")]
98
use core::iter::Step;
@@ -53,7 +52,7 @@ impl PageTableEntry {
5352

5453
/// Returns the flags of this entry.
5554
#[inline]
56-
#[const_fn(cfg(not(feature = "memory_encryption")))]
55+
#[cfg_attr(all(not(feature = "memory_encryption"), feature = "const_fn"), const_fn::const_fn)]
5756
pub const fn flags(&self) -> PageTableFlags {
5857
PageTableFlags::from_bits_retain(self.entry & !Self::physical_address_mask())
5958
}

0 commit comments

Comments
 (0)