Check reveal and can_define_opaque_ty in try_normalize_ty_recur

This commit is contained in:
Michael Goulet 2024-01-10 16:11:47 +00:00
parent e927184629
commit f49b0dcce2

View File

@ -22,6 +22,7 @@ use rustc_middle::traits::solve::{
CanonicalResponse, Certainty, ExternalConstraintsData, Goal, GoalSource, IsNormalizesToHack, CanonicalResponse, Certainty, ExternalConstraintsData, Goal, GoalSource, IsNormalizesToHack,
QueryResult, Response, QueryResult, Response,
}; };
use rustc_middle::traits::Reveal;
use rustc_middle::ty::{self, OpaqueTypeKey, Ty, TyCtxt, UniverseIndex}; use rustc_middle::ty::{self, OpaqueTypeKey, Ty, TyCtxt, UniverseIndex};
use rustc_middle::ty::{ use rustc_middle::ty::{
CoercePredicate, RegionOutlivesPredicate, SubtypePredicate, TypeOutlivesPredicate, CoercePredicate, RegionOutlivesPredicate, SubtypePredicate, TypeOutlivesPredicate,
@ -317,18 +318,21 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
}; };
// We do no always define opaque types eagerly to allow non-defining uses in the defining scope. // We do no always define opaque types eagerly to allow non-defining uses in the defining scope.
if let (DefineOpaqueTypes::No, ty::AliasKind::Opaque) = (define_opaque_types, kind) { if let DefineOpaqueTypes::No = define_opaque_types
if let Some(def_id) = alias.def_id.as_local() { && let Reveal::UserFacing = param_env.reveal()
if self && let ty::Opaque = kind
.unify_existing_opaque_tys( && let Some(def_id) = alias.def_id.as_local()
param_env, && self.can_define_opaque_ty(def_id)
OpaqueTypeKey { def_id, args: alias.args }, {
self.next_ty_infer(), if self
) .unify_existing_opaque_tys(
.is_empty() param_env,
{ OpaqueTypeKey { def_id, args: alias.args },
return Some(ty); self.next_ty_infer(),
} )
.is_empty()
{
return Some(ty);
} }
} }