Rollup merge of #118915 - compiler-errors:alias-nits, r=lcnr
Add some comments, add `can_define_opaque_ty` check to `try_normalize_ty_recur` Follow-up from #117278, since I was recently re-reviewing this code.
This commit is contained in:
commit
859874f3eb
8 changed files with 65 additions and 45 deletions
|
@ -2348,11 +2348,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
GenericKind::Param(ref p) => format!("the parameter type `{p}`"),
|
||||
GenericKind::Placeholder(ref p) => format!("the placeholder type `{p:?}`"),
|
||||
GenericKind::Alias(ref p) => match p.kind(self.tcx) {
|
||||
ty::AliasKind::Projection | ty::AliasKind::Inherent => {
|
||||
ty::Projection | ty::Inherent => {
|
||||
format!("the associated type `{p}`")
|
||||
}
|
||||
ty::AliasKind::Weak => format!("the type alias `{p}`"),
|
||||
ty::AliasKind::Opaque => format!("the opaque type `{p}`"),
|
||||
ty::Weak => format!("the type alias `{p}`"),
|
||||
ty::Opaque => format!("the opaque type `{p}`"),
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -510,7 +510,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
|
|||
));
|
||||
} else {
|
||||
match a_ty.kind() {
|
||||
&ty::Alias(ty::AliasKind::Projection, data) => {
|
||||
&ty::Alias(ty::Projection, data) => {
|
||||
// FIXME: This does not handle subtyping correctly, we could
|
||||
// instead create a new inference variable for `a_ty`, emitting
|
||||
// `Projection(a_ty, a_infer)` and `a_infer <: b_ty`.
|
||||
|
@ -522,10 +522,9 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
|
|||
))
|
||||
}
|
||||
// The old solver only accepts projection predicates for associated types.
|
||||
ty::Alias(
|
||||
ty::AliasKind::Inherent | ty::AliasKind::Weak | ty::AliasKind::Opaque,
|
||||
_,
|
||||
) => return Err(TypeError::CyclicTy(a_ty)),
|
||||
ty::Alias(ty::Inherent | ty::Weak | ty::Opaque, _) => {
|
||||
return Err(TypeError::CyclicTy(a_ty));
|
||||
}
|
||||
_ => bug!("generalizated `{a_ty:?} to infer, not an alias"),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue