Skip to content

Commit 6c1df36

Browse files
committed
rustc_hir: flatten nested ifs
1 parent 8aba730 commit 6c1df36

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

compiler/rustc_hir/src/hir.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -3531,10 +3531,10 @@ impl<'hir> FnRetTy<'hir> {
35313531
}
35323532

35333533
pub fn is_suggestable_infer_ty(&self) -> Option<&'hir Ty<'hir>> {
3534-
if let Self::Return(ty) = self {
3535-
if ty.is_suggestable_infer_ty() {
3536-
return Some(*ty);
3537-
}
3534+
if let Self::Return(ty) = self
3535+
&& ty.is_suggestable_infer_ty()
3536+
{
3537+
return Some(*ty);
35383538
}
35393539
None
35403540
}
@@ -4409,16 +4409,14 @@ impl<'hir> Node<'hir> {
44094409

44104410
/// Get a `hir::Impl` if the node is an impl block for the given `trait_def_id`.
44114411
pub fn impl_block_of_trait(self, trait_def_id: DefId) -> Option<&'hir Impl<'hir>> {
4412-
match self {
4413-
Node::Item(Item { kind: ItemKind::Impl(impl_block), .. })
4414-
if impl_block
4415-
.of_trait
4416-
.and_then(|trait_ref| trait_ref.trait_def_id())
4417-
.is_some_and(|trait_id| trait_id == trait_def_id) =>
4418-
{
4419-
Some(impl_block)
4420-
}
4421-
_ => None,
4412+
if let Node::Item(Item { kind: ItemKind::Impl(impl_block), .. }) = self
4413+
&& let Some(trait_ref) = impl_block.of_trait
4414+
&& let Some(trait_id) = trait_ref.trait_def_id()
4415+
&& trait_id == trait_def_id
4416+
{
4417+
Some(impl_block)
4418+
} else {
4419+
None
44224420
}
44234421
}
44244422

0 commit comments

Comments
 (0)