Skip to content

Commit

Permalink
const_fn: Remove stablized features
Browse files Browse the repository at this point in the history
Both `const_fn_fn_ptr_basics` and `const_fn_trait_bound` were stabilized
in Rust relese 1.61. We can't immediately remove the `const_fn!` quite
yet. 1.61 is not yet on stable, and even it were, removing them would
increase our MSRV to 1.61 (which we may or may not want to do in a patch
release).

See also: #262 (comment)

Signed-off-by: Joe Richey <[email protected]>
  • Loading branch information
josephlr committed Mar 24, 2022
1 parent 8bec7be commit e6ff36d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

#![cfg_attr(not(test), no_std)]
#![cfg_attr(feature = "const_fn", feature(const_mut_refs))] // GDT add_entry()
#![cfg_attr(feature = "const_fn", feature(const_fn_fn_ptr_basics))] // IDT new()
#![cfg_attr(feature = "const_fn", feature(const_fn_trait_bound))] // PageSize marker trait
#![cfg_attr(feature = "abi_x86_interrupt", feature(abi_x86_interrupt))]
#![cfg_attr(feature = "step_trait", feature(step_trait))]
#![cfg_attr(feature = "doc_cfg", feature(doc_cfg))]
Expand Down
1 change: 1 addition & 0 deletions src/structures/idt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ pub struct InterruptDescriptorTable {
}

impl InterruptDescriptorTable {
// TODO: Remove const_fn! when our minimum supported stable Rust version is 1.61
const_fn! {
/// Creates a new IDT filled with non-present entries.
#[inline]
Expand Down
8 changes: 7 additions & 1 deletion src/structures/paging/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ use core::ops::{Add, AddAssign, Sub, SubAssign};
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
pub struct PhysFrame<S: PageSize = Size4KiB> {
pub(crate) start_address: PhysAddr, // TODO: remove when start_address() is const
// TODO: Make private when our minimum supported stable Rust version is 1.61
pub(crate) start_address: PhysAddr,
size: PhantomData<S>,
}

Expand All @@ -29,6 +30,7 @@ impl<S: PageSize> PhysFrame<S> {
Ok(unsafe { PhysFrame::from_start_address_unchecked(address) })
}

// TODO: Remove const_fn! when our minimum supported stable Rust version is 1.61
const_fn! {
/// Returns the frame that starts at the given virtual address.
///
Expand All @@ -53,6 +55,7 @@ impl<S: PageSize> PhysFrame<S> {
}
}

// TODO: Remove const_fn! when our minimum supported stable Rust version is 1.61
const_fn! {
/// Returns the start address of the frame.
#[inline]
Expand All @@ -61,6 +64,7 @@ impl<S: PageSize> PhysFrame<S> {
}
}

// TODO: Remove const_fn! when our minimum supported stable Rust version is 1.61
const_fn! {
/// Returns the size the frame (4KB, 2MB or 1GB).
#[inline]
Expand All @@ -69,6 +73,7 @@ impl<S: PageSize> PhysFrame<S> {
}
}

// TODO: Remove const_fn! when our minimum supported stable Rust version is 1.61
const_fn! {
/// Returns a range of frames, exclusive `end`.
#[inline]
Expand All @@ -77,6 +82,7 @@ impl<S: PageSize> PhysFrame<S> {
}
}

// TODO: Remove const_fn! when our minimum supported stable Rust version is 1.61
const_fn! {
/// Returns a range of frames, inclusive `end`.
#[inline]
Expand Down
9 changes: 9 additions & 0 deletions src/structures/paging/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ impl<S: PageSize> Page<S> {
Ok(Page::containing_address(address))
}

// TODO: Remove const_fn! when our minimum supported stable Rust version is 1.61
const_fn! {
/// Returns the page that starts at the given virtual address.
///
Expand All @@ -101,6 +102,7 @@ impl<S: PageSize> Page<S> {
}
}

// TODO: Remove const_fn! when our minimum supported stable Rust version is 1.61
const_fn! {
/// Returns the start address of the page.
#[inline]
Expand All @@ -109,6 +111,7 @@ impl<S: PageSize> Page<S> {
}
}

// TODO: Remove const_fn! when our minimum supported stable Rust version is 1.61
const_fn! {
/// Returns the size the page (4KB, 2MB or 1GB).
#[inline]
Expand All @@ -117,6 +120,7 @@ impl<S: PageSize> Page<S> {
}
}

// TODO: Remove const_fn! when our minimum supported stable Rust version is 1.61
const_fn! {
/// Returns the level 4 page table index of this page.
#[inline]
Expand All @@ -125,6 +129,7 @@ impl<S: PageSize> Page<S> {
}
}

// TODO: Remove const_fn! when our minimum supported stable Rust version is 1.61
const_fn! {
/// Returns the level 3 page table index of this page.
#[inline]
Expand All @@ -133,6 +138,7 @@ impl<S: PageSize> Page<S> {
}
}

// TODO: Remove const_fn! when our minimum supported stable Rust version is 1.61
const_fn! {
/// Returns the table index of this page at the specified level.
#[inline]
Expand All @@ -141,6 +147,7 @@ impl<S: PageSize> Page<S> {
}
}

// TODO: Remove const_fn! when our minimum supported stable Rust version is 1.61
const_fn! {
/// Returns a range of pages, exclusive `end`.
#[inline]
Expand All @@ -149,6 +156,7 @@ impl<S: PageSize> Page<S> {
}
}

// TODO: Remove const_fn! when our minimum supported stable Rust version is 1.61
const_fn! {
/// Returns a range of pages, inclusive `end`.
#[inline]
Expand All @@ -159,6 +167,7 @@ impl<S: PageSize> Page<S> {
}

impl<S: NotGiantPageSize> Page<S> {
// TODO: Remove const_fn! when our minimum supported stable Rust version is 1.61
const_fn! {
/// Returns the level 2 page table index of this page.
#[inline]
Expand Down

0 comments on commit e6ff36d

Please sign in to comment.