Rollup merge of #121002 - lcnr:cleanup-commit_if_ok, r=oli-obk

remove unnecessary calls to `commit_if_ok`

we propagate the error outwards, so anything which wants to discard the error should do so itself.

r? types
This commit is contained in:
Matthias Krüger 2024-02-13 22:51:55 +01:00 committed by GitHub
commit 147fd3f236
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 59 additions and 69 deletions

View file

@ -192,13 +192,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
&mut obligations,
);
obligations.extend(self.infcx.commit_if_ok(|_| {
obligations.extend(
self.infcx
.at(&obligation.cause, obligation.param_env)
.sup(DefineOpaqueTypes::No, placeholder_trait_predicate, candidate)
.map(|InferOk { obligations, .. }| obligations)
.map_err(|_| Unimplemented)
})?);
.map_err(|_| Unimplemented)?,
);
// FIXME(compiler-errors): I don't think this is needed.
if let ty::Alias(ty::Projection, alias_ty) = placeholder_self_ty.kind() {
@ -532,13 +532,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
&mut nested,
);
nested.extend(self.infcx.commit_if_ok(|_| {
nested.extend(
self.infcx
.at(&obligation.cause, obligation.param_env)
.sup(DefineOpaqueTypes::No, obligation_trait_ref, upcast_trait_ref)
.map(|InferOk { obligations, .. }| obligations)
.map_err(|_| Unimplemented)
})?);
.map_err(|_| Unimplemented)?,
);
// Check supertraits hold. This is so that their associated type bounds
// will be checked in the code below.