Skip to content

Commit

Permalink
Update documentation to note the weird panic message.
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Richey <joerichey@google.com>
  • Loading branch information
josephlr committed Jul 16, 2021
1 parent 2bbaebb commit 45d7c84
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,10 @@ impl Sub<PhysAddr> for PhysAddr {

/// Align address downwards.
///
/// Returns the greatest x with alignment `align` so that x <= addr. The alignment must be
/// a power of 2.
/// Returns the greatest `x` with alignment `align` so that `x <= addr`.
///
/// Panics if the alignment is not a power of two. Without the `const_fn`
/// feature, the panic message will be "index out of bounds".
#[inline]
pub const fn align_down(addr: u64, align: u64) -> u64 {
const_assert!(align.is_power_of_two(), "`align` must be a power of two");
Expand All @@ -541,8 +543,10 @@ pub const fn align_down(addr: u64, align: u64) -> u64 {

/// Align address upwards.
///
/// Returns the smallest x with alignment `align` so that x >= addr. The alignment must be
/// a power of 2.
/// Returns the smallest `x` with alignment `align` so that `x >= addr`.
///
/// Panics if the alignment is not a power of two. Without the `const_fn`
/// feature, the panic message will be "index out of bounds".
#[inline]
pub const fn align_up(addr: u64, align: u64) -> u64 {
const_assert!(align.is_power_of_two(), "`align` must be a power of two");
Expand Down
3 changes: 2 additions & 1 deletion src/structures/gdt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ impl GlobalDescriptorTable {
const_fn! {
/// Adds the given segment descriptor to the GDT, returning the segment selector.
///
/// Panics if the GDT has no free entries left.
/// Panics if the GDT has no free entries left. Without the `const_fn`
/// feature, the panic message will be "index out of bounds".
#[inline]
pub fn add_entry(&mut self, entry: Descriptor) -> SegmentSelector {
let index = match entry {
Expand Down

0 comments on commit 45d7c84

Please sign in to comment.