Skip to content

Commit

Permalink
Use option combinators instead of manual if/return
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Jan 9, 2025
1 parent 8505904 commit 84c8d4f
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2262,18 +2262,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
_ => None,
};

if let Some(lit_input) = lit_input {
// If an error occurred, ignore that it's a literal and leave reporting the error up to
// mir.

lit_input
// Allow the `ty` to be an alias type, though we cannot handle it here, we just go through
// the more expensive anon const code path.
if !lit_input.ty.has_aliases() {
return Some(tcx.at(expr.span).lit_to_const(lit_input));
}
}

None
.filter(|l| !l.ty.has_aliases())
.map(|l| tcx.at(expr.span).lit_to_const(l))
}

fn lower_delegation_ty(&self, idx: hir::InferDelegationKind) -> Ty<'tcx> {
Expand Down

0 comments on commit 84c8d4f

Please sign in to comment.