@@ -16,7 +16,7 @@ use rustc_macros::{HashStable, TyDecodable, TyEncodable};
1616use rustc_span:: { DUMMY_SP , Span } ;
1717use tracing:: debug;
1818
19- use crate :: ty:: TyCtxt ;
19+ use crate :: ty:: { self , TyCtxt } ;
2020
2121/// Represents a statically-describable scope that can be used to
2222/// bound the lifetime/region for values.
@@ -302,20 +302,20 @@ impl ScopeTree {
302302
303303 /// Returns the scope of non-lifetime-extended temporaries within a given scope, as well as
304304 /// whether we've recorded a potential backwards-incompatible change to lint on.
305- /// Returns `None` when no enclosing temporary scope is found, such as for static items .
306- pub fn default_temporary_scope ( & self , inner : Scope ) -> ( Option < Scope > , Option < Scope > ) {
305+ /// Panics if no enclosing temporary scope is found.
306+ pub fn default_temporary_scope ( & self , inner : Scope ) -> ( Scope , Option < Scope > ) {
307307 let mut id = inner;
308308 let mut backwards_incompatible = None ;
309309
310310 while let Some ( & p) = self . parent_map . get ( & id) {
311311 match p. data {
312312 ScopeData :: Destruction => {
313313 debug ! ( "temporary_scope({inner:?}) = {id:?} [enclosing]" ) ;
314- return ( Some ( id ) , backwards_incompatible) ;
314+ return ( id , backwards_incompatible) ;
315315 }
316316 ScopeData :: IfThenRescope | ScopeData :: MatchGuard => {
317317 debug ! ( "temporary_scope({inner:?}) = {p:?} [enclosing]" ) ;
318- return ( Some ( p ) , backwards_incompatible) ;
318+ return ( p , backwards_incompatible) ;
319319 }
320320 ScopeData :: Node
321321 | ScopeData :: CallSite
@@ -335,7 +335,6 @@ impl ScopeTree {
335335 }
336336 }
337337
338- debug ! ( "temporary_scope({inner:?}) = None" ) ;
339- ( None , backwards_incompatible)
338+ span_bug ! ( ty:: tls:: with( |tcx| inner. span( tcx, self ) ) , "no enclosing temporary scope" )
340339 }
341340}
0 commit comments