Adopt let else in more places

This commit is contained in:
est31
2022-02-19 00:48:49 +01:00
parent b8c56fa8c3
commit 2ef8af6619
132 changed files with 539 additions and 881 deletions

View File

@@ -1582,12 +1582,9 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
def_id: DefId,
span: Span,
) {
let variants = match self.collect_enum_ctors(def_id) {
Some(variants) => variants,
None => {
err.note("you might have meant to use one of the enum's variants");
return;
}
let Some(variants) = self.collect_enum_ctors(def_id) else {
err.note("you might have meant to use one of the enum's variants");
return;
};
let suggest_only_tuple_variants =

View File

@@ -1748,10 +1748,7 @@ fn object_lifetime_defaults_for_item<'tcx>(
let param_def_id = tcx.hir().local_def_id(param.hir_id);
for predicate in generics.where_clause.predicates {
// Look for `type: ...` where clauses.
let data = match *predicate {
hir::WherePredicate::BoundPredicate(ref data) => data,
_ => continue,
};
let hir::WherePredicate::BoundPredicate(ref data) = *predicate else { continue };
// Ignore `for<'a> type: ...` as they can change what
// lifetimes mean (although we could "just" handle it).
@@ -1976,12 +1973,9 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
}
fn check_uses_for_lifetimes_defined_by_scope(&mut self) {
let defined_by = match self.scope {
Scope::Binder { lifetimes, .. } => lifetimes,
_ => {
debug!("check_uses_for_lifetimes_defined_by_scope: not in a binder scope");
return;
}
let Scope::Binder { lifetimes: defined_by, .. } = self.scope else {
debug!("check_uses_for_lifetimes_defined_by_scope: not in a binder scope");
return;
};
let def_ids: Vec<_> = defined_by
@@ -2636,9 +2630,8 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
smallvec![(def_id, smallvec![])];
let mut visited: FxHashSet<DefId> = FxHashSet::default();
loop {
let (def_id, bound_vars) = match stack.pop() {
Some(next) => next,
None => break None,
let Some((def_id, bound_vars)) = stack.pop() else {
break None;
};
// See issue #83753. If someone writes an associated type on a non-trait, just treat it as
// there being no supertrait HRTBs.
@@ -2723,10 +2716,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
}
});
let output = match output {
Some(ty) => ty,
None => return,
};
let Some(output) = output else { return };
debug!("determine output");