Don't throw away information just to recompute it again
This commit is contained in:
parent
00fcc82df2
commit
8aed75bee0
3 changed files with 22 additions and 26 deletions
|
@ -427,16 +427,14 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
|
|||
obligation.param_env,
|
||||
Binder::dummy(subtype),
|
||||
) {
|
||||
None => {
|
||||
Err((a, b)) => {
|
||||
// None means that both are unresolved.
|
||||
pending_obligation.stalled_on = vec![
|
||||
TyOrConstInferVar::maybe_from_ty(subtype.a).unwrap(),
|
||||
TyOrConstInferVar::maybe_from_ty(subtype.b).unwrap(),
|
||||
];
|
||||
pending_obligation.stalled_on =
|
||||
vec![TyOrConstInferVar::Ty(a), TyOrConstInferVar::Ty(b)];
|
||||
ProcessResult::Unchanged
|
||||
}
|
||||
Some(Ok(ok)) => ProcessResult::Changed(mk_pending(ok.obligations)),
|
||||
Some(Err(err)) => {
|
||||
Ok(Ok(ok)) => ProcessResult::Changed(mk_pending(ok.obligations)),
|
||||
Ok(Err(err)) => {
|
||||
let expected_found =
|
||||
ExpectedFound::new(subtype.a_is_expected, subtype.a, subtype.b);
|
||||
ProcessResult::Error(FulfillmentErrorCode::CodeSubtypeError(
|
||||
|
@ -453,16 +451,14 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
|
|||
obligation.param_env,
|
||||
Binder::dummy(coerce),
|
||||
) {
|
||||
None => {
|
||||
Err((a, b)) => {
|
||||
// None means that both are unresolved.
|
||||
pending_obligation.stalled_on = vec![
|
||||
TyOrConstInferVar::maybe_from_ty(coerce.a).unwrap(),
|
||||
TyOrConstInferVar::maybe_from_ty(coerce.b).unwrap(),
|
||||
];
|
||||
pending_obligation.stalled_on =
|
||||
vec![TyOrConstInferVar::Ty(a), TyOrConstInferVar::Ty(b)];
|
||||
ProcessResult::Unchanged
|
||||
}
|
||||
Some(Ok(ok)) => ProcessResult::Changed(mk_pending(ok.obligations)),
|
||||
Some(Err(err)) => {
|
||||
Ok(Ok(ok)) => ProcessResult::Changed(mk_pending(ok.obligations)),
|
||||
Ok(Err(err)) => {
|
||||
let expected_found = ExpectedFound::new(false, coerce.a, coerce.b);
|
||||
ProcessResult::Error(FulfillmentErrorCode::CodeSubtypeError(
|
||||
expected_found,
|
||||
|
|
|
@ -462,15 +462,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let p = bound_predicate.rebind(p);
|
||||
// Does this code ever run?
|
||||
match self.infcx.subtype_predicate(&obligation.cause, obligation.param_env, p) {
|
||||
Some(Ok(InferOk { mut obligations, .. })) => {
|
||||
Ok(Ok(InferOk { mut obligations, .. })) => {
|
||||
self.add_depth(obligations.iter_mut(), obligation.recursion_depth);
|
||||
self.evaluate_predicates_recursively(
|
||||
previous_stack,
|
||||
obligations.into_iter(),
|
||||
)
|
||||
}
|
||||
Some(Err(_)) => Ok(EvaluatedToErr),
|
||||
None => Ok(EvaluatedToAmbig),
|
||||
Ok(Err(_)) => Ok(EvaluatedToErr),
|
||||
Err(..) => Ok(EvaluatedToAmbig),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -478,15 +478,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
let p = bound_predicate.rebind(p);
|
||||
// Does this code ever run?
|
||||
match self.infcx.coerce_predicate(&obligation.cause, obligation.param_env, p) {
|
||||
Some(Ok(InferOk { mut obligations, .. })) => {
|
||||
Ok(Ok(InferOk { mut obligations, .. })) => {
|
||||
self.add_depth(obligations.iter_mut(), obligation.recursion_depth);
|
||||
self.evaluate_predicates_recursively(
|
||||
previous_stack,
|
||||
obligations.into_iter(),
|
||||
)
|
||||
}
|
||||
Some(Err(_)) => Ok(EvaluatedToErr),
|
||||
None => Ok(EvaluatedToAmbig),
|
||||
Ok(Err(_)) => Ok(EvaluatedToErr),
|
||||
Err(..) => Ok(EvaluatedToAmbig),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue