Adopt let_else across the compiler
This performs a substitution of code following the pattern: let <id> = if let <pat> = ... { identity } else { ... : ! }; To simplify it to: let <pat> = ... { identity } else { ... : ! }; By adopting the let_else feature.
This commit is contained in:
parent
c1026539bd
commit
1418df5888
51 changed files with 69 additions and 137 deletions
|
@ -673,9 +673,7 @@ impl Inliner<'tcx> {
|
|||
assert!(args.next().is_none());
|
||||
|
||||
let tuple = Place::from(tuple);
|
||||
let tuple_tys = if let ty::Tuple(s) = tuple.ty(caller_body, tcx).ty.kind() {
|
||||
s
|
||||
} else {
|
||||
let ty::Tuple(tuple_tys) = tuple.ty(caller_body, tcx).ty.kind() else {
|
||||
bug!("Closure arguments are not passed as a tuple");
|
||||
};
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#![cfg_attr(bootstrap, feature(const_panic))]
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(let_else)]
|
||||
#![feature(map_try_insert)]
|
||||
#![feature(min_specialization)]
|
||||
#![feature(option_get_or_insert_default)]
|
||||
|
|
|
@ -17,9 +17,7 @@ impl<'tcx> MirPass<'tcx> for LowerSliceLenCalls {
|
|||
|
||||
pub fn lower_slice_len_calls<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||
let language_items = tcx.lang_items();
|
||||
let slice_len_fn_item_def_id = if let Some(slice_len_fn_item) = language_items.slice_len_fn() {
|
||||
slice_len_fn_item
|
||||
} else {
|
||||
let Some(slice_len_fn_item_def_id) = language_items.slice_len_fn() else {
|
||||
// there is no language item to compare to :)
|
||||
return;
|
||||
};
|
||||
|
|
|
@ -208,7 +208,7 @@ fn normalize_array_len_call<'tcx>(
|
|||
operand,
|
||||
cast_ty,
|
||||
) => {
|
||||
let local = if let Some(local) = place.as_local() { local } else { return };
|
||||
let Some(local) = place.as_local() else { return };
|
||||
match operand {
|
||||
Operand::Copy(place) | Operand::Move(place) => {
|
||||
let operand_local =
|
||||
|
@ -255,9 +255,7 @@ fn normalize_array_len_call<'tcx>(
|
|||
}
|
||||
}
|
||||
Rvalue::Len(place) => {
|
||||
let local = if let Some(local) = place.local_or_deref_local() {
|
||||
local
|
||||
} else {
|
||||
let Some(local) = place.local_or_deref_local() else {
|
||||
return;
|
||||
};
|
||||
if let Some(cast_statement_idx) = state.get(&local).copied() {
|
||||
|
|
|
@ -83,12 +83,9 @@ impl<'tcx> MirPass<'tcx> for UninhabitedEnumBranching {
|
|||
let bb = BasicBlock::from_usize(bb);
|
||||
trace!("processing block {:?}", bb);
|
||||
|
||||
let discriminant_ty =
|
||||
if let Some(ty) = get_switched_on_type(&body.basic_blocks()[bb], tcx, body) {
|
||||
ty
|
||||
} else {
|
||||
continue;
|
||||
};
|
||||
let Some(discriminant_ty) = get_switched_on_type(&body.basic_blocks()[bb], tcx, body) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let layout = tcx.layout_of(tcx.param_env(body.source.def_id()).and(discriminant_ty));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue