From f7dee68a7970cbc930ff2332d6b3d9f4e21229da Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Sun, 9 Oct 2022 10:45:34 -0700 Subject: [PATCH 01/16] chore: roll nightly to `2022-10-09` (#335) This commit updates Mycelium's pinned nightly version to Rust `nightly-2022-10-09`. Unfortunately, this currently doesn't work, due to linker errors when linking with the bootloader (see rust-osdev/bootloader#271). --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 26d7c626..b07557f5 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2022-07-31" +channel = "nightly-2022-10-07" components = [ "clippy", "rustfmt", From 9f0d4a43b3714f2d9673d3c0295a4299158a9217 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Fri, 4 Nov 2022 10:23:44 -0700 Subject: [PATCH 02/16] chore: roll nightly to 2022-11-03 (#335) --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index b07557f5..52b69d00 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2022-10-07" +channel = "nightly-2022-11-03" components = [ "clippy", "rustfmt", From 9697ed004d87855bdaa211f1cccd549bb1ed2954 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Fri, 4 Nov 2022 10:23:58 -0700 Subject: [PATCH 03/16] style: update rustfmt on nightly-2022-11-03 (#335) --- hal-x86_64/src/vga.rs | 7 ++++++- maitake/src/sync/wait_map/tests/loom.rs | 3 +-- maitake/src/time/timer/sleep.rs | 6 +++++- maitake/src/time/timer/wheel.rs | 9 ++++++++- mycotest/src/assert.rs | 12 +++++++----- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/hal-x86_64/src/vga.rs b/hal-x86_64/src/vga.rs index ae7d29b4..b507d8d7 100644 --- a/hal-x86_64/src/vga.rs +++ b/hal-x86_64/src/vga.rs @@ -172,7 +172,12 @@ impl fmt::Write for Buffer { impl fmt::Debug for Buffer { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let Self { row, col, color, buf: _} = self; + let Self { + row, + col, + color, + buf: _, + } = self; f.debug_struct("vga::Buffer") .field("row", row) .field("col", col) diff --git a/maitake/src/sync/wait_map/tests/loom.rs b/maitake/src/sync/wait_map/tests/loom.rs index 7425c116..11f72dc8 100644 --- a/maitake/src/sync/wait_map/tests/loom.rs +++ b/maitake/src/sync/wait_map/tests/loom.rs @@ -1,4 +1,3 @@ - use super::*; use crate::loom::{self, future, sync::Arc, thread}; @@ -90,4 +89,4 @@ fn wake_and_drop() { thread.join().unwrap(); }); -} \ No newline at end of file +} diff --git a/maitake/src/time/timer/sleep.rs b/maitake/src/time/timer/sleep.rs index b38786b7..af619816 100644 --- a/maitake/src/time/timer/sleep.rs +++ b/maitake/src/time/timer/sleep.rs @@ -148,7 +148,11 @@ impl PinnedDrop for Sleep<'_> { impl fmt::Debug for Sleep<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let Self { state, entry, timer } = self; + let Self { + state, + entry, + timer, + } = self; f.debug_struct("Sleep") .field("duration", &self.duration()) .field("state", state) diff --git a/maitake/src/time/timer/wheel.rs b/maitake/src/time/timer/wheel.rs index 8d05cf94..1284e498 100644 --- a/maitake/src/time/timer/wheel.rs +++ b/maitake/src/time/timer/wheel.rs @@ -430,7 +430,14 @@ impl Wheel { impl fmt::Debug for Wheel { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let Self { level, ticks_per_slot, ticks_per_wheel, wheel_mask, occupied_slots, slots: _ } = self; + let Self { + level, + ticks_per_slot, + ticks_per_wheel, + wheel_mask, + occupied_slots, + slots: _, + } = self; f.debug_struct("Wheel") .field("level", level) .field("ticks_per_slot", ticks_per_slot) diff --git a/mycotest/src/assert.rs b/mycotest/src/assert.rs index 4f8d8259..0b9b8d64 100644 --- a/mycotest/src/assert.rs +++ b/mycotest/src/assert.rs @@ -143,10 +143,12 @@ macro_rules! assert_binop { impl core::fmt::Debug for Failed { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let Self { expr, file, line, col } = self; - write!( - f, - "assertion failed: `{expr}`, {file}:{line}:{col}", - ) + let Self { + expr, + file, + line, + col, + } = self; + write!(f, "assertion failed: `{expr}`, {file}:{line}:{col}",) } } From b8e904553a174064009c2817000f0637d02a1179 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Fri, 4 Nov 2022 11:24:20 -0700 Subject: [PATCH 04/16] test(maitake): fix segfault running timer tests in loom (#335) --- maitake/src/time/timer/wheel.rs | 121 ++++++++++++++++++-------------- 1 file changed, 69 insertions(+), 52 deletions(-) diff --git a/maitake/src/time/timer/wheel.rs b/maitake/src/time/timer/wheel.rs index 1284e498..3714deba 100644 --- a/maitake/src/time/timer/wheel.rs +++ b/maitake/src/time/timer/wheel.rs @@ -36,7 +36,7 @@ struct Wheel { /// A bitmask for masking out all lower wheels' indices from a `now` timestamp. wheel_mask: u64, - slots: [List; Self::SLOTS], + slots: SlotArray, } #[derive(Debug)] @@ -46,6 +46,17 @@ struct Deadline { wheel: usize, } +/// In loom mode, the slot arrays are apparently a bit too big to pass around +/// (since loom's `UnsafeCell`s and atomics are larger than "real" ones), and we +/// apparently segfault when trying to construct a timer wheel. Therefore, it's +/// necessary to box the slot arrau when running under loom in order to reduce +/// the stack size of the timer wheel. +#[cfg(loom)] +type SlotArray = alloc::boxed::Box<[List; Wheel::SLOTS]>; + +#[cfg(not(loom))] +type SlotArray = [List; Wheel::SLOTS]; + // === impl Core === impl Core { @@ -53,33 +64,34 @@ impl Core { pub(super) const MAX_SLEEP_TICKS: u64 = (1 << (Wheel::BITS * Self::WHEELS)) - 1; - pub(super) const fn new() -> Self { - // Initialize the wheels. - // XXX(eliza): we would have to do this extremely gross thing if we - // wanted to support a variable number of wheels, because const fn... - /* - // Used as an initializer when constructing a new `Core`. - const NEW_WHEEL: Wheel = Wheel::empty(); - - let mut wheels = [NEW_WHEEL; Self::WHEELS];n - let mut level = 0; - while level < Self::WHEELS { - wheels[level].level = level; - wheels[level].ticks_per_slot = wheel::ticks_per_slot(level); - level += 1; - } - */ - - Self { - now: 0, - wheels: [ - Wheel::new(0), - Wheel::new(1), - Wheel::new(2), - Wheel::new(3), - Wheel::new(4), - Wheel::new(5), - ], + loom_const_fn! { + pub(super) fn new() -> Self { + // Initialize the wheels. + // XXX(eliza): we would have to do this extremely gross thing if we + // wanted to support a variable number of wheels, because const fn... + /* + // Used as an initializer when constructing a new `Core`. + const NEW_WHEEL: Wheel = Wheel::empty(); + + let mut wheels = [NEW_WHEEL; Self::WHEELS];n + let mut level = 0; + while level < Self::WHEELS { + wheels[level].level = level; + wheels[level].ticks_per_slot = wheel::ticks_per_slot(level); + level += 1; + } + */ + Self { + now: 0, + wheels: [ + Wheel::new(0), + Wheel::new(1), + Wheel::new(2), + Wheel::new(3), + Wheel::new(4), + Wheel::new(5), + ], + } } } @@ -249,29 +261,34 @@ impl Wheel { /// slots are occupied. const SLOTS: usize = 64; const BITS: usize = Self::SLOTS.trailing_zeros() as usize; - const fn new(level: usize) -> Self { - // linked list const initializer - const NEW_LIST: List = List::new(); - - // how many ticks does a single slot represent in a wheel of this level? - let ticks_per_slot = Self::SLOTS.pow(level as u32) as Ticks; - let ticks_per_wheel = ticks_per_slot * Self::SLOTS as u64; - - debug_assert!(ticks_per_slot.is_power_of_two()); - debug_assert!(ticks_per_wheel.is_power_of_two()); - - // because `ticks_per_wheel` is a power of two, we can calculate a - // bitmask for masking out the indices in all lower wheels from a `now` - // timestamp. - let wheel_mask = !(ticks_per_wheel - 1); - - Self { - level, - ticks_per_slot, - ticks_per_wheel, - wheel_mask, - occupied_slots: 0, - slots: [NEW_LIST; Self::SLOTS], + loom_const_fn! { + fn new(level: usize) -> Self { + // linked list const initializer + const NEW_LIST: List = List::new(); + + // how many ticks does a single slot represent in a wheel of this level? + let ticks_per_slot = Self::SLOTS.pow(level as u32) as Ticks; + let ticks_per_wheel = ticks_per_slot * Self::SLOTS as u64; + + debug_assert!(ticks_per_slot.is_power_of_two()); + debug_assert!(ticks_per_wheel.is_power_of_two()); + + // because `ticks_per_wheel` is a power of two, we can calculate a + // bitmask for masking out the indices in all lower wheels from a `now` + // timestamp. + let wheel_mask = !(ticks_per_wheel - 1); + let slots = [NEW_LIST; Self::SLOTS]; + #[cfg(loom)] + let slots = alloc::boxed::Box::new(slots); + + Self { + level, + ticks_per_slot, + ticks_per_wheel, + wheel_mask, + occupied_slots: 0, + slots, + } } } @@ -444,7 +461,7 @@ impl fmt::Debug for Wheel { .field("ticks_per_wheel", ticks_per_wheel) .field("wheel_mask", &fmt::bin(wheel_mask)) .field("occupied_slots", &fmt::bin(occupied_slots)) - .field("slots", &format_args!("[...]")) + .field("slots", &format_args!("[Slot; {}]", Self::SLOTS)) .finish() } } From b738458c986b52d6be207d8a160f9a5e6a4f7901 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Fri, 4 Nov 2022 11:25:35 -0700 Subject: [PATCH 05/16] style: fix Rust 1.65 clippy lints (#335) --- build.rs | 2 +- hal-core/src/addr.rs | 2 +- hal-x86_64/src/interrupt/idt.rs | 2 +- inoculate/src/lib.rs | 4 ++-- maitake/src/time/timer/wheel/tests.rs | 7 ++----- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/build.rs b/build.rs index c96183bb..0472e80a 100644 --- a/build.rs +++ b/build.rs @@ -7,6 +7,6 @@ fn main() -> Result<(), Box> { // Build our helloworld.wast into binary. let binary = wat::parse_file("src/helloworld.wast")?; - fs::write(out_dir.join("helloworld.wasm"), &binary)?; + fs::write(out_dir.join("helloworld.wasm"), binary)?; Ok(()) } diff --git a/hal-core/src/addr.rs b/hal-core/src/addr.rs index 9b70b6f2..f910ca1c 100644 --- a/hal-core/src/addr.rs +++ b/hal-core/src/addr.rs @@ -32,7 +32,7 @@ pub trait Address: return self; } let aligned = (u | mask) + 1; - Self::from_usize(aligned as usize) + Self::from_usize(aligned) } /// Align `self` up to the required alignment for a value of type `T`. diff --git a/hal-x86_64/src/interrupt/idt.rs b/hal-x86_64/src/interrupt/idt.rs index 8d4461b2..f63e57c5 100644 --- a/hal-x86_64/src/interrupt/idt.rs +++ b/hal-x86_64/src/interrupt/idt.rs @@ -305,7 +305,7 @@ mod tests { // Z: this bit is 0 for a 64-bit IDT. for a 32-bit IDT, this may be 1 for task gates. // Gate Type: 32-bit interrupt gate is 0b1110. that's just how it is. assert_eq!( - present_32bit_interrupt.0 as u8, 0b1000_1110, + present_32bit_interrupt.0, 0b1000_1110, "\n attrs: {:#?}", present_32bit_interrupt ); diff --git a/inoculate/src/lib.rs b/inoculate/src/lib.rs index 260d88ec..b485abec 100644 --- a/inoculate/src/lib.rs +++ b/inoculate/src/lib.rs @@ -200,9 +200,9 @@ impl Options { let mut cmd = self.cargo_cmd("builder"); cmd.current_dir(run_dir) .arg("--kernel-manifest") - .arg(&paths.kernel_manifest()) + .arg(paths.kernel_manifest()) .arg("--kernel-binary") - .arg(&paths.kernel_bin()) + .arg(paths.kernel_bin()) .arg("--out-dir") .arg(out_dir) .arg("--target-dir") diff --git a/maitake/src/time/timer/wheel/tests.rs b/maitake/src/time/timer/wheel/tests.rs index 9c6dbbb2..5c8a7176 100644 --- a/maitake/src/time/timer/wheel/tests.rs +++ b/maitake/src/time/timer/wheel/tests.rs @@ -12,7 +12,7 @@ fn wheel_indices() { ) } - for wheel in 1..Core::WHEELS as usize { + for wheel in 1..Core::WHEELS { for slot in wheel..Wheel::SLOTS { let ticks = (slot * usize::pow(Wheel::SLOTS, wheel as u32)) as u64; assert_eq!( @@ -60,10 +60,7 @@ fn slot_indices() { for i in level..Wheel::SLOTS { let ticks = i * usize::pow(Wheel::SLOTS, level as u32); let slot_index = wheel.slot_index(ticks as u64); - assert_eq!( - i as usize, slot_index, - "wheels[{level}].slot_index({ticks}) == {i}" - ) + assert_eq!(i, slot_index, "wheels[{level}].slot_index({ticks}) == {i}") } } } From cc3c0f4bbf20a5abd17c512093893d05649734d4 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Fri, 4 Nov 2022 11:37:27 -0700 Subject: [PATCH 06/16] style: use `let`-`else` in a few places (#335) --- alloc/src/buddy.rs | 7 +++--- cordyceps/src/list.rs | 39 ++++++++++++++-------------------- cordyceps/src/list/cursor.rs | 15 ++++++------- maitake/src/scheduler/steal.rs | 5 +---- maitake/src/sync/wait_cell.rs | 5 +---- mycotest/src/report.rs | 9 +++----- src/arch/x86_64/framebuf.rs | 5 ++--- 7 files changed, 32 insertions(+), 53 deletions(-) diff --git a/alloc/src/buddy.rs b/alloc/src/buddy.rs index 0a9ae13b..90e4eafe 100644 --- a/alloc/src/buddy.rs +++ b/alloc/src/buddy.rs @@ -318,15 +318,14 @@ impl Alloc { tracing::trace!(?min_order); let min_order = min_order.ok_or_else(AllocErr::oom)?; - let size = match self.size_for(layout) { - Some(size) => size, + let Some(size) = self.size_for(layout) else { // XXX(eliza): is it better to just leak it? - None => panic!( + panic!( "couldn't determine the correct layout for an allocation \ we previously allocated successfully, what the actual fuck!\n \ addr={:?}; layout={:?}; min_order={}", paddr, layout, min_order, - ), + ) }; // Construct a new free block. diff --git a/cordyceps/src/list.rs b/cordyceps/src/list.rs index 0e5c8505..018c39df 100644 --- a/cordyceps/src/list.rs +++ b/cordyceps/src/list.rs @@ -312,14 +312,11 @@ impl> + ?Sized> List { /// /// This operation should compute in *O*(1) time and *O*(1) memory. pub fn append(&mut self, other: &mut Self) { - let tail = match self.tail { + let Some(tail) = self.tail else { // if this list is empty, simply replace it with `other` - None => { - debug_assert!(self.is_empty()); - mem::swap(self, other); - return; - } - Some(tail) => tail, + debug_assert!(self.is_empty()); + mem::swap(self, other); + return; }; // if `other` is empty, do nothing. @@ -450,19 +447,16 @@ impl> + ?Sized> List { /// Asserts as many of the linked list's invariants as possible. #[track_caller] pub(crate) fn assert_valid_named(&self, name: &str) { - let head = match self.head { - Some(head) => head, - None => { - assert!( - self.tail.is_none(), - "{name}if the linked list's head is null, the tail must also be null" - ); - assert_eq!( - self.len, 0, - "{name}if a linked list's head is null, its length must be 0" - ); - return; - } + let Some(head) = self.head else { + assert!( + self.tail.is_none(), + "{name}if the linked list's head is null, the tail must also be null" + ); + assert_eq!( + self.len, 0, + "{name}if a linked list's head is null, its length must be 0" + ); + return; }; assert_ne!( @@ -928,9 +922,8 @@ impl> + ?Sized> List { #[inline] unsafe fn split_after_node(&mut self, split_node: Link, idx: usize) -> Self { - let split_node = match split_node { - Some(node) => node, - None => return mem::replace(self, Self::new()), + let Some(split_node) = split_node else { + return mem::replace(self, Self::new()); }; // the head of the new list is the split node's `next` node (which is diff --git a/cordyceps/src/list/cursor.rs b/cordyceps/src/list/cursor.rs index 577dbc58..f3c275a8 100644 --- a/cordyceps/src/list/cursor.rs +++ b/cordyceps/src/list/cursor.rs @@ -334,10 +334,9 @@ impl<'list, T: Linked> + ?Sized> CursorMut<'list, T> { let split_at = self.core.index; self.core.index = 0; - let split_node = match self.core.curr { - Some(node) => node, + let Some(split_node) = self.core.curr else { // the split portion is the entire list. just return it. - None => return mem::replace(self.core.list, List::new()), + return mem::replace(self.core.list, List::new()) }; // the tail of the new list is the split node's `prev` node (which is @@ -374,10 +373,9 @@ impl<'list, T: Linked> + ?Sized> CursorMut<'list, T> { /// If the cursor is pointing at the null element, then the contents of /// `spliced` are inserted at the beginning of the `List` the cursor points to. pub fn splice_after(&mut self, mut spliced: List) { - let (splice_head, splice_tail, splice_len) = match spliced.take_all() { - Some(spliced) => spliced, + let Some((splice_head, splice_tail, splice_len)) = spliced.take_all() else { // the spliced list is empty, do nothing. - None => return, + return; }; let next = self.core.next_link(); @@ -404,10 +402,9 @@ impl<'list, T: Linked> + ?Sized> CursorMut<'list, T> { /// If the cursor is pointing at the null element, then the contents of /// `spliced` are inserted at the end of the `List` the cursor points to. pub fn splice_before(&mut self, mut spliced: List) { - let (splice_head, splice_tail, splice_len) = match spliced.take_all() { - Some(spliced) => spliced, + let Some((splice_head, splice_tail, splice_len)) = spliced.take_all() else { // the spliced list is empty, do nothing. - None => return, + return; }; let prev = self.core.prev_link(); diff --git a/maitake/src/scheduler/steal.rs b/maitake/src/scheduler/steal.rs index 75368a8d..fc105d9e 100644 --- a/maitake/src/scheduler/steal.rs +++ b/maitake/src/scheduler/steal.rs @@ -192,10 +192,7 @@ impl<'worker, S: Schedule> Stealer<'worker, S> { /// - `true` if a task was successfully stolen. /// - `false` if the targeted queue is empty. pub fn spawn_one(&self, scheduler: &S) -> bool { - let task = match self.queue.dequeue() { - Some(task) => task, - None => return false, - }; + let Some(task) = self.queue.dequeue() else { return false }; test_trace!(?task, "stole"); // decrement the target queue's task count diff --git a/maitake/src/sync/wait_cell.rs b/maitake/src/sync/wait_cell.rs index efd968c8..1ff6674d 100644 --- a/maitake/src/sync/wait_cell.rs +++ b/maitake/src/sync/wait_cell.rs @@ -446,10 +446,7 @@ pub(crate) mod test_util { let this = Arc::downgrade(&self); drop(self); futures_util::future::poll_fn(move |cx| { - let this = match this.upgrade() { - Some(this) => this, - None => return Poll::Ready(()), - }; + let Some(this) = this.upgrade() else {return Poll::Ready(()) }; let res = this.task.wait(); futures_util::pin_mut!(res); diff --git a/mycotest/src/report.rs b/mycotest/src/report.rs index 1bc9efb1..e68dd4c5 100644 --- a/mycotest/src/report.rs +++ b/mycotest/src/report.rs @@ -61,12 +61,9 @@ impl<'a> TestName<'a> { #[tracing::instrument(level = "trace")] pub fn parse_outcome(line: &'a str) -> Result, ParseError> { - let line = match line.strip_prefix("MYCELIUM_TEST_") { - None => { - tracing::trace!("not a test outcome"); - return Ok(None); - } - Some(line) => line, + let Some(line) = line.strip_prefix("MYCELIUM_TEST_") else { + tracing::trace!("not a test outcome"); + return Ok(None); }; tracing::trace!(?line); let (line, result) = if let Some(line) = line.strip_prefix("PASS:") { diff --git a/src/arch/x86_64/framebuf.rs b/src/arch/x86_64/framebuf.rs index bfea870f..28fd9fee 100644 --- a/src/arch/x86_64/framebuf.rs +++ b/src/arch/x86_64/framebuf.rs @@ -54,11 +54,10 @@ pub(super) fn init(bootinfo: &mut BootInfo) -> bool { } // Okay, try to initialize the framebuffer - let framebuffer = match mem::replace(&mut bootinfo.framebuffer, Optional::None) { - Optional::Some(framebuffer) => framebuffer, + let Optional::Some(framebuffer) = mem::replace(&mut bootinfo.framebuffer, Optional::None) else { // The boot info does not contain a framebuffer configuration. Nothing // for us to do! - Optional::None => return false, + return false; }; let info = framebuffer.info(); From 5f4f71f69163536eb0c78e19c83caf67e012c29e Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Sat, 5 Nov 2022 10:20:10 -0700 Subject: [PATCH 07/16] chore: roll nightly to 2022-11-04 (#335) --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 52b69d00..5d015422 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2022-11-03" +channel = "nightly-2022-11-04" components = [ "clippy", "rustfmt", From 2e00f678b8468394505bd25e895ab62812b5776e Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Sat, 5 Nov 2022 10:23:52 -0700 Subject: [PATCH 08/16] chore(justfile): dedup rustdoc command (#335) --- justfile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/justfile b/justfile index b5686561..c38295e2 100755 --- a/justfile +++ b/justfile @@ -26,6 +26,9 @@ _fmt := if env_var_or_default("GITHUB_ACTIONS", "") != "true" { "" } else { ``` } +# arguments to pass to all RustDoc invocations +_rustdoc := _cargo + " doc --no-deps --all-features --document-private-items" + # default recipe to display help information default: @echo "justfile for Mycelium" @@ -81,14 +84,13 @@ check-docs crate='': (build-docs crate '--cfg docsrs -Dwarnings') (test-docs cra # open RustDoc documentation for `crate` (or for the whole workspace). docs crate='' $RUSTDOCFLAGS='--cfg docsrs': (build-docs crate RUSTDOCFLAGS) - {{ _cargo }} doc \ + {{ _rustdoc }} \ {{ if crate == '' { '--workspace' } else { '--package' } }} {{ crate }} \ - --no-deps --all-features \ --open # build RustDoc documentation for the workspace. build-docs crate='' $RUSTDOCFLAGS='--cfg docsrs': - {{ _cargo }} doc --no-deps --all-features --document-private-items \ + {{ _rustdoc }} \ {{ if crate == '' { '--workspace' } else { '--package' } }} {{ crate }} \ {{ _fmt }} From bf025e052b336dee684ecde48e42784be292f045 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Sat, 5 Nov 2022 10:48:33 -0700 Subject: [PATCH 09/16] chore: roll nightly to 2022-11-05 (#335) --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 5d015422..6eb9195a 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2022-11-04" +channel = "nightly-2022-11-05" components = [ "clippy", "rustfmt", From 9c69100784cfa0a55abd787443136d962d683e03 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Sun, 6 Nov 2022 10:02:32 -0800 Subject: [PATCH 10/16] chore: bump nightly to 2022-11-06 (#335) --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 6eb9195a..e13d4ce1 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2022-11-05" +channel = "nightly-2022-11-06" components = [ "clippy", "rustfmt", From dc5a9d6d2bb893d74d7e7a6789bc638c4f03bb51 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Fri, 11 Nov 2022 11:54:04 -0800 Subject: [PATCH 11/16] chore: roll nightly to 2022-11-11 (#335) --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index e13d4ce1..4b818aba 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2022-11-06" +channel = "nightly-2022-11-11" components = [ "clippy", "rustfmt", From 78485d8b08b548e8f9cbf1d37322b67f99ea84b6 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Fri, 11 Nov 2022 11:55:56 -0800 Subject: [PATCH 12/16] fix(util): rename `ilog` fns to avoid clash with std (#335) --- util/src/math.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/util/src/math.rs b/util/src/math.rs index 1c399d15..7d7a3919 100644 --- a/util/src/math.rs +++ b/util/src/math.rs @@ -48,10 +48,10 @@ pub trait Logarithm: Sized { /// Returns the integer logarithm base `base` of `self`, or `None` if it is /// not possible to take the log base `base` of `self`. - fn checked_ilog(self, base: Self) -> Option; + fn checked_log(self, base: Self) -> Option; /// Returns the integer logarithm base `base` of `self`. - fn ilog(self, base: Self) -> Self; + fn log(self, base: Self) -> Self; } impl Logarithm for usize { @@ -72,15 +72,15 @@ impl Logarithm for usize { #[inline(always)] #[must_use = "this returns the result of the operation, \ without modifying the original"] - fn checked_ilog(self, base: usize) -> Option { + fn checked_log(self, base: usize) -> Option { usize_const_checked_log(self, base) } #[inline(always)] #[must_use = "this returns the result of the operation, \ without modifying the original"] - fn ilog(self, base: usize) -> Self { - match self.checked_ilog(base) { + fn log(self, base: usize) -> Self { + match self.checked_log(base) { Some(log) => log, None => panic!("cannot take log base {} of {}", base, self), } From 7f0462fd04c4a090d3617bad9a88e5885a520872 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Tue, 15 Nov 2022 10:43:24 -0800 Subject: [PATCH 13/16] chore: roll nightly to 2022-11-15 (#335) This appears not to have the fix for rust-lang/rust#104145 yet, as it's currently on rust-lang/rust@96ddd32c4bfb1d78f0cd03eb068b1710a8cebeef, and the fix was merged in rust-lang/rust@dc869fcfb22bfabae187578dcd10ba68348fdc93, but I figured I'd bump anyway. Tomorrow's nightly should be good again! --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 4b818aba..4ea6edc7 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2022-11-11" +channel = "nightly-2022-11-15" components = [ "clippy", "rustfmt", From 46f1621b196ab3ef7fbfe4f9d5c0e60986e90d14 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Wed, 16 Nov 2022 09:04:36 -0800 Subject: [PATCH 14/16] chore: roll nightly to 2022-11-16 (#335) This contains the fix for rust-lang/rust#104145, so our docs build now! --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 4ea6edc7..7c0c234a 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2022-11-15" +channel = "nightly-2022-11-16" components = [ "clippy", "rustfmt", From 47162c1524582d89cc6d3368851e76e80496d175 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Wed, 16 Nov 2022 09:11:11 -0800 Subject: [PATCH 15/16] fix(kernel): just use `core`'s `checked_ilog` (#335) --- src/allocator.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/allocator.rs b/src/allocator.rs index a04eaf05..3d6a44eb 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -9,7 +9,7 @@ use hal_core::{ PAddr, }; use mycelium_alloc::{buddy, bump}; -use mycelium_util::{fmt, math::Logarithm}; +use mycelium_util::fmt; #[derive(Debug)] pub struct Allocator { @@ -171,7 +171,10 @@ impl fmt::Display for State { if bump_mode { writeln!(f, " bump allocator mode only")?; } else { - let digits = (heap_size).checked_ilog(10).unwrap_or(0) + 1; + let digits = { + let digits = (heap_size).checked_ilog(10).unwrap_or(0) + 1; + digits as usize + }; let free = heap_size - allocated; writeln!(f, "buddy heap:")?; @@ -188,7 +191,10 @@ impl fmt::Display for State { } writeln!(f, "bump region:")?; - let bump_digits = (bump_size).checked_ilog(10).unwrap_or(0) + 1; + let bump_digits = { + let digits = (bump_size).checked_ilog(10).unwrap_or(0) + 1; + digits as usize + }; let bump_free = bump_size - bump_allocated; writeln!(f, " {bump_free:>digits$} B free", digits = bump_digits)?; From fc455ca640b3b746f61d0cbfcb4d7664c94a7c85 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Wed, 16 Nov 2022 09:16:52 -0800 Subject: [PATCH 16/16] docs(maitake): fix typo in timer wheel comment (#335) --- maitake/src/time/timer/wheel.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maitake/src/time/timer/wheel.rs b/maitake/src/time/timer/wheel.rs index 3714deba..50148650 100644 --- a/maitake/src/time/timer/wheel.rs +++ b/maitake/src/time/timer/wheel.rs @@ -49,7 +49,7 @@ struct Deadline { /// In loom mode, the slot arrays are apparently a bit too big to pass around /// (since loom's `UnsafeCell`s and atomics are larger than "real" ones), and we /// apparently segfault when trying to construct a timer wheel. Therefore, it's -/// necessary to box the slot arrau when running under loom in order to reduce +/// necessary to box the slot array when running under loom in order to reduce /// the stack size of the timer wheel. #[cfg(loom)] type SlotArray = alloc::boxed::Box<[List; Wheel::SLOTS]>;