Skip to content

Commit d73be85

Browse files
committed
extract regionck_outlives into a separate helper function
This helps make its inputs and outputs more clear.
1 parent c925008 commit d73be85

File tree

5 files changed

+498
-367
lines changed

5 files changed

+498
-367
lines changed

src/librustc/infer/mod.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,27 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
14511451

14521452
self.tcx.generator_sig(def_id)
14531453
}
1454+
1455+
/// Normalizes associated types in `value`, potentially returning
1456+
/// new obligations that must further be processed.
1457+
pub fn partially_normalize_associated_types_in<T>(&self,
1458+
span: Span,
1459+
body_id: ast::NodeId,
1460+
param_env: ty::ParamEnv<'tcx>,
1461+
value: &T)
1462+
-> InferOk<'tcx, T>
1463+
where T : TypeFoldable<'tcx>
1464+
{
1465+
debug!("partially_normalize_associated_types_in(value={:?})", value);
1466+
let mut selcx = traits::SelectionContext::new(self);
1467+
let cause = ObligationCause::misc(span, body_id);
1468+
let traits::Normalized { value, obligations } =
1469+
traits::normalize(&mut selcx, param_env, cause, value);
1470+
debug!("partially_normalize_associated_types_in: result={:?} predicates={:?}",
1471+
value,
1472+
obligations);
1473+
InferOk { value, obligations }
1474+
}
14541475
}
14551476

14561477
impl<'a, 'gcx, 'tcx> TypeTrace<'tcx> {

src/librustc_typeck/check/mod.rs

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ mod autoderef;
136136
pub mod dropck;
137137
pub mod _match;
138138
pub mod writeback;
139-
pub mod regionck;
139+
mod regionck;
140+
mod regionck_outlives;
140141
pub mod coercion;
141142
pub mod demand;
142143
pub mod method;
@@ -657,29 +658,10 @@ impl<'a, 'gcx, 'tcx> Inherited<'a, 'gcx, 'tcx> {
657658
value: &T) -> T
658659
where T : TypeFoldable<'tcx>
659660
{
660-
let ok = self.normalize_associated_types_in_as_infer_ok(span, body_id, param_env, value);
661+
let ok = self.partially_normalize_associated_types_in(span, body_id, param_env, value);
661662
self.register_infer_ok_obligations(ok)
662663
}
663664

664-
fn normalize_associated_types_in_as_infer_ok<T>(&self,
665-
span: Span,
666-
body_id: ast::NodeId,
667-
param_env: ty::ParamEnv<'tcx>,
668-
value: &T)
669-
-> InferOk<'tcx, T>
670-
where T : TypeFoldable<'tcx>
671-
{
672-
debug!("normalize_associated_types_in(value={:?})", value);
673-
let mut selcx = traits::SelectionContext::new(self);
674-
let cause = ObligationCause::misc(span, body_id);
675-
let traits::Normalized { value, obligations } =
676-
traits::normalize(&mut selcx, param_env, cause, value);
677-
debug!("normalize_associated_types_in: result={:?} predicates={:?}",
678-
value,
679-
obligations);
680-
InferOk { value, obligations }
681-
}
682-
683665
/// Replace any late-bound regions bound in `value` with
684666
/// free variants attached to `all_outlive_scope`.
685667
fn liberate_late_bound_regions<T>(&self,
@@ -1970,10 +1952,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
19701952
-> InferOk<'tcx, T>
19711953
where T : TypeFoldable<'tcx>
19721954
{
1973-
self.inh.normalize_associated_types_in_as_infer_ok(span,
1974-
self.body_id,
1975-
self.param_env,
1976-
value)
1955+
self.inh.partially_normalize_associated_types_in(span,
1956+
self.body_id,
1957+
self.param_env,
1958+
value)
19771959
}
19781960

19791961
pub fn require_type_meets(&self,

0 commit comments

Comments
 (0)