about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-05-25 19:46:52 +0000
committerMichael Goulet <michael@errs.io>2023-05-27 04:13:44 +0000
commitc4e8a86d9ee6b83bacadd3983122e56c323fd7b2 (patch)
tree74f2c5c1f11991617379ddb1b988561f9705d5d6
parentd7a2fdd4dba976fddfebe4b3be95a327bae39423 (diff)
downloadrust-c4e8a86d9ee6b83bacadd3983122e56c323fd7b2.tar.gz
rust-c4e8a86d9ee6b83bacadd3983122e56c323fd7b2.zip
Don't use outlives type op outside of MIR typeck
-rw-r--r--compiler/rustc_trait_selection/src/traits/outlives_bounds.rs37
1 files changed, 23 insertions, 14 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs b/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs
index 0e797a1cb60..f8d056e321e 100644
--- a/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs
+++ b/compiler/rustc_trait_selection/src/traits/outlives_bounds.rs
@@ -1,9 +1,9 @@
 use crate::infer::InferCtxt;
-use crate::traits::query::type_op::{self, TypeOp, TypeOpOutput};
 use crate::traits::{ObligationCause, ObligationCtxt};
 use rustc_data_structures::fx::FxIndexSet;
-use rustc_errors::ErrorGuaranteed;
 use rustc_infer::infer::resolve::OpportunisticRegionResolver;
+use rustc_infer::infer::InferOk;
+use rustc_middle::infer::canonical::{OriginalQueryValues, QueryRegionConstraints};
 use rustc_middle::ty::{self, ParamEnv, Ty, TypeFolder, TypeVisitableExt};
 use rustc_span::def_id::LocalDefId;
 
@@ -68,20 +68,29 @@ impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> {
             return vec![];
         }
 
-        let span = self.tcx.def_span(body_id);
-        let result: Result<_, ErrorGuaranteed> = param_env
-            .and(type_op::implied_outlives_bounds::ImpliedOutlivesBounds { ty })
-            .fully_perform(self, span);
-        let result = match result {
-            Ok(r) => r,
-            Err(_) => {
-                return vec![];
-            }
+        let mut canonical_var_values = OriginalQueryValues::default();
+        let canonical_ty =
+            self.canonicalize_query_keep_static(param_env.and(ty), &mut canonical_var_values);
+        let Ok(canonical_result) = self.tcx.implied_outlives_bounds(canonical_ty) else {
+            return vec![];
+        };
+
+        let mut constraints = QueryRegionConstraints::default();
+        let Ok(InferOk { value, obligations }) = self
+            .instantiate_nll_query_response_and_region_obligations(
+                &ObligationCause::dummy(),
+                param_env,
+                &canonical_var_values,
+                canonical_result,
+                &mut constraints,
+            ) else {
+            return vec![];
         };
+        assert_eq!(&obligations, &[]);
 
-        let TypeOpOutput { output, constraints, .. } = result;
+        if !constraints.is_empty() {
+            let span = self.tcx.def_span(body_id);
 
-        if let Some(constraints) = constraints {
             debug!(?constraints);
             if !constraints.member_constraints.is_empty() {
                 span_bug!(span, "{:#?}", constraints.member_constraints);
@@ -108,7 +117,7 @@ impl<'a, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'tcx> {
             }
         };
 
-        output
+        value
     }
 
     fn implied_bounds_tys(