about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-01-10 16:11:47 +0000
committerMichael Goulet <michael@errs.io>2024-01-10 16:21:58 +0000
commitf49b0dcce2d36e907c3eb12e97f2fab0a4e02dc6 (patch)
treea2393038dc126d847c5456afb8c489efee5ff963
parente9271846294c4ee5bd7706df68180320c0b5ff20 (diff)
downloadrust-f49b0dcce2d36e907c3eb12e97f2fab0a4e02dc6.tar.gz
rust-f49b0dcce2d36e907c3eb12e97f2fab0a4e02dc6.zip
Check reveal and can_define_opaque_ty in try_normalize_ty_recur
-rw-r--r--compiler/rustc_trait_selection/src/solve/mod.rs28
1 files changed, 16 insertions, 12 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/mod.rs b/compiler/rustc_trait_selection/src/solve/mod.rs
index 2f3111a2414..dac8b3cce80 100644
--- a/compiler/rustc_trait_selection/src/solve/mod.rs
+++ b/compiler/rustc_trait_selection/src/solve/mod.rs
@@ -22,6 +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::{
     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.
-        if let (DefineOpaqueTypes::No, ty::AliasKind::Opaque) = (define_opaque_types, kind) {
-            if let Some(def_id) = alias.def_id.as_local() {
-                if self
-                    .unify_existing_opaque_tys(
-                        param_env,
-                        OpaqueTypeKey { def_id, args: alias.args },
-                        self.next_ty_infer(),
-                    )
-                    .is_empty()
-                {
-                    return Some(ty);
-                }
+        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);
             }
         }