Auto merge of #121462 - compiler-errors:eq-and-sub, r=lcnr
Combine `Sub` and `Equate` Combine `Sub` and `Equate` into a new relation called `TypeRelating` (that name sounds familiar...) Tracks the difference between `Sub` and `Equate` via `ambient_variance: ty::Variance` much like the `NllTypeRelating` relation, but implemented slightly jankier because it's a more general purpose relation. r? lcnr
This commit is contained in:
commit
b0696a5160
28 changed files with 510 additions and 841 deletions
|
@ -904,7 +904,6 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||
&ObligationCause::dummy(),
|
||||
param_env,
|
||||
hidden_ty,
|
||||
true,
|
||||
&mut obligations,
|
||||
)?;
|
||||
self.add_goals(GoalSource::Misc, obligations.into_iter().map(|o| o.into()));
|
||||
|
|
|
@ -116,24 +116,6 @@ impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> {
|
|||
self.infcx.at(cause, param_env).deeply_normalize(value, &mut **self.engine.borrow_mut())
|
||||
}
|
||||
|
||||
/// Makes `expected <: actual`.
|
||||
pub fn eq_exp<T>(
|
||||
&self,
|
||||
cause: &ObligationCause<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
a_is_expected: bool,
|
||||
a: T,
|
||||
b: T,
|
||||
) -> Result<(), TypeError<'tcx>>
|
||||
where
|
||||
T: ToTrace<'tcx>,
|
||||
{
|
||||
self.infcx
|
||||
.at(cause, param_env)
|
||||
.eq_exp(DefineOpaqueTypes::Yes, a_is_expected, a, b)
|
||||
.map(|infer_ok| self.register_infer_ok_obligations(infer_ok))
|
||||
}
|
||||
|
||||
pub fn eq<T: ToTrace<'tcx>>(
|
||||
&self,
|
||||
cause: &ObligationCause<'tcx>,
|
||||
|
|
|
@ -1528,6 +1528,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
| ObligationCauseCode::Coercion { .. }
|
||||
);
|
||||
|
||||
let (expected, actual) = if is_normalized_term_expected {
|
||||
(normalized_term, data.term)
|
||||
} else {
|
||||
(data.term, normalized_term)
|
||||
};
|
||||
|
||||
// constrain inference variables a bit more to nested obligations from normalize so
|
||||
// we can have more helpful errors.
|
||||
//
|
||||
|
@ -1535,13 +1541,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
// since the normalization is just done to improve the error message.
|
||||
let _ = ocx.select_where_possible();
|
||||
|
||||
if let Err(new_err) = ocx.eq_exp(
|
||||
&obligation.cause,
|
||||
obligation.param_env,
|
||||
is_normalized_term_expected,
|
||||
normalized_term,
|
||||
data.term,
|
||||
) {
|
||||
if let Err(new_err) =
|
||||
ocx.eq(&obligation.cause, obligation.param_env, expected, actual)
|
||||
{
|
||||
(Some((data, is_normalized_term_expected, normalized_term, data.term)), new_err)
|
||||
} else {
|
||||
(None, error.err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue