Use let
/else
to de-indent ElaborateBoxDerefs::run_pass
.
This commit is contained in:
parent
cc09ab3c75
commit
181fbd5ce8
1 changed files with 39 additions and 42 deletions
|
@ -92,11 +92,12 @@ pub(super) struct ElaborateBoxDerefs;
|
|||
|
||||
impl<'tcx> crate::MirPass<'tcx> for ElaborateBoxDerefs {
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||
if let Some(def_id) = tcx.lang_items().owned_box() {
|
||||
// If box is not present, this pass doesn't need to do anything.
|
||||
let Some(def_id) = tcx.lang_items().owned_box() else { return };
|
||||
|
||||
let unique_did = tcx.adt_def(def_id).non_enum_variant().fields[FieldIdx::ZERO].did;
|
||||
|
||||
let Some(nonnull_def) = tcx.type_of(unique_did).instantiate_identity().ty_adt_def()
|
||||
else {
|
||||
let Some(nonnull_def) = tcx.type_of(unique_did).instantiate_identity().ty_adt_def() else {
|
||||
span_bug!(tcx.def_span(unique_did), "expected Box to contain Unique")
|
||||
};
|
||||
|
||||
|
@ -132,9 +133,8 @@ impl<'tcx> crate::MirPass<'tcx> for ElaborateBoxDerefs {
|
|||
let (unique_ty, nonnull_ty, ptr_ty) =
|
||||
build_ptr_tys(tcx, boxed_ty, unique_did, nonnull_did);
|
||||
|
||||
new_projections.extend_from_slice(&build_projection(
|
||||
unique_ty, nonnull_ty, ptr_ty,
|
||||
));
|
||||
new_projections
|
||||
.extend_from_slice(&build_projection(unique_ty, nonnull_ty, ptr_ty));
|
||||
new_projections.push(PlaceElem::Deref);
|
||||
} else if let Some(new_projections) = new_projections.as_mut() {
|
||||
// Keep building up our projections list once we've started it.
|
||||
|
@ -148,8 +148,5 @@ impl<'tcx> crate::MirPass<'tcx> for ElaborateBoxDerefs {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// box is not present, this pass doesn't need to do anything
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue