Skip to content

Commit 0b88103

Browse files
committed
skip no-op obligations and add a little debug output
1 parent e5286d9 commit 0b88103

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

src/librustc/infer/canonical/query_result.rs

Lines changed: 14 additions & 10 deletions
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/traits/query/outlives_bounds.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
103103
ty: Ty<'tcx>,
104104
span: Span,
105105
) -> Vec<OutlivesBound<'tcx>> {
106+
debug!("implied_outlives_bounds(ty = {:?})", ty);
107+
106108
let mut orig_values = SmallVec::new();
107109
let key = self.canonicalize_query(&param_env.and(ty), &mut orig_values);
108110
let result = match self.tcx.global_tcx().implied_outlives_bounds(key) {
@@ -119,7 +121,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
119121

120122
let result = self.instantiate_query_result_and_region_obligations(
121123
&ObligationCause::dummy(), param_env, &orig_values, &result);
122-
debug!("implied_outlives_bounds for {:?}: {:?}", ty, result);
124+
debug!("implied_outlives_bounds for {:?}: {:#?}", ty, result);
123125
let result = match result {
124126
Ok(v) => v,
125127
Err(_) => {

0 commit comments

Comments
 (0)