Skip to content

Commit 55d5fad

Browse files
authored
Merge pull request #326 from Freax13/const-panic
remove `const_assert!` in favor of std's `assert!`
2 parents 498fa5c + 36a9243 commit 55d5fad

File tree

3 files changed

+3
-17
lines changed

3 files changed

+3
-17
lines changed

src/addr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ impl Sub<PhysAddr> for PhysAddr {
544544
/// feature, the panic message will be "index out of bounds".
545545
#[inline]
546546
pub const fn align_down(addr: u64, align: u64) -> u64 {
547-
const_assert!(align.is_power_of_two(), "`align` must be a power of two");
547+
assert!(align.is_power_of_two(), "`align` must be a power of two");
548548
addr & !(align - 1)
549549
}
550550

@@ -556,7 +556,7 @@ pub const fn align_down(addr: u64, align: u64) -> u64 {
556556
/// feature, the panic message will be "index out of bounds".
557557
#[inline]
558558
pub const fn align_up(addr: u64, align: u64) -> u64 {
559-
const_assert!(align.is_power_of_two(), "`align` must be a power of two");
559+
assert!(align.is_power_of_two(), "`align` must be a power of two");
560560
let align_mask = align - 1;
561561
if addr & align_mask == 0 {
562562
addr // already aligned

src/lib.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//! and access to various system registers.
33
44
#![cfg_attr(not(test), no_std)]
5-
#![cfg_attr(feature = "const_fn", feature(const_panic))] // Better panic messages
65
#![cfg_attr(feature = "const_fn", feature(const_mut_refs))] // GDT add_entry()
76
#![cfg_attr(feature = "const_fn", feature(const_fn_fn_ptr_basics))] // IDT new()
87
#![cfg_attr(feature = "const_fn", feature(const_fn_trait_bound))] // PageSize marker trait
@@ -45,19 +44,6 @@ macro_rules! const_fn {
4544
};
4645
}
4746

48-
// Helper method for assert! in const fn. Uses out of bounds indexing if an
49-
// assertion fails and the "const_fn" feature is not enabled.
50-
#[cfg(feature = "const_fn")]
51-
macro_rules! const_assert {
52-
($cond:expr, $($arg:tt)+) => { assert!($cond, $($arg)*) };
53-
}
54-
#[cfg(not(feature = "const_fn"))]
55-
macro_rules! const_assert {
56-
($cond:expr, $($arg:tt)+) => {
57-
[(); 1][!($cond as bool) as usize]
58-
};
59-
}
60-
6147
#[cfg(all(feature = "instructions", feature = "external_asm"))]
6248
pub(crate) mod asm;
6349

src/structures/gdt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl GlobalDescriptorTable {
7272
let mut table = [0; 8];
7373
let mut idx = 0;
7474

75-
const_assert!(
75+
assert!(
7676
next_free <= 8,
7777
"initializing a GDT from a slice requires it to be **at most** 8 elements."
7878
);

0 commit comments

Comments
 (0)