Use Option::is_some_and and Result::is_ok_and in the compiler
This commit is contained in:
@@ -351,7 +351,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
}
|
||||
|
||||
let popped = this.block_context.pop();
|
||||
assert!(popped.map_or(false, |bf| bf.is_statement()));
|
||||
assert!(popped.is_some_and(|bf| bf.is_statement()));
|
||||
}
|
||||
|
||||
// Then, the block may have an optional trailing expression which is a “return” value
|
||||
@@ -367,7 +367,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
unpack!(block = this.expr_into_dest(destination, block, expr));
|
||||
let popped = this.block_context.pop();
|
||||
|
||||
assert!(popped.map_or(false, |bf| bf.is_tail_expr()));
|
||||
assert!(popped.is_some_and(|bf| bf.is_tail_expr()));
|
||||
} else {
|
||||
// If a block has no trailing expression, then it is given an implicit return type.
|
||||
// This return type is usually `()`, unless the block is diverging, in which case the
|
||||
|
||||
@@ -325,10 +325,10 @@ impl DropTree {
|
||||
entry_points.sort();
|
||||
|
||||
for (drop_idx, drop_data) in self.drops.iter_enumerated().rev() {
|
||||
if entry_points.last().map_or(false, |entry_point| entry_point.0 == drop_idx) {
|
||||
if entry_points.last().is_some_and(|entry_point| entry_point.0 == drop_idx) {
|
||||
let block = *blocks[drop_idx].get_or_insert_with(|| T::make_block(cfg));
|
||||
needs_block[drop_idx] = Block::Own;
|
||||
while entry_points.last().map_or(false, |entry_point| entry_point.0 == drop_idx) {
|
||||
while entry_points.last().is_some_and(|entry_point| entry_point.0 == drop_idx) {
|
||||
let entry_block = entry_points.pop().unwrap().1;
|
||||
T::add_entry(cfg, entry_block, block);
|
||||
}
|
||||
@@ -731,7 +731,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
fn leave_top_scope(&mut self, block: BasicBlock) -> BasicBlock {
|
||||
// If we are emitting a `drop` statement, we need to have the cached
|
||||
// diverge cleanup pads ready in case that drop panics.
|
||||
let needs_cleanup = self.scopes.scopes.last().map_or(false, |scope| scope.needs_cleanup());
|
||||
let needs_cleanup = self.scopes.scopes.last().is_some_and(|scope| scope.needs_cleanup());
|
||||
let is_generator = self.generator_kind.is_some();
|
||||
let unwind_to = if needs_cleanup { self.diverge_cleanup() } else { DropIdx::MAX };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user