diff --git a/cli/src/commands/run.rs b/cli/src/commands/run.rs index 8c205cb00..cd343d490 100644 --- a/cli/src/commands/run.rs +++ b/cli/src/commands/run.rs @@ -62,8 +62,8 @@ pub fn cmd_run(ui: &mut Ui, command: &CommandHelper, args: &RunArgs) -> Result<( // SAFETY: // We use a internal constant of 4 threads, if it fails - let available = std::thread::available_parallelism() - .unwrap_or(unsafe { NonZeroUsize::new_unchecked(4) }); + let available = + std::thread::available_parallelism().unwrap_or(NonZeroUsize::new(4).unwrap()); available.into() }; Err(user_error("This is a stub, do not use")) diff --git a/lib/src/default_index_store.rs b/lib/src/default_index_store.rs index f66ce864a..4fcbccd07 100644 --- a/lib/src/default_index_store.rs +++ b/lib/src/default_index_store.rs @@ -839,11 +839,8 @@ impl<'a> CompositeIndex<'a> { if pos.0 >= num_parent_commits { self.0.segment_entry_by_pos(pos, pos.0 - num_parent_commits) } else { - let parent_file: &ReadonlyIndexImpl = self.0.segment_parent_file().unwrap().as_ref(); - // The parent ReadonlyIndex outlives the child - let parent_file: &'a ReadonlyIndexImpl = unsafe { std::mem::transmute(parent_file) }; - - CompositeIndex(parent_file).entry_by_pos(pos) + let parent_file = self.0.segment_parent_file().unwrap(); + CompositeIndex(&**parent_file).entry_by_pos(pos) } } diff --git a/lib/src/stacked_table.rs b/lib/src/stacked_table.rs index 698c4f5a0..75c9319f0 100644 --- a/lib/src/stacked_table.rs +++ b/lib/src/stacked_table.rs @@ -51,14 +51,8 @@ pub trait TableSegment { } fn get_value<'a>(&'a self, key: &[u8]) -> Option<&'a [u8]> { - if let Some(value) = self.segment_get_value(key) { - return Some(value); - } - let parent_file = self.segment_parent_file()?; - let parent_file: &ReadonlyTable = parent_file.as_ref(); - // The parent ReadonlyIndex outlives the child - let parent_file: &'a ReadonlyTable = unsafe { std::mem::transmute(parent_file) }; - parent_file.get_value(key) + self.segment_get_value(key) + .or_else(|| self.segment_parent_file()?.get_value(key)) } }