Skip to content

Commit 796ca64

Browse files
committed
Move traits::query::outlives_bounds::explicit_outlives_bounds to infer::outlives.
1 parent 98444ca commit 796ca64

File tree

4 files changed

+29
-23
lines changed

4 files changed

+29
-23
lines changed

src/librustc_infer/infer/outlives/env.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
use crate::infer::{GenericKind, InferCtxt};
2-
use crate::traits::query::outlives_bounds::{self, OutlivesBound};
2+
use crate::traits::query::OutlivesBound;
33
use rustc::ty::free_region_map::FreeRegionMap;
44
use rustc::ty::{self, Ty};
55
use rustc_data_structures::fx::FxHashMap;
66
use rustc_hir as hir;
77
use rustc_span::Span;
88

9+
use super::explicit_outlives_bounds;
10+
911
/// The `OutlivesEnvironment` collects information about what outlives
1012
/// what in a given type-checking setting. For example, if we have a
1113
/// where-clause like `where T: 'a` in scope, then the
@@ -76,7 +78,7 @@ impl<'a, 'tcx> OutlivesEnvironment<'tcx> {
7678
region_bound_pairs_accum: vec![],
7779
};
7880

79-
env.add_outlives_bounds(None, outlives_bounds::explicit_outlives_bounds(param_env));
81+
env.add_outlives_bounds(None, explicit_outlives_bounds(param_env));
8082

8183
env
8284
}

src/librustc_infer/infer/outlives/mod.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,25 @@
33
pub mod env;
44
pub mod obligations;
55
pub mod verify;
6+
7+
use rustc::traits::query::OutlivesBound;
8+
use rustc::ty;
9+
10+
pub fn explicit_outlives_bounds<'tcx>(
11+
param_env: ty::ParamEnv<'tcx>,
12+
) -> impl Iterator<Item = OutlivesBound<'tcx>> + 'tcx {
13+
debug!("explicit_outlives_bounds()");
14+
param_env.caller_bounds.into_iter().filter_map(move |predicate| match predicate {
15+
ty::Predicate::Projection(..)
16+
| ty::Predicate::Trait(..)
17+
| ty::Predicate::Subtype(..)
18+
| ty::Predicate::WellFormed(..)
19+
| ty::Predicate::ObjectSafe(..)
20+
| ty::Predicate::ClosureKind(..)
21+
| ty::Predicate::TypeOutlives(..)
22+
| ty::Predicate::ConstEvaluatable(..) => None,
23+
ty::Predicate::RegionOutlives(ref data) => data
24+
.no_bound_vars()
25+
.map(|ty::OutlivesPredicate(r_a, r_b)| OutlivesBound::RegionSubRegion(r_b, r_a)),
26+
})
27+
}

src/librustc_infer/traits/query/outlives_bounds.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,3 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
8282
result.value
8383
}
8484
}
85-
86-
pub fn explicit_outlives_bounds<'tcx>(
87-
param_env: ty::ParamEnv<'tcx>,
88-
) -> impl Iterator<Item = OutlivesBound<'tcx>> + 'tcx {
89-
debug!("explicit_outlives_bounds()");
90-
param_env.caller_bounds.into_iter().filter_map(move |predicate| match predicate {
91-
ty::Predicate::Projection(..)
92-
| ty::Predicate::Trait(..)
93-
| ty::Predicate::Subtype(..)
94-
| ty::Predicate::WellFormed(..)
95-
| ty::Predicate::ObjectSafe(..)
96-
| ty::Predicate::ClosureKind(..)
97-
| ty::Predicate::TypeOutlives(..)
98-
| ty::Predicate::ConstEvaluatable(..) => None,
99-
ty::Predicate::RegionOutlives(ref data) => data
100-
.no_bound_vars()
101-
.map(|ty::OutlivesPredicate(r_a, r_b)| OutlivesBound::RegionSubRegion(r_b, r_a)),
102-
})
103-
}

src/librustc_mir/borrow_check/type_check/free_region_relations.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
use rustc::mir::ConstraintCategory;
2+
use rustc::traits::query::OutlivesBound;
23
use rustc::ty::free_region_map::FreeRegionRelations;
34
use rustc::ty::{self, RegionVid, Ty, TyCtxt};
45
use rustc_data_structures::transitive_relation::TransitiveRelation;
56
use rustc_infer::infer::canonical::QueryRegionConstraints;
7+
use rustc_infer::infer::outlives;
68
use rustc_infer::infer::region_constraints::GenericKind;
79
use rustc_infer::infer::InferCtxt;
8-
use rustc_infer::traits::query::outlives_bounds::{self, OutlivesBound};
910
use rustc_infer::traits::query::type_op::{self, TypeOp};
1011
use rustc_span::DUMMY_SP;
1112
use std::rc::Rc;
@@ -266,7 +267,7 @@ impl UniversalRegionRelationsBuilder<'cx, 'tcx> {
266267

267268
// Insert the facts we know from the predicates. Why? Why not.
268269
let param_env = self.param_env;
269-
self.add_outlives_bounds(outlives_bounds::explicit_outlives_bounds(param_env));
270+
self.add_outlives_bounds(outlives::explicit_outlives_bounds(param_env));
270271

271272
// Finally:
272273
// - outlives is reflexive, so `'r: 'r` for every region `'r`

0 commit comments

Comments
 (0)