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();