about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSparrowLii <liyuan179@huawei.com>2022-08-22 18:36:02 +0800
committerSparrowLii <liyuan179@huawei.com>2022-08-22 18:36:02 +0800
commita01ac5a6996f4fad346a6ff07edb197f74612aa8 (patch)
tree47e25f6c9fc7575402981115faad53021226eb09
parentd39fefdd694b02c7e7b4a64ccbb38d9f8be16df0 (diff)
downloadrust-a01ac5a6996f4fad346a6ff07edb197f74612aa8.tar.gz
rust-a01ac5a6996f4fad346a6ff07edb197f74612aa8.zip
re-base and use `OutlivesEnvironment::with_bounds`
-rw-r--r--compiler/rustc_infer/src/infer/outlives/env.rs2
-rw-r--r--compiler/rustc_typeck/src/check/compare_method.rs6
-rw-r--r--compiler/rustc_typeck/src/check/wfcheck.rs6
-rw-r--r--compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs28
4 files changed, 13 insertions, 29 deletions
diff --git a/compiler/rustc_infer/src/infer/outlives/env.rs b/compiler/rustc_infer/src/infer/outlives/env.rs
index 7afb44517a3..872886da362 100644
--- a/compiler/rustc_infer/src/infer/outlives/env.rs
+++ b/compiler/rustc_infer/src/infer/outlives/env.rs
@@ -109,7 +109,7 @@ impl<'tcx> OutlivesEnvironment<'tcx> {
 
 impl<'a, 'tcx> OutlivesEnvironmentBuilder<'tcx> {
     #[inline]
-    pub fn build(self) -> OutlivesEnvironment<'tcx> {
+    fn build(self) -> OutlivesEnvironment<'tcx> {
         OutlivesEnvironment {
             param_env: self.param_env,
             free_region_map: FreeRegionMap { relation: self.region_relation.freeze() },
diff --git a/compiler/rustc_typeck/src/check/compare_method.rs b/compiler/rustc_typeck/src/check/compare_method.rs
index 5fde6f396e5..dfef924f699 100644
--- a/compiler/rustc_typeck/src/check/compare_method.rs
+++ b/compiler/rustc_typeck/src/check/compare_method.rs
@@ -1516,9 +1516,9 @@ pub fn check_type_bounds<'tcx>(
 
         // Finally, resolve all regions. This catches wily misuses of
         // lifetime parameters.
-        let mut outlives_environment = OutlivesEnvironment::builder(param_env);
-        outlives_environment.add_implied_bounds(&infcx, assumed_wf_types, impl_ty_hir_id);
-        let outlives_environment = outlives_environment.build();
+        let implied_bounds = infcx.implied_bounds_tys(param_env, impl_ty_hir_id, assumed_wf_types);
+        let outlives_environment =
+            OutlivesEnvironment::with_bounds(param_env, Some(&infcx), implied_bounds);
 
         infcx.check_region_obligations_and_report_errors(
             impl_ty.def_id.expect_local(),
diff --git a/compiler/rustc_typeck/src/check/wfcheck.rs b/compiler/rustc_typeck/src/check/wfcheck.rs
index 057e5f93563..b4b6fe8eead 100644
--- a/compiler/rustc_typeck/src/check/wfcheck.rs
+++ b/compiler/rustc_typeck/src/check/wfcheck.rs
@@ -104,9 +104,9 @@ pub(super) fn enter_wf_checking_ctxt<'tcx, F>(
             return;
         }
 
-        let mut outlives_environment = OutlivesEnvironment::builder(param_env);
-        outlives_environment.add_implied_bounds(infcx, assumed_wf_types, body_id);
-        let outlives_environment = outlives_environment.build();
+        let implied_bounds = infcx.implied_bounds_tys(param_env, body_id, assumed_wf_types);
+        let outlives_environment =
+            OutlivesEnvironment::with_bounds(param_env, Some(infcx), implied_bounds);
 
         infcx.check_region_obligations_and_report_errors(body_def_id, &outlives_environment);
     })
diff --git a/compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs b/compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs
index 64cd69750f3..6240024d49c 100644
--- a/compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs
+++ b/compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs
@@ -67,7 +67,7 @@
 
 use crate::constrained_generic_params as cgp;
 use crate::errors::SubstsOnOverriddenImpl;
-use crate::outlives::outlives_bounds::InferCtxtExt;
+use crate::outlives::outlives_bounds::InferCtxtExt as _;
 
 use rustc_data_structures::fx::FxHashSet;
 use rustc_hir::def_id::{DefId, LocalDefId};
@@ -147,35 +147,18 @@ fn get_impl_substs<'tcx>(
         let assumed_wf_types =
             ocx.assumed_wf_types(param_env, tcx.def_span(impl1_def_id), impl1_def_id);
 
-      let impl1_substs = InternalSubsts::identity_for_item(tcx, impl1_def_id.to_def_id());
+        let impl1_substs = InternalSubsts::identity_for_item(tcx, impl1_def_id.to_def_id());
         let impl2_substs =
             translate_substs(infcx, param_env, impl1_def_id.to_def_id(), impl1_substs, impl2_node);
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
         let errors = ocx.select_all_or_error();
         if !errors.is_empty() {
             ocx.infcx.report_fulfillment_errors(&errors, None, false);
             return None;
         }
 
-        let mut outlives_env = OutlivesEnvironment::new(param_env);
-        outlives_env.add_implied_bounds(infcx, assumed_wf_types, impl1_hir_id);
+        let implied_bounds = infcx.implied_bounds_tys(param_env, impl1_hir_id, assumed_wf_types);
+        let outlives_env = OutlivesEnvironment::with_bounds(param_env, Some(infcx), implied_bounds);
         infcx.check_region_obligations_and_report_errors(impl1_def_id, &outlives_env);
         let Ok(impl2_substs) = infcx.fully_resolve(impl2_substs) else {
             let span = tcx.def_span(impl1_def_id);
@@ -183,7 +166,8 @@ fn get_impl_substs<'tcx>(
             return None;
         };
         Some((impl1_substs, impl2_substs))
-    })}
+    })
+}
 
 /// Returns a list of all of the unconstrained subst of the given impl.
 ///