Skip to content

Commit 8e4132a

Browse files
committed
Delay ICE in early_free_scope so feature gate has chance to stop compilation cleanly.
1 parent 698e50f commit 8e4132a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/librustc/middle/region.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -658,12 +658,15 @@ impl<'tcx> ScopeTree {
658658
// The lifetime was defined on node that doesn't own a body,
659659
// which in practice can only mean a trait or an impl, that
660660
// is the parent of a method, and that is enforced below.
661-
assert_eq!(Some(param_owner_id), self.root_parent,
662-
"free_scope: {:?} not recognized by the \
663-
region scope tree for {:?} / {:?}",
664-
param_owner,
665-
self.root_parent.map(|id| tcx.hir().local_def_id_from_hir_id(id)),
666-
self.root_body.map(|hir_id| DefId::local(hir_id.owner)));
661+
if Some(param_owner_id) != self.root_parent {
662+
tcx.sess.delay_span_bug(
663+
DUMMY_SP,
664+
&format!("free_scope: {:?} not recognized by the \
665+
region scope tree for {:?} / {:?}",
666+
param_owner,
667+
self.root_parent.map(|id| tcx.hir().local_def_id_from_hir_id(id)),
668+
self.root_body.map(|hir_id| DefId::local(hir_id.owner))));
669+
}
667670

668671
// The trait/impl lifetime is in scope for the method's body.
669672
self.root_body.unwrap().local_id

0 commit comments

Comments
 (0)