chore: satisfy clippy::unnecessary_map_or in Rust 1.85

This commit is contained in:
Erich Gubler committed 2025-02-26 22:58:50 -05:00
1 parent 4200136e2c
commit f234ff27ab
4 files changed
+5 -7

No files matched your search

+1 -2
View File
@@ -2203,8 +2203,7 @@ impl<'a, W: Write> Writer<'a, W> {
self.write_stmt(sta, ctx, l2.next())?;
}
if !case.fall_through
&& case.body.last().map_or(true, |s| !s.is_terminator())
if !case.fall_through && case.body.last().is_none_or(|s| !s.is_terminator())
{
writeln!(self.out, "{}break;", l2.next())?;
}
+2 -2
View File
@@ -1715,14 +1715,14 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
}
let last_case = &cases[end_case_idx];
if last_case.body.last().map_or(true, |s| !s.is_terminator()) {
if last_case.body.last().is_none_or(|s| !s.is_terminator()) {
writeln!(self.out, "{indent_level_2}break;")?;
}
} else {
for sta in case.body.iter() {
self.write_stmt(module, sta, func_ctx, indent_level_2)?;
}
if !case.fall_through && case.body.last().map_or(true, |s| !s.is_terminator()) {
if !case.fall_through && case.body.last().is_none_or(|s| !s.is_terminator()) {
writeln!(self.out, "{indent_level_2}break;")?;
}
}
+1 -2
View File
@@ -3223,8 +3223,7 @@ impl<W: Write> Writer<W> {
}
self.put_block(lcase.next(), &case.body, context)?;
if !case.fall_through
&& case.body.last().map_or(true, |s| !s.is_terminator())
if !case.fall_through && case.body.last().is_none_or(|s| !s.is_terminator())
{
writeln!(self.out, "{}break;", lcase.next())?;
}
+1 -1
View File
@@ -643,7 +643,7 @@ impl BlockContext<'_> {
let body = lower_impl(blocks, bodies, body_idx);
// Handle simple cases that would make a fallthrough statement unreachable code
let fall_through = body.last().map_or(true, |s| !s.is_terminator());
let fall_through = body.last().is_none_or(|s| !s.is_terminator());
crate::SwitchCase {
value: crate::SwitchValue::I32(value),