From 8e4132a55c625de8ba431a4e9fe72339c777e96a Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Fri, 24 May 2019 14:01:07 +0200 Subject: [PATCH] Delay ICE in early_free_scope so feature gate has chance to stop compilation cleanly. --- src/librustc/middle/region.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index fa4e8e3d476..3d78b9b6382 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -658,12 +658,15 @@ impl<'tcx> ScopeTree { // The lifetime was defined on node that doesn't own a body, // which in practice can only mean a trait or an impl, that // is the parent of a method, and that is enforced below. - assert_eq!(Some(param_owner_id), self.root_parent, - "free_scope: {:?} not recognized by the \ - region scope tree for {:?} / {:?}", - param_owner, - self.root_parent.map(|id| tcx.hir().local_def_id_from_hir_id(id)), - self.root_body.map(|hir_id| DefId::local(hir_id.owner))); + if Some(param_owner_id) != self.root_parent { + tcx.sess.delay_span_bug( + DUMMY_SP, + &format!("free_scope: {:?} not recognized by the \ + region scope tree for {:?} / {:?}", + param_owner, + self.root_parent.map(|id| tcx.hir().local_def_id_from_hir_id(id)), + self.root_body.map(|hir_id| DefId::local(hir_id.owner)))); + } // The trait/impl lifetime is in scope for the method's body. self.root_body.unwrap().local_id