Skip to content

Commit

Permalink
Subtype predicates only exist on inference types, so we can allow the…
Browse files Browse the repository at this point in the history
…m to register opaque types within them.
  • Loading branch information
oli-obk committed Apr 15, 2024
1 parent 0230848 commit ba2072b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -945,14 +945,20 @@ impl<'tcx> InferCtxt<'tcx> {
(&ty::Infer(ty::TyVar(a_vid)), &ty::Infer(ty::TyVar(b_vid))) => {
return Err((a_vid, b_vid));
}
(ty::Alias(ty::Opaque, ..), ty::Infer(ty::TyVar(_)))
| (ty::Infer(ty::TyVar(_)), ty::Alias(ty::Opaque, ..)) => {}
(ty::Alias(ty::Opaque, ..), _) | (_, ty::Alias(ty::Opaque, ..)) => span_bug!(
cause.span(),
"opaque types got hidden types registered from within subtype predicate: {r_a:?} vs {r_b:?}"
),
_ => {}
}

self.enter_forall(predicate, |ty::SubtypePredicate { a_is_expected, a, b }| {
if a_is_expected {
Ok(self.at(cause, param_env).sub(DefineOpaqueTypes::No, a, b))
Ok(self.at(cause, param_env).sub(DefineOpaqueTypes::Yes, a, b))
} else {
Ok(self.at(cause, param_env).sup(DefineOpaqueTypes::No, b, a))
Ok(self.at(cause, param_env).sup(DefineOpaqueTypes::Yes, b, a))
}
})
}
Expand Down

0 comments on commit ba2072b

Please sign in to comment.