Skip to content

Commit ebd219a

Browse files
committed
comments
1 parent d049e5d commit ebd219a

File tree

3 files changed

+31
-23
lines changed

3 files changed

+31
-23
lines changed

src/librustc/infer/outlives/obligations.rs

-12
Original file line numberDiff line numberDiff line change
@@ -181,18 +181,6 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
181181
TypeOutlives::new(self, region_bound_pairs, implicit_region_bound, param_env);
182182
outlives.type_must_outlive(origin, ty, region);
183183
}
184-
185-
/// Ignore the region obligations, not bothering to prove
186-
/// them. This function should not really exist; it is used to
187-
/// accommodate some older code for the time being.
188-
pub fn ignore_region_obligations(&self) {
189-
assert!(
190-
!self.in_snapshot.get(),
191-
"cannot ignore registered region obligations in a snapshot"
192-
);
193-
194-
self.region_obligations.borrow_mut().clear();
195-
}
196184
}
197185

198186
#[must_use] // you ought to invoke `into_accrued_obligations` when you are done =)

src/librustc/traits/mod.rs

+20-11
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,9 @@ pub fn type_known_to_meet_bound<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx
431431
// this function's result remains infallible, we must confirm
432432
// that guess. While imperfect, I believe this is sound.
433433

434+
// The handling of regions in this area of the code is terrible,
435+
// see issue #29149. We should be able to improve on this with
436+
// NLL.
434437
let mut fulfill_cx = FulfillmentContext::new_ignoring_regions();
435438

436439
// 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>,
511514
unnormalized_env.reveal);
512515

513516
tcx.infer_ctxt().enter(|infcx| {
514-
let predicates = match fully_normalize(
517+
// FIXME. We should really... do something with these region
518+
// obligations. But this call just continues the older
519+
// behavior (i.e., doesn't cause any new bugs), and it would
520+
// take some further refactoring to actually solve them. In
521+
// particular, we would have to handle implied bounds
522+
// properly, and that code is currently largely confined to
523+
// regionck (though I made some efforts to extract it
524+
// out). -nmatsakis
525+
//
526+
// @arielby: In any case, these obligations are checked
527+
// by wfcheck anyway, so I'm not sure we have to check
528+
// them here too, and we will remove this function when
529+
// we move over to lazy normalization *anyway*.
530+
let fulfill_cx = FulfillmentContext::new_ignoring_regions();
531+
532+
let predicates = match fully_normalize_with_fulfillcx(
515533
&infcx,
534+
fulfill_cx,
516535
cause,
517536
elaborated_env,
518537
// 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>,
537556
let region_scope_tree = region::ScopeTree::default();
538557
let free_regions = FreeRegionMap::new();
539558

540-
// FIXME. We should really... do something with these region
541-
// obligations. But this call just continues the older
542-
// behavior (i.e., doesn't cause any new bugs), and it would
543-
// take some further refactoring to actually solve them. In
544-
// particular, we would have to handle implied bounds
545-
// properly, and that code is currently largely confined to
546-
// regionck (though I made some efforts to extract it
547-
// out). -nmatsakis
548-
let _ = infcx.ignore_region_obligations();
549-
550559
infcx.resolve_regions_and_report_errors(region_context, &region_scope_tree, &free_regions);
551560
let predicates = match infcx.fully_resolve(&predicates) {
552561
Ok(predicates) => predicates,

src/librustc/traits/specialize/mod.rs

+11
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,17 @@ fn fulfill_implication<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
241241
// (which are packed up in penv)
242242

243243
infcx.save_and_restore_in_snapshot_flag(|infcx| {
244+
// If we came from `translate_substs`, we already know that the
245+
// predicates for our impl hold (after all, we know that a more
246+
// specialized impl holds, so our impl must hold too), and
247+
// we only want to process the projections to determine the
248+
// the types in our substs using RFC 447, so we can safely
249+
// ignore region obligations, which allows us to avoid threading
250+
// a node-id to assign them with.
251+
//
252+
// If we came from specialization graph construction, then
253+
// we already make a mockery out of the region system, so
254+
// why not ignore them a bit earlier?
244255
let mut fulfill_cx = FulfillmentContext::new_ignoring_regions();
245256
for oblig in obligations.into_iter() {
246257
fulfill_cx.register_predicate_obligation(&infcx, oblig);

0 commit comments

Comments
 (0)