Pre-populate MIR with opaques, prefer subst-relate candidate
This commit is contained in:
parent
e3f8beaed6
commit
a2d806d56d
3 changed files with 86 additions and 27 deletions
|
@ -239,34 +239,34 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
|
|||
evaluate_normalizes_to(self, alias_rhs, lhs, direction, Invert::Yes).ok(),
|
||||
);
|
||||
// Relate via substs
|
||||
candidates.extend(
|
||||
self.probe(|ecx| {
|
||||
let span = tracing::span!(
|
||||
tracing::Level::DEBUG,
|
||||
"compute_alias_relate_goal(relate_via_substs)",
|
||||
?alias_lhs,
|
||||
?alias_rhs,
|
||||
?direction
|
||||
);
|
||||
let _enter = span.enter();
|
||||
let subst_relate_response = self.probe(|ecx| {
|
||||
let span = tracing::span!(
|
||||
tracing::Level::DEBUG,
|
||||
"compute_alias_relate_goal(relate_via_substs)",
|
||||
?alias_lhs,
|
||||
?alias_rhs,
|
||||
?direction
|
||||
);
|
||||
let _enter = span.enter();
|
||||
|
||||
match direction {
|
||||
ty::AliasRelationDirection::Equate => {
|
||||
ecx.eq(goal.param_env, alias_lhs, alias_rhs)?;
|
||||
}
|
||||
ty::AliasRelationDirection::Subtype => {
|
||||
ecx.sub(goal.param_env, alias_lhs, alias_rhs)?;
|
||||
}
|
||||
match direction {
|
||||
ty::AliasRelationDirection::Equate => {
|
||||
ecx.eq(goal.param_env, alias_lhs, alias_rhs)?;
|
||||
}
|
||||
ty::AliasRelationDirection::Subtype => {
|
||||
ecx.sub(goal.param_env, alias_lhs, alias_rhs)?;
|
||||
}
|
||||
}
|
||||
|
||||
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
|
||||
})
|
||||
.ok(),
|
||||
);
|
||||
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
|
||||
});
|
||||
candidates.extend(subst_relate_response);
|
||||
debug!(?candidates);
|
||||
|
||||
if let Some(merged) = self.try_merge_responses(&candidates) {
|
||||
Ok(merged)
|
||||
} else if let Ok(subst_relate_response) = subst_relate_response {
|
||||
Ok(subst_relate_response)
|
||||
} else {
|
||||
self.flounder(&candidates)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use rustc_middle::traits::query::NoSolution;
|
||||
use rustc_middle::traits::solve::{Certainty, Goal, QueryResult};
|
||||
use rustc_middle::traits::{ObligationCause, Reveal};
|
||||
use rustc_middle::traits::Reveal;
|
||||
use rustc_middle::ty;
|
||||
use rustc_middle::ty::util::NotUniqueParam;
|
||||
|
||||
|
@ -37,11 +37,8 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||
Ok(()) => {}
|
||||
}
|
||||
// Prefer opaques registered already.
|
||||
let matches = self.unify_existing_opaque_tys(
|
||||
goal.param_env,
|
||||
opaque_ty,
|
||||
expected
|
||||
);
|
||||
let matches =
|
||||
self.unify_existing_opaque_tys(goal.param_env, opaque_ty, expected);
|
||||
if !matches.is_empty() {
|
||||
if let Some(response) = self.try_merge_responses(&matches) {
|
||||
return Ok(response);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue