lint: convert is_some+unwrap into if let

This fixes an `unnecessary_unwrap` lint shown by nightly Clippy.

Closes #12130
This commit is contained in:
Daniel Rainer
2025-12-03 00:14:14 +01:00
committed by Johannes Altmanninger
parent 07389055f1
commit 75c005a4d4
3 changed files with 29 additions and 24 deletions

View File

@@ -515,12 +515,14 @@ fn throwing_main() -> i32 {
parser.set_last_statuses(Statuses::just(STATUS_CMD_OK));
// TODO: if-let-chains
if opts.profile_startup_output.is_some() && opts.profile_startup_output != opts.profile_output {
parser.emit_profiling(&opts.profile_startup_output.unwrap());
if let Some(path) = &opts.profile_startup_output {
if opts.profile_startup_output != opts.profile_output {
parser.emit_profiling(path);
// If we are profiling both, ensure the startup data only
// ends up in the startup file.
parser.clear_profiling();
// If we are profiling both, ensure the startup data only
// ends up in the startup file.
parser.clear_profiling();
}
}
PROFILING_ACTIVE.store(opts.profile_output.is_some());

View File

@@ -415,9 +415,9 @@ fn timestamp_now(&self) -> SystemTime {
/// Loads old items if necessary.
/// Return a reference to the loaded history file.
fn load_old_if_needed(&mut self) -> &HistoryFile {
if self.file_contents.is_some() {
return self.file_contents.as_ref().unwrap();
};
if let Some(ref file_contents) = self.file_contents {
return file_contents;
}
let Ok(Some(history_path)) = self.history_file_path() else {
return self.file_contents.insert(HistoryFile::create_empty());
};

View File

@@ -1800,23 +1800,26 @@ fn paint_layout(&mut self, reason: &wstr, is_final_rendering: bool) {
let mut colors = data.colors.clone();
// Highlight any history search.
if !self.conf.in_silent_mode && data.history_search_range.is_some() {
let mut range = data.history_search_range.unwrap().as_usize();
if range.end > colors.len() {
range.start = range.start.min(colors.len());
range.end = colors.len();
}
let explicit_foreground = self
.vars()
.get_unless_empty(L!("fish_color_search_match"))
.is_some_and(|var| parse_text_face(var.as_list()).fg.is_some());
for color in &mut colors[range] {
if explicit_foreground {
color.foreground = HighlightRole::search_match;
if let Some(range) = data.history_search_range {
// TODO(MSRV>=1.88): let chain
if !self.conf.in_silent_mode {
let mut range = range.as_usize();
if range.end > colors.len() {
range.start = range.start.min(colors.len());
range.end = colors.len();
}
let explicit_foreground = self
.vars()
.get_unless_empty(L!("fish_color_search_match"))
.is_some_and(|var| parse_text_face(var.as_list()).fg.is_some());
for color in &mut colors[range] {
if explicit_foreground {
color.foreground = HighlightRole::search_match;
}
color.background = HighlightRole::search_match;
}
color.background = HighlightRole::search_match;
}
}