Replace some thens with some then_somes

This commit is contained in:
Maybe Waffle 2023-02-15 17:39:43 +00:00
parent 8751fa1a9a
commit 5bf6a46032
24 changed files with 27 additions and 26 deletions

View file

@ -771,7 +771,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
.iter()
.chain([&obligation])
.all(|obligation| self.predicate_may_hold(obligation))
.then(|| steps);
.then_some(steps);
may_hold
})

View file

@ -307,7 +307,7 @@ fn predicate_references_self<'tcx>(
match predicate.kind().skip_binder() {
ty::PredicateKind::Clause(ty::Clause::Trait(ref data)) => {
// In the case of a trait predicate, we can skip the "self" type.
data.trait_ref.substs[1..].iter().any(has_self_ty).then(|| sp)
data.trait_ref.substs[1..].iter().any(has_self_ty).then_some(sp)
}
ty::PredicateKind::Clause(ty::Clause::Projection(ref data)) => {
// And similarly for projections. This should be redundant with
@ -325,7 +325,7 @@ fn predicate_references_self<'tcx>(
//
// This is ALT2 in issue #56288, see that for discussion of the
// possible alternatives.
data.projection_ty.substs[1..].iter().any(has_self_ty).then(|| sp)
data.projection_ty.substs[1..].iter().any(has_self_ty).then_some(sp)
}
ty::PredicateKind::AliasEq(..) => bug!("`AliasEq` not allowed as assumption"),

View file

@ -113,7 +113,7 @@ impl<'tcx> ChildrenExt<'tcx> for Children {
// Only report the `Self` type if it has at least
// some outer concrete shell; otherwise, it's
// not adding much information.
self_ty: self_ty.has_concrete_skeleton().then(|| self_ty),
self_ty: self_ty.has_concrete_skeleton().then_some(self_ty),
intercrate_ambiguity_causes: overlap.intercrate_ambiguity_causes,
involves_placeholder: overlap.involves_placeholder,
}