about summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src
diff options
context:
space:
mode:
author许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com>2025-08-19 19:42:02 +0800
committerGitHub <noreply@github.com>2025-08-19 19:42:02 +0800
commitbd0e768fff3b72f3c28075e9dee00b4318a0d7ea (patch)
treef19d148485a7d6b7607630cc5d8acfb3df4fe078 /compiler/rustc_borrowck/src
parentdf01a87de2f9cf936e380a3fca637e552f34a31b (diff)
parentf5e43d5ee31f0740a96479b4ffa2dcff009c226f (diff)
downloadrust-bd0e768fff3b72f3c28075e9dee00b4318a0d7ea.tar.gz
rust-bd0e768fff3b72f3c28075e9dee00b4318a0d7ea.zip
Rollup merge of #142079 - lcnr:opaque-types-universes, r=BoxyUwU
nll-relate: improve hr opaque types support

This should currently not be user-facing outside of diagnostics as even if we successfully relate the opaque types, we don't support opaque types with non-param arguments and also require all member regions to be equal to the arguments or `'static`. This means there's no way to end up with a placeholder in the hidden type.

r? types
Diffstat (limited to 'compiler/rustc_borrowck/src')
-rw-r--r--compiler/rustc_borrowck/src/type_check/relate_tys.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/rustc_borrowck/src/type_check/relate_tys.rs b/compiler/rustc_borrowck/src/type_check/relate_tys.rs
index 84ca9bad2c1..7ac2dff12f7 100644
--- a/compiler/rustc_borrowck/src/type_check/relate_tys.rs
+++ b/compiler/rustc_borrowck/src/type_check/relate_tys.rs
@@ -124,8 +124,13 @@ impl<'a, 'b, 'tcx> NllTypeRelating<'a, 'b, 'tcx> {
         // by using `ty_vid rel B` and then finally and end by equating `ty_vid` to
         // the opaque.
         let mut enable_subtyping = |ty, opaque_is_expected| {
-            let ty_vid = infcx.next_ty_var_id_in_universe(self.span(), ty::UniverseIndex::ROOT);
-
+            // We create the fresh inference variable in the highest universe.
+            // In theory we could limit it to the highest universe in the args of
+            // the opaque but that isn't really worth the effort.
+            //
+            // We'll make sure that the opaque type can actually name everything
+            // in its hidden type later on.
+            let ty_vid = infcx.next_ty_vid(self.span());
             let variance = if opaque_is_expected {
                 self.ambient_variance
             } else {