Skip to content

Commit

Permalink
Auto merge of #51959 - tmandry:make-implied-outlives-query, r=nikomat…
Browse files Browse the repository at this point in the history
…sakis

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
  • Loading branch information
bors committed Jul 21, 2018
2 parents 942b384 + 0d8f3b3 commit d941658
Show file tree
Hide file tree
Showing 17 changed files with 503 additions and 235 deletions.
1 change: 1 addition & 0 deletions src/librustc/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ define_dep_nodes!( <'tcx>
[input] OutputFilenames,
[] NormalizeProjectionTy(CanonicalProjectionGoal<'tcx>),
[] NormalizeTyAfterErasingRegions(ParamEnvAnd<'tcx, Ty<'tcx>>),
[] ImpliedOutlivesBounds(CanonicalTyGoal<'tcx>),
[] DropckOutlives(CanonicalTyGoal<'tcx>),
[] EvaluateObligation(CanonicalPredicateGoal<'tcx>),
[] TypeOpEq(CanonicalTypeOpEqGoal<'tcx>),
Expand Down
24 changes: 14 additions & 10 deletions src/librustc/infer/canonical/query_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
//! [c]: https://rust-lang-nursery.github.io/rustc-guide/traits/canonicalization.html

use infer::canonical::substitute::substitute_value;
use infer::canonical::{Canonical, CanonicalVarKind, CanonicalVarValues, CanonicalizedQueryResult,
Certainty, QueryRegionConstraint, QueryResult, SmallCanonicalVarValues};
use infer::canonical::{
Canonical, CanonicalVarKind, CanonicalVarValues, CanonicalizedQueryResult, Certainty,
QueryRegionConstraint, QueryResult, SmallCanonicalVarValues,
};
use infer::region_constraints::{Constraint, RegionConstraintData};
use infer::InferCtxtBuilder;
use infer::{InferCtxt, InferOk, InferResult, RegionObligation};
Expand Down Expand Up @@ -276,9 +278,9 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {

for (index, original_value) in original_values.iter().enumerate() {
// ...with the value `v_r` of that variable from the query.
let result_value = query_result
.substitute_projected(self.tcx, &result_subst,
|v| &v.var_values[CanonicalVar::new(index)]);
let result_value = query_result.substitute_projected(self.tcx, &result_subst, |v| {
&v.var_values[CanonicalVar::new(index)]
});
match (original_value.unpack(), result_value.unpack()) {
(UnpackedKind::Lifetime(ty::ReErased), UnpackedKind::Lifetime(ty::ReErased)) => {
// no action needed
Expand Down Expand Up @@ -312,11 +314,13 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
// ...also include the other query region constraints from the query.
output_query_region_constraints.reserve(query_result.value.region_constraints.len());
for r_c in query_result.value.region_constraints.iter() {
output_query_region_constraints.push(r_c.map_bound(|ty::OutlivesPredicate(k1, r2)| {
let k1 = substitute_value(self.tcx, &result_subst, &k1);
let r2 = substitute_value(self.tcx, &result_subst, &r2);
ty::OutlivesPredicate(k1, r2)
}));
let &ty::OutlivesPredicate(k1, r2) = r_c.skip_binder(); // reconstructed below
let k1 = substitute_value(self.tcx, &result_subst, &k1);
let r2 = substitute_value(self.tcx, &result_subst, &r2);
if k1 != r2.into() {
output_query_region_constraints
.push(ty::Binder::bind(ty::OutlivesPredicate(k1, r2)));
}
}

let user_result: R =
Expand Down
216 changes: 0 additions & 216 deletions src/librustc/infer/outlives/bounds.rs

This file was deleted.

4 changes: 2 additions & 2 deletions src/librustc/infer/outlives/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use infer::{GenericKind, InferCtxt};
use infer::outlives::free_region_map::FreeRegionMap;
use infer::outlives::bounds::{self, OutlivesBound};
use traits::query::outlives_bounds::{self, OutlivesBound};
use ty::{self, Ty};

use syntax::ast;
Expand Down Expand Up @@ -50,7 +50,7 @@ impl<'a, 'gcx: 'tcx, 'tcx: 'a> OutlivesEnvironment<'tcx> {
region_bound_pairs: vec![],
};

env.add_outlives_bounds(None, bounds::explicit_outlives_bounds(param_env));
env.add_outlives_bounds(None, outlives_bounds::explicit_outlives_bounds(param_env));

env
}
Expand Down
1 change: 0 additions & 1 deletion src/librustc/infer/outlives/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@

pub mod env;
pub mod free_region_map;
pub mod bounds;
pub mod obligations;
1 change: 1 addition & 0 deletions src/librustc/traits/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub mod dropck_outlives;
pub mod evaluate_obligation;
pub mod normalize;
pub mod normalize_erasing_regions;
pub mod outlives_bounds;
pub mod type_op;

pub type CanonicalProjectionGoal<'tcx> =
Expand Down
Loading

0 comments on commit d941658

Please sign in to comment.