introduce QueryRegionConstraints struct (no-op)

This commit is contained in:
Niko Matsakis 2019-06-03 17:39:52 -04:00
parent fd5f7673a7
commit 7e66a96d58
3 changed files with 30 additions and 9 deletions

View File

@ -189,11 +189,16 @@ pub enum CanonicalTyVarKind {
#[derive(Clone, Debug, HashStable)]
pub struct QueryResponse<'tcx, R> {
pub var_values: CanonicalVarValues<'tcx>,
pub region_constraints: Vec<QueryOutlivesConstraint<'tcx>>,
pub region_constraints: QueryRegionConstraints<'tcx>,
pub certainty: Certainty,
pub value: R,
}
#[derive(Clone, Debug, Default, HashStable)]
pub struct QueryRegionConstraints<'tcx> {
outlives: Vec<QueryOutlivesConstraint<'tcx>>,
}
pub type Canonicalized<'tcx, V> = Canonical<'tcx, V>;
pub type CanonicalizedQueryResponse<'tcx, T> =
@ -540,6 +545,19 @@ BraceStructLiftImpl! {
} where R: Lift<'tcx>
}
BraceStructTypeFoldableImpl! {
impl<'tcx> TypeFoldable<'tcx> for QueryRegionConstraints<'tcx> {
outlives
}
}
BraceStructLiftImpl! {
impl<'a, 'tcx> Lift<'tcx> for QueryRegionConstraints<'a> {
type Lifted = QueryRegionConstraints<'tcx>;
outlives
}
}
impl<'tcx> Index<BoundVar> for CanonicalVarValues<'tcx> {
type Output = Kind<'tcx>;

View File

@ -11,7 +11,7 @@ use crate::arena::ArenaAllocatable;
use crate::infer::canonical::substitute::substitute_value;
use crate::infer::canonical::{
Canonical, CanonicalVarValues, CanonicalizedQueryResponse, Certainty,
OriginalQueryValues, QueryOutlivesConstraint, QueryResponse,
OriginalQueryValues, QueryRegionConstraints, QueryOutlivesConstraint, QueryResponse,
};
use crate::infer::region_constraints::{Constraint, RegionConstraintData};
use crate::infer::InferCtxtBuilder;
@ -132,7 +132,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
{
self.canonicalize_response(&QueryResponse {
var_values: inference_vars,
region_constraints: vec![],
region_constraints: QueryRegionConstraints::default(),
certainty: Certainty::Proven, // Ambiguities are OK!
value: answer,
})
@ -173,7 +173,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
debug!("ambig_errors = {:#?}", ambig_errors);
let region_obligations = self.take_registered_region_obligations();
let region_constraints = self.with_region_constraints(|region_constraints| {
let outlives_constraints = self.with_region_constraints(|region_constraints| {
make_query_outlives(
tcx,
region_obligations
@ -191,7 +191,9 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
Ok(QueryResponse {
var_values: inference_vars,
region_constraints,
region_constraints: QueryRegionConstraints {
outlives: outlives_constraints,
},
certainty,
value: answer,
})
@ -225,7 +227,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
obligations.extend(self.query_outlives_constraints_into_obligations(
cause,
param_env,
&query_response.value.region_constraints,
&query_response.value.region_constraints.outlives,
&result_subst,
));
@ -334,7 +336,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
// ...also include the other query region constraints from the query.
output_query_outlives_constraints.extend(
query_response.value.region_constraints.iter().filter_map(|r_c| {
query_response.value.region_constraints.outlives.iter().filter_map(|r_c| {
let r_c = substitute_value(self.tcx, &result_subst, r_c);
// Screen out `'a: 'a` cases -- we skip the binder here but

View File

@ -17,6 +17,7 @@ use rustc::infer::canonical::{
CanonicalVarValues,
OriginalQueryValues,
QueryResponse,
QueryRegionConstraints,
Certainty,
};
use rustc::traits::{
@ -151,14 +152,14 @@ impl context::AggregateOps<ChalkArenas<'tcx>> for ChalkContext<'tcx> {
let solution = constrained_subst.unchecked_map(|cs| match ambiguous {
true => QueryResponse {
var_values: cs.subst.make_identity(self.tcx),
region_constraints: Vec::new(),
region_constraints: QueryRegionConstraints::default(),
certainty: Certainty::Ambiguous,
value: (),
},
false => QueryResponse {
var_values: cs.subst,
region_constraints: Vec::new(),
region_constraints: QueryRegionConstraints::default(),
// FIXME: restore this later once we get better at handling regions
// region_constraints: cs.constraints