Skip to content

Commit ba2072b

Browse files
committed
Subtype predicates only exist on inference types, so we can allow them to register opaque types within them.
1 parent 0230848 commit ba2072b

File tree

1 file changed

+8
-2
lines changed
  • compiler/rustc_infer/src/infer

1 file changed

+8
-2
lines changed

compiler/rustc_infer/src/infer/mod.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -945,14 +945,20 @@ impl<'tcx> InferCtxt<'tcx> {
945945
(&ty::Infer(ty::TyVar(a_vid)), &ty::Infer(ty::TyVar(b_vid))) => {
946946
return Err((a_vid, b_vid));
947947
}
948+
(ty::Alias(ty::Opaque, ..), ty::Infer(ty::TyVar(_)))
949+
| (ty::Infer(ty::TyVar(_)), ty::Alias(ty::Opaque, ..)) => {}
950+
(ty::Alias(ty::Opaque, ..), _) | (_, ty::Alias(ty::Opaque, ..)) => span_bug!(
951+
cause.span(),
952+
"opaque types got hidden types registered from within subtype predicate: {r_a:?} vs {r_b:?}"
953+
),
948954
_ => {}
949955
}
950956

951957
self.enter_forall(predicate, |ty::SubtypePredicate { a_is_expected, a, b }| {
952958
if a_is_expected {
953-
Ok(self.at(cause, param_env).sub(DefineOpaqueTypes::No, a, b))
959+
Ok(self.at(cause, param_env).sub(DefineOpaqueTypes::Yes, a, b))
954960
} else {
955-
Ok(self.at(cause, param_env).sup(DefineOpaqueTypes::No, b, a))
961+
Ok(self.at(cause, param_env).sup(DefineOpaqueTypes::Yes, b, a))
956962
}
957963
})
958964
}

0 commit comments

Comments
 (0)