]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #99814 - aliemjay:patch-2, r=jackh726
authorbors <bors@rust-lang.org>
Wed, 30 Nov 2022 14:03:36 +0000 (14:03 +0000)
committerbors <bors@rust-lang.org>
Wed, 30 Nov 2022 14:03:36 +0000 (14:03 +0000)
fix universe map in ifcx.instantiate_canonical_*

Previously, `infcx.instantiate_canonical_*` maps the root universe in `canonical` into `ty::UniverseIndex::Root`, I think because it assumes it works with a fresh `infcx` but this is not true for the use cases in mir typeck. Now the root universe is mapped into `infcx.universe()`.

I catched this accidentally while reviewing the code. I'm not sure if this is the right fix or if it is really a bug!

1  2 
compiler/rustc_infer/src/infer/canonical/mod.rs

index ba0ce16bb81ae33d7c674a4b3b1c555c9bf5d7ad,5b37dda12336d4568698e90f0536834fbfc4b30f..e59715b706b29c0c4da6afde7ba99fe9b5a3f737
@@@ -41,9 -41,9 +41,9 @@@ impl<'tcx> InferCtxt<'tcx> 
      /// inference variables and applies it to the canonical value.
      /// Returns both the instantiated result *and* the substitution S.
      ///
-     /// This is only meant to be invoked as part of constructing an
+     /// This can be invoked as part of constructing an
      /// inference context at the start of a query (see
 -    /// `InferCtxtBuilder::enter_with_canonical`). It basically
 +    /// `InferCtxtBuilder::build_with_canonical`). It basically
      /// brings the canonical value "into scope" within your new infcx.
      ///
      /// At the end of processing, the substitution S (once