also try to normalize opaque types in alias-relate
with this, alias-relate treats all aliases the same way and it can be used for structural normalization.
This commit is contained in:
parent
0a5b998c57
commit
bbe2f6c0b2
5 changed files with 27 additions and 98 deletions
|
@ -22,8 +22,7 @@ use rustc_middle::traits::solve::{
|
|||
CanonicalResponse, Certainty, ExternalConstraintsData, Goal, GoalSource, IsNormalizesToHack,
|
||||
QueryResult, Response,
|
||||
};
|
||||
use rustc_middle::traits::Reveal;
|
||||
use rustc_middle::ty::{self, OpaqueTypeKey, Ty, TyCtxt, UniverseIndex};
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt, UniverseIndex};
|
||||
use rustc_middle::ty::{
|
||||
CoercePredicate, RegionOutlivesPredicate, SubtypePredicate, TypeOutlivesPredicate,
|
||||
};
|
||||
|
@ -292,32 +291,10 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||
return None;
|
||||
}
|
||||
|
||||
let ty::Alias(kind, alias) = *ty.kind() else {
|
||||
let ty::Alias(_, alias) = *ty.kind() else {
|
||||
return Some(ty);
|
||||
};
|
||||
|
||||
// We do no always define opaque types eagerly to allow non-defining uses
|
||||
// in the defining scope. However, if we can unify this opaque to an existing
|
||||
// opaque, then we should attempt to eagerly reveal the opaque, and we fall
|
||||
// through.
|
||||
if let DefineOpaqueTypes::No = define_opaque_types
|
||||
&& let Reveal::UserFacing = param_env.reveal()
|
||||
&& let ty::Opaque = kind
|
||||
&& let Some(def_id) = alias.def_id.as_local()
|
||||
&& self.can_define_opaque_ty(def_id)
|
||||
{
|
||||
if self
|
||||
.unify_existing_opaque_tys(
|
||||
param_env,
|
||||
OpaqueTypeKey { def_id, args: alias.args },
|
||||
self.next_ty_infer(),
|
||||
)
|
||||
.is_empty()
|
||||
{
|
||||
return Some(ty);
|
||||
}
|
||||
}
|
||||
|
||||
match self.commit_if_ok(|this| {
|
||||
let normalized_ty = this.next_ty_infer();
|
||||
let normalizes_to_goal = Goal::new(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue