diff options
| author | Ariel Ben-Yehuda <ariel.byd@gmail.com> | 2017-11-23 23:21:56 +0200 |
|---|---|---|
| committer | Ariel Ben-Yehuda <ariel.byd@gmail.com> | 2017-11-25 22:57:59 +0200 |
| commit | ebd219ab8e7be56020436f9c6d6a44c6d4f4a5cf (patch) | |
| tree | 74cb1787931331958c1225d14ac31ce8f0ed1f1e | |
| parent | d049e5d19e4058dfdbf1ce54770a0e3ca36e5dd3 (diff) | |
| download | rust-ebd219ab8e7be56020436f9c6d6a44c6d4f4a5cf.tar.gz rust-ebd219ab8e7be56020436f9c6d6a44c6d4f4a5cf.zip | |
comments
| -rw-r--r-- | src/librustc/infer/outlives/obligations.rs | 12 | ||||
| -rw-r--r-- | src/librustc/traits/mod.rs | 31 | ||||
| -rw-r--r-- | src/librustc/traits/specialize/mod.rs | 11 |
3 files changed, 31 insertions, 23 deletions
diff --git a/src/librustc/infer/outlives/obligations.rs b/src/librustc/infer/outlives/obligations.rs index 221d378d621..3c3aba372fb 100644 --- a/src/librustc/infer/outlives/obligations.rs +++ b/src/librustc/infer/outlives/obligations.rs @@ -181,18 +181,6 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { TypeOutlives::new(self, region_bound_pairs, implicit_region_bound, param_env); outlives.type_must_outlive(origin, ty, region); } - - /// Ignore the region obligations, not bothering to prove - /// them. This function should not really exist; it is used to - /// accommodate some older code for the time being. - pub fn ignore_region_obligations(&self) { - assert!( - !self.in_snapshot.get(), - "cannot ignore registered region obligations in a snapshot" - ); - - self.region_obligations.borrow_mut().clear(); - } } #[must_use] // you ought to invoke `into_accrued_obligations` when you are done =) diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index 55bd10e9225..a3a5c26ec18 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -431,6 +431,9 @@ pub fn type_known_to_meet_bound<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx // this function's result remains infallible, we must confirm // that guess. While imperfect, I believe this is sound. + // The handling of regions in this area of the code is terrible, + // see issue #29149. We should be able to improve on this with + // NLL. let mut fulfill_cx = FulfillmentContext::new_ignoring_regions(); // We can use a dummy node-id here because we won't pay any mind @@ -511,8 +514,24 @@ pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, unnormalized_env.reveal); tcx.infer_ctxt().enter(|infcx| { - let predicates = match fully_normalize( + // FIXME. We should really... do something with these region + // obligations. But this call just continues the older + // behavior (i.e., doesn't cause any new bugs), and it would + // take some further refactoring to actually solve them. In + // particular, we would have to handle implied bounds + // properly, and that code is currently largely confined to + // regionck (though I made some efforts to extract it + // out). -nmatsakis + // + // @arielby: In any case, these obligations are checked + // by wfcheck anyway, so I'm not sure we have to check + // them here too, and we will remove this function when + // we move over to lazy normalization *anyway*. + let fulfill_cx = FulfillmentContext::new_ignoring_regions(); + + let predicates = match fully_normalize_with_fulfillcx( &infcx, + fulfill_cx, cause, elaborated_env, // You would really want to pass infcx.param_env.caller_bounds here, @@ -537,16 +556,6 @@ pub fn normalize_param_env_or_error<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let region_scope_tree = region::ScopeTree::default(); let free_regions = FreeRegionMap::new(); - // FIXME. We should really... do something with these region - // obligations. But this call just continues the older - // behavior (i.e., doesn't cause any new bugs), and it would - // take some further refactoring to actually solve them. In - // particular, we would have to handle implied bounds - // properly, and that code is currently largely confined to - // regionck (though I made some efforts to extract it - // out). -nmatsakis - let _ = infcx.ignore_region_obligations(); - infcx.resolve_regions_and_report_errors(region_context, ®ion_scope_tree, &free_regions); let predicates = match infcx.fully_resolve(&predicates) { Ok(predicates) => predicates, diff --git a/src/librustc/traits/specialize/mod.rs b/src/librustc/traits/specialize/mod.rs index f83e131c327..1b5b0d35ba3 100644 --- a/src/librustc/traits/specialize/mod.rs +++ b/src/librustc/traits/specialize/mod.rs @@ -241,6 +241,17 @@ fn fulfill_implication<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>, // (which are packed up in penv) infcx.save_and_restore_in_snapshot_flag(|infcx| { + // If we came from `translate_substs`, we already know that the + // predicates for our impl hold (after all, we know that a more + // specialized impl holds, so our impl must hold too), and + // we only want to process the projections to determine the + // the types in our substs using RFC 447, so we can safely + // ignore region obligations, which allows us to avoid threading + // a node-id to assign them with. + // + // If we came from specialization graph construction, then + // we already make a mockery out of the region system, so + // why not ignore them a bit earlier? let mut fulfill_cx = FulfillmentContext::new_ignoring_regions(); for oblig in obligations.into_iter() { fulfill_cx.register_predicate_obligation(&infcx, oblig); |
