Skip to content

Commit ce340af

Browse files
committed
move outlives_components onto tcx
1 parent f3cc374 commit ce340af

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

src/librustc/ty/outlives.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
// refers to rules defined in RFC 1214 (`OutlivesFooBar`), so see that
1313
// RFC for reference.
1414

15-
use infer::InferCtxt;
16-
use ty::{self, Ty, TypeFoldable};
15+
use ty::{self, Ty, TyCtxt, TypeFoldable};
1716

1817
#[derive(Debug)]
1918
pub enum Component<'tcx> {
@@ -55,9 +54,9 @@ pub enum Component<'tcx> {
5554
EscapingProjection(Vec<Component<'tcx>>),
5655
}
5756

58-
impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
57+
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
5958
/// Returns all the things that must outlive `'a` for the condition
60-
/// `ty0: 'a` to hold.
59+
/// `ty0: 'a` to hold. Note that `ty0` must be a **fully resolved type**.
6160
pub fn outlives_components(&self, ty0: Ty<'tcx>)
6261
-> Vec<Component<'tcx>> {
6362
let mut components = vec![];
@@ -148,16 +147,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
148147
}
149148
}
150149

151-
// If we encounter an inference variable, try to resolve it
152-
// and proceed with resolved version. If we cannot resolve it,
153-
// then record the unresolved variable as a component.
154-
ty::TyInfer(_) => {
155-
let ty = self.resolve_type_vars_if_possible(&ty);
156-
if let ty::TyInfer(infer_ty) = ty.sty {
157-
out.push(Component::UnresolvedInferenceVariable(infer_ty));
158-
} else {
159-
self.compute_components(ty, out);
160-
}
150+
// We assume that inference variables are fully resolved.
151+
// So, if we encounter an inference variable, just record
152+
// the unresolved variable as a component.
153+
ty::TyInfer(infer_ty) => {
154+
out.push(Component::UnresolvedInferenceVariable(infer_ty));
161155
}
162156

163157
// Most types do not introduce any region binders, nor

src/librustc/ty/wf.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ pub fn implied_bounds<'a, 'gcx, 'tcx>(
178178
match infcx.tcx.no_late_bound_regions(data) {
179179
None => vec![],
180180
Some(ty::OutlivesPredicate(ty_a, r_b)) => {
181-
let components = infcx.outlives_components(ty_a);
181+
let ty_a = infcx.resolve_type_vars_if_possible(&ty_a);
182+
let components = infcx.tcx.outlives_components(ty_a);
182183
implied_bounds_from_components(r_b, components)
183184
}
184185
},

src/librustc_typeck/check/regionck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1474,7 +1474,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
14741474

14751475
assert!(!ty.has_escaping_regions());
14761476

1477-
let components = self.outlives_components(ty);
1477+
let components = self.tcx.outlives_components(ty);
14781478
self.components_must_outlive(origin, components, region);
14791479
}
14801480

0 commit comments

Comments
 (0)