about summary refs log tree commit diff
path: root/compiler/rustc_infer/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-04-16 19:52:48 +0000
committerbors <bors@rust-lang.org>2024-04-16 19:52:48 +0000
commit1cec373f65eb76e8e4b4d1847213cf3ec6c292b6 (patch)
tree043e5fb90ab4a2bb4d9963f49fd610e517fc5928 /compiler/rustc_infer/src
parent468f1156843c35af624304c44b0ea0cf0a7777d4 (diff)
parent7709b7d44a99e52ef8818b3690aa2a3531b86707 (diff)
downloadrust-1cec373f65eb76e8e4b4d1847213cf3ec6c292b6.tar.gz
rust-1cec373f65eb76e8e4b4d1847213cf3ec6c292b6.zip
Auto merge of #124034 - GuillaumeGomez:rollup-ayztp9l, r=GuillaumeGomez
Rollup of 7 pull requests

Successful merges:

 - #122811 (Move `SourceMap` initialization)
 - #123512 (Match ergonomics 2024: Implement eat-one-layer)
 - #123811 (Use queue-based `RwLock` on more platforms)
 - #123859 (Remove uneeded clones now that TrustedStep implies Copy)
 - #123979 (Subtype predicates only exist on inference types, so we can allow them to register opaque types within them.)
 - #124016 (Outline default query and hook provider function implementations)
 - #124023 (Allow workproducts without object files.)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_infer/src')
-rw-r--r--compiler/rustc_infer/src/infer/mod.rs17
1 files changed, 15 insertions, 2 deletions
diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs
index f3f214f2123..2963557bb3c 100644
--- a/compiler/rustc_infer/src/infer/mod.rs
+++ b/compiler/rustc_infer/src/infer/mod.rs
@@ -945,14 +945,27 @@ impl<'tcx> InferCtxt<'tcx> {
             (&ty::Infer(ty::TyVar(a_vid)), &ty::Infer(ty::TyVar(b_vid))) => {
                 return Err((a_vid, b_vid));
             }
+            // We don't silently want to constrain hidden types here, so we assert that either one side is
+            // an infer var, so it'll get constrained to whatever the other side is, or there are no opaque
+            // types involved.
+            // We don't expect this to actually get hit, but if it does, we now at least know how to write
+            // a test for it.
+            (_, ty::Infer(ty::TyVar(_))) => {}
+            (ty::Infer(ty::TyVar(_)), _) => {}
+            _ if (r_a, r_b).has_opaque_types() => {
+                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))
             }
         })
     }