Skip to content

Commit 2a25b28

Browse files
Add TyKind::TyAlias support in rustc_infer
1 parent ed3f028 commit 2a25b28

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,8 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
456456
| ty::Projection(..)
457457
| ty::Foreign(..)
458458
| ty::Param(..)
459-
| ty::Opaque(..) => {
459+
| ty::Opaque(..)
460+
| ty::TyAlias(..) => {
460461
if t.flags().intersects(self.needs_canonical_flags) {
461462
t.super_fold_with(self)
462463
} else {

compiler/rustc_infer/src/infer/freshen.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
210210
| ty::Param(..)
211211
| ty::Closure(..)
212212
| ty::GeneratorWitness(..)
213-
| ty::Opaque(..) => t.super_fold_with(self),
213+
| ty::Opaque(..)
214+
| ty::TyAlias(..) => t.super_fold_with(self),
214215

215216
ty::Placeholder(..) | ty::Bound(..) => bug!("unexpected type {:?}", t),
216217
}

compiler/rustc_infer/src/infer/opaque_types.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<'tcx> InferCtxt<'tcx> {
5252
span: Span,
5353
param_env: ty::ParamEnv<'tcx>,
5454
) -> InferOk<'tcx, T> {
55-
if !value.has_opaque_types() {
55+
if !value.has_opaque_types() && !value.has_ty_alias() {
5656
return InferOk { value, obligations: vec![] };
5757
}
5858
let mut obligations = vec![];
@@ -61,7 +61,7 @@ impl<'tcx> InferCtxt<'tcx> {
6161
.as_local()
6262
.map_or(false, |def_id| self.opaque_type_origin(def_id, span).is_some())
6363
};
64-
let value = value.fold_with(&mut ty::fold::BottomUpFolder {
64+
let value = self.tcx.peel_off_ty_alias(value).fold_with(&mut ty::fold::BottomUpFolder {
6565
tcx: self.tcx,
6666
lt_op: |lt| lt,
6767
ct_op: |ct| ct,
@@ -548,6 +548,9 @@ impl<'tcx> InferCtxt<'tcx> {
548548
let item_bounds = tcx.bound_explicit_item_bounds(def_id.to_def_id());
549549

550550
for (predicate, _) in item_bounds.subst_iter_copied(tcx, substs) {
551+
debug!(?predicate);
552+
let predicate = tcx.peel_off_ty_alias(predicate);
553+
551554
let predicate = predicate.fold_with(&mut BottomUpFolder {
552555
tcx,
553556
ty_op: |ty| match *ty.kind() {

compiler/rustc_infer/src/infer/outlives/components.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ fn compute_components<'tcx>(
169169
out.push(Component::UnresolvedInferenceVariable(infer_ty));
170170
}
171171

172+
ty::TyAlias(def_id, _) => {
173+
compute_components(tcx, tcx.type_of(def_id), out, visited);
174+
}
175+
172176
// Most types do not introduce any region binders, nor
173177
// involve any other subtle cases, and so the WF relation
174178
// simply constraints any regions referenced directly by

0 commit comments

Comments
 (0)