Emit alias-eq when equating numeric var and projection
This commit is contained in:
parent
39f2657d11
commit
3aea46979a
@ -119,20 +119,30 @@ pub fn super_combine_tys<R>(
|
||||
self.unify_float_variable(!a_is_expected, v_id, v)
|
||||
}
|
||||
|
||||
// We don't expect `TyVar` or `Fresh*` vars at this point with lazy norm.
|
||||
(
|
||||
ty::Alias(AliasKind::Projection, _),
|
||||
ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)),
|
||||
)
|
||||
| (
|
||||
ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)),
|
||||
ty::Alias(AliasKind::Projection, _),
|
||||
) if self.tcx.trait_solver_next() => {
|
||||
bug!()
|
||||
}
|
||||
|
||||
(_, ty::Alias(AliasKind::Projection, _)) | (ty::Alias(AliasKind::Projection, _), _)
|
||||
if self.tcx.trait_solver_next() =>
|
||||
{
|
||||
relation.register_type_equate_obligation(a, b);
|
||||
Ok(a)
|
||||
}
|
||||
|
||||
// All other cases of inference are errors
|
||||
(&ty::Infer(_), _) | (_, &ty::Infer(_)) => {
|
||||
Err(TypeError::Sorts(ty::relate::expected_found(relation, a, b)))
|
||||
}
|
||||
|
||||
(ty::Alias(AliasKind::Projection, _), _) if self.tcx.trait_solver_next() => {
|
||||
relation.register_type_equate_obligation(a, b);
|
||||
Ok(b)
|
||||
}
|
||||
(_, ty::Alias(AliasKind::Projection, _)) if self.tcx.trait_solver_next() => {
|
||||
relation.register_type_equate_obligation(b, a);
|
||||
Ok(a)
|
||||
}
|
||||
|
||||
_ => ty::relate::super_relate_tys(relation, a, b),
|
||||
}
|
||||
}
|
||||
|
@ -995,7 +995,7 @@ pub fn to_alias_term_no_opaque(&self, tcx: TyCtxt<'tcx>) -> Option<AliasTy<'tcx>
|
||||
|
||||
pub fn is_infer(&self) -> bool {
|
||||
match self.unpack() {
|
||||
TermKind::Ty(ty) => ty.is_ty_or_numeric_infer(),
|
||||
TermKind::Ty(ty) => ty.is_ty_var(),
|
||||
TermKind::Const(ct) => ct.is_ct_infer(),
|
||||
}
|
||||
}
|
||||
|
18
tests/ui/traits/new-solver/int-var-alias-eq.rs
Normal file
18
tests/ui/traits/new-solver/int-var-alias-eq.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// check-pass
|
||||
// compile-flags: -Ztrait-solver=next
|
||||
|
||||
// HIR typeck ends up equating `<_#0i as Add>::Output == _#0i`.
|
||||
// Want to make sure that we emit an alias-eq goal for this,
|
||||
// instead of treating it as a type error and bailing.
|
||||
|
||||
fn test() {
|
||||
// fallback
|
||||
let x = 1 + 2;
|
||||
}
|
||||
|
||||
fn test2() -> u32 {
|
||||
// expectation from return ty
|
||||
1 + 2
|
||||
}
|
||||
|
||||
fn main() {}
|
Loading…
Reference in New Issue
Block a user