Skip to content

Commit a01ac5a

Browse files
committed
re-base and use OutlivesEnvironment::with_bounds
1 parent d39fefd commit a01ac5a

File tree

4 files changed

+13
-29
lines changed

4 files changed

+13
-29
lines changed

Diff for: compiler/rustc_infer/src/infer/outlives/env.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl<'tcx> OutlivesEnvironment<'tcx> {
109109

110110
impl<'a, 'tcx> OutlivesEnvironmentBuilder<'tcx> {
111111
#[inline]
112-
pub fn build(self) -> OutlivesEnvironment<'tcx> {
112+
fn build(self) -> OutlivesEnvironment<'tcx> {
113113
OutlivesEnvironment {
114114
param_env: self.param_env,
115115
free_region_map: FreeRegionMap { relation: self.region_relation.freeze() },

Diff for: compiler/rustc_typeck/src/check/compare_method.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1516,9 +1516,9 @@ pub fn check_type_bounds<'tcx>(
15161516

15171517
// Finally, resolve all regions. This catches wily misuses of
15181518
// lifetime parameters.
1519-
let mut outlives_environment = OutlivesEnvironment::builder(param_env);
1520-
outlives_environment.add_implied_bounds(&infcx, assumed_wf_types, impl_ty_hir_id);
1521-
let outlives_environment = outlives_environment.build();
1519+
let implied_bounds = infcx.implied_bounds_tys(param_env, impl_ty_hir_id, assumed_wf_types);
1520+
let outlives_environment =
1521+
OutlivesEnvironment::with_bounds(param_env, Some(&infcx), implied_bounds);
15221522

15231523
infcx.check_region_obligations_and_report_errors(
15241524
impl_ty.def_id.expect_local(),

Diff for: compiler/rustc_typeck/src/check/wfcheck.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ pub(super) fn enter_wf_checking_ctxt<'tcx, F>(
104104
return;
105105
}
106106

107-
let mut outlives_environment = OutlivesEnvironment::builder(param_env);
108-
outlives_environment.add_implied_bounds(infcx, assumed_wf_types, body_id);
109-
let outlives_environment = outlives_environment.build();
107+
let implied_bounds = infcx.implied_bounds_tys(param_env, body_id, assumed_wf_types);
108+
let outlives_environment =
109+
OutlivesEnvironment::with_bounds(param_env, Some(infcx), implied_bounds);
110110

111111
infcx.check_region_obligations_and_report_errors(body_def_id, &outlives_environment);
112112
})

Diff for: compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs

+6-22
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
6868
use crate::constrained_generic_params as cgp;
6969
use crate::errors::SubstsOnOverriddenImpl;
70-
use crate::outlives::outlives_bounds::InferCtxtExt;
70+
use crate::outlives::outlives_bounds::InferCtxtExt as _;
7171

7272
use rustc_data_structures::fx::FxHashSet;
7373
use rustc_hir::def_id::{DefId, LocalDefId};
@@ -147,43 +147,27 @@ fn get_impl_substs<'tcx>(
147147
let assumed_wf_types =
148148
ocx.assumed_wf_types(param_env, tcx.def_span(impl1_def_id), impl1_def_id);
149149

150-
let impl1_substs = InternalSubsts::identity_for_item(tcx, impl1_def_id.to_def_id());
150+
let impl1_substs = InternalSubsts::identity_for_item(tcx, impl1_def_id.to_def_id());
151151
let impl2_substs =
152152
translate_substs(infcx, param_env, impl1_def_id.to_def_id(), impl1_substs, impl2_node);
153153

154-
155-
156-
157-
158-
159-
160-
161-
162-
163-
164-
165-
166-
167-
168-
169-
170-
171154
let errors = ocx.select_all_or_error();
172155
if !errors.is_empty() {
173156
ocx.infcx.report_fulfillment_errors(&errors, None, false);
174157
return None;
175158
}
176159

177-
let mut outlives_env = OutlivesEnvironment::new(param_env);
178-
outlives_env.add_implied_bounds(infcx, assumed_wf_types, impl1_hir_id);
160+
let implied_bounds = infcx.implied_bounds_tys(param_env, impl1_hir_id, assumed_wf_types);
161+
let outlives_env = OutlivesEnvironment::with_bounds(param_env, Some(infcx), implied_bounds);
179162
infcx.check_region_obligations_and_report_errors(impl1_def_id, &outlives_env);
180163
let Ok(impl2_substs) = infcx.fully_resolve(impl2_substs) else {
181164
let span = tcx.def_span(impl1_def_id);
182165
tcx.sess.emit_err(SubstsOnOverriddenImpl { span });
183166
return None;
184167
};
185168
Some((impl1_substs, impl2_substs))
186-
})}
169+
})
170+
}
187171

188172
/// Returns a list of all of the unconstrained subst of the given impl.
189173
///

0 commit comments

Comments
 (0)