1
Fork 0

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:
est31 2021-10-16 03:45:14 +02:00
parent c1026539bd
commit 1418df5888
51 changed files with 69 additions and 137 deletions

View file

@ -315,9 +315,7 @@ impl<'a, 'tcx> GatherBorrows<'a, 'tcx> {
// TEMP = &foo
//
// so extract `temp`.
let temp = if let Some(temp) = assigned_place.as_local() {
temp
} else {
let Some(temp) = assigned_place.as_local() else {
span_bug!(
self.body.source_info(start_location).span,
"expected 2-phase borrow to assign to a local, not `{:?}`",

View file

@ -90,9 +90,7 @@ impl OutlivesSuggestionBuilder {
let mut unified_already = FxHashSet::default();
for (fr, outlived) in &self.constraints_to_add {
let fr_name = if let Some(fr_name) = self.region_vid_to_name(mbcx, *fr) {
fr_name
} else {
let Some(fr_name) = self.region_vid_to_name(mbcx, *fr) else {
continue;
};

View file

@ -7,6 +7,7 @@
#![feature(format_args_capture)]
#![feature(in_band_lifetimes)]
#![feature(iter_zip)]
#![feature(let_else)]
#![feature(min_specialization)]
#![feature(stmt_expr_attributes)]
#![feature(trusted_step)]