1
Fork 0

Auto merge of #99509 - lcnr:commit_unconditionally, r=jackh726

remove `commit_unconditionally`

`commit_unconditionally` is a noop unless we somehow inspect the current state of our snapshot. The only thing which does that is the leak check which was only used in one place where `commit_if_ok` is probably at least as, or even more, correct.

r? rust-lang/types
This commit is contained in:
bors 2022-08-03 01:55:20 +00:00
commit b759b2efad
4 changed files with 164 additions and 195 deletions

View file

@ -2084,30 +2084,28 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
.flat_map(|ty| {
let ty: ty::Binder<'tcx, Ty<'tcx>> = types.rebind(*ty); // <----/
self.infcx.commit_unconditionally(|_| {
let placeholder_ty = self.infcx.replace_bound_vars_with_placeholders(ty);
let Normalized { value: normalized_ty, mut obligations } =
ensure_sufficient_stack(|| {
project::normalize_with_depth(
self,
param_env,
cause.clone(),
recursion_depth,
placeholder_ty,
)
});
let placeholder_obligation = predicate_for_trait_def(
self.tcx(),
param_env,
cause.clone(),
trait_def_id,
recursion_depth,
normalized_ty,
&[],
);
obligations.push(placeholder_obligation);
obligations
})
let placeholder_ty = self.infcx.replace_bound_vars_with_placeholders(ty);
let Normalized { value: normalized_ty, mut obligations } =
ensure_sufficient_stack(|| {
project::normalize_with_depth(
self,
param_env,
cause.clone(),
recursion_depth,
placeholder_ty,
)
});
let placeholder_obligation = predicate_for_trait_def(
self.tcx(),
param_env,
cause.clone(),
trait_def_id,
recursion_depth,
normalized_ty,
&[],
);
obligations.push(placeholder_obligation);
obligations
})
.collect()
}