Skip to content

Commit d941658

Browse files
committed
Auto merge of #51959 - tmandry:make-implied-outlives-query, r=nikomatsakis
Turn implied_outlives_bounds into a query Right now all this does is remove the error reporting in `implied_outlives_bounds`, which seems to work. Farming out full tests to Travis. For #51649. That issue is deferred so not sure what's next. r? @nikomatsakis
2 parents 942b384 + 0d8f3b3 commit d941658

File tree

17 files changed

+503
-235
lines changed

17 files changed

+503
-235
lines changed

src/librustc/dep_graph/dep_node.rs

+1
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ define_dep_nodes!( <'tcx>
649649
[input] OutputFilenames,
650650
[] NormalizeProjectionTy(CanonicalProjectionGoal<'tcx>),
651651
[] NormalizeTyAfterErasingRegions(ParamEnvAnd<'tcx, Ty<'tcx>>),
652+
[] ImpliedOutlivesBounds(CanonicalTyGoal<'tcx>),
652653
[] DropckOutlives(CanonicalTyGoal<'tcx>),
653654
[] EvaluateObligation(CanonicalPredicateGoal<'tcx>),
654655
[] TypeOpEq(CanonicalTypeOpEqGoal<'tcx>),

src/librustc/infer/canonical/query_result.rs

+14-10
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
//! [c]: https://rust-lang-nursery.github.io/rustc-guide/traits/canonicalization.html
1919
2020
use infer::canonical::substitute::substitute_value;
21-
use infer::canonical::{Canonical, CanonicalVarKind, CanonicalVarValues, CanonicalizedQueryResult,
22-
Certainty, QueryRegionConstraint, QueryResult, SmallCanonicalVarValues};
21+
use infer::canonical::{
22+
Canonical, CanonicalVarKind, CanonicalVarValues, CanonicalizedQueryResult, Certainty,
23+
QueryRegionConstraint, QueryResult, SmallCanonicalVarValues,
24+
};
2325
use infer::region_constraints::{Constraint, RegionConstraintData};
2426
use infer::InferCtxtBuilder;
2527
use infer::{InferCtxt, InferOk, InferResult, RegionObligation};
@@ -276,9 +278,9 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
276278

277279
for (index, original_value) in original_values.iter().enumerate() {
278280
// ...with the value `v_r` of that variable from the query.
279-
let result_value = query_result
280-
.substitute_projected(self.tcx, &result_subst,
281-
|v| &v.var_values[CanonicalVar::new(index)]);
281+
let result_value = query_result.substitute_projected(self.tcx, &result_subst, |v| {
282+
&v.var_values[CanonicalVar::new(index)]
283+
});
282284
match (original_value.unpack(), result_value.unpack()) {
283285
(UnpackedKind::Lifetime(ty::ReErased), UnpackedKind::Lifetime(ty::ReErased)) => {
284286
// no action needed
@@ -312,11 +314,13 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
312314
// ...also include the other query region constraints from the query.
313315
output_query_region_constraints.reserve(query_result.value.region_constraints.len());
314316
for r_c in query_result.value.region_constraints.iter() {
315-
output_query_region_constraints.push(r_c.map_bound(|ty::OutlivesPredicate(k1, r2)| {
316-
let k1 = substitute_value(self.tcx, &result_subst, &k1);
317-
let r2 = substitute_value(self.tcx, &result_subst, &r2);
318-
ty::OutlivesPredicate(k1, r2)
319-
}));
317+
let &ty::OutlivesPredicate(k1, r2) = r_c.skip_binder(); // reconstructed below
318+
let k1 = substitute_value(self.tcx, &result_subst, &k1);
319+
let r2 = substitute_value(self.tcx, &result_subst, &r2);
320+
if k1 != r2.into() {
321+
output_query_region_constraints
322+
.push(ty::Binder::bind(ty::OutlivesPredicate(k1, r2)));
323+
}
320324
}
321325

322326
let user_result: R =

src/librustc/infer/outlives/bounds.rs

-216
This file was deleted.

src/librustc/infer/outlives/env.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use infer::{GenericKind, InferCtxt};
1212
use infer::outlives::free_region_map::FreeRegionMap;
13-
use infer::outlives::bounds::{self, OutlivesBound};
13+
use traits::query::outlives_bounds::{self, OutlivesBound};
1414
use ty::{self, Ty};
1515

1616
use syntax::ast;
@@ -50,7 +50,7 @@ impl<'a, 'gcx: 'tcx, 'tcx: 'a> OutlivesEnvironment<'tcx> {
5050
region_bound_pairs: vec![],
5151
};
5252

53-
env.add_outlives_bounds(None, bounds::explicit_outlives_bounds(param_env));
53+
env.add_outlives_bounds(None, outlives_bounds::explicit_outlives_bounds(param_env));
5454

5555
env
5656
}

src/librustc/infer/outlives/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@
1212
1313
pub mod env;
1414
pub mod free_region_map;
15-
pub mod bounds;
1615
pub mod obligations;

src/librustc/traits/query/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub mod dropck_outlives;
2323
pub mod evaluate_obligation;
2424
pub mod normalize;
2525
pub mod normalize_erasing_regions;
26+
pub mod outlives_bounds;
2627
pub mod type_op;
2728

2829
pub type CanonicalProjectionGoal<'tcx> =

0 commit comments

Comments
 (0)