@@ -4,7 +4,6 @@ use crate::build::expr::category::Category;
44use crate :: build:: ForGuard :: { OutsideGuard , RefWithinGuard } ;
55use crate :: build:: { BlockAnd , BlockAndExtension , Builder , Capture , CaptureMap } ;
66use rustc_hir:: def_id:: LocalDefId ;
7- use rustc_middle:: bug;
87use rustc_middle:: hir:: place:: Projection as HirProjection ;
98use rustc_middle:: hir:: place:: ProjectionKind as HirProjectionKind ;
109use rustc_middle:: middle:: region;
@@ -13,6 +12,7 @@ use rustc_middle::mir::*;
1312use rustc_middle:: thir:: * ;
1413use rustc_middle:: ty:: AdtDef ;
1514use rustc_middle:: ty:: { self , CanonicalUserTypeAnnotation , Ty , Variance } ;
15+ use rustc_middle:: { bug, span_bug} ;
1616use rustc_span:: Span ;
1717use rustc_target:: abi:: { FieldIdx , VariantIdx , FIRST_VARIANT } ;
1818use tracing:: { debug, instrument, trace} ;
@@ -252,7 +252,18 @@ fn strip_prefix<'a, 'tcx>(
252252
253253impl < ' tcx > PlaceBuilder < ' tcx > {
254254 pub ( in crate :: build) fn to_place ( & self , cx : & Builder < ' _ , ' tcx > ) -> Place < ' tcx > {
255- self . try_to_place ( cx) . unwrap ( )
255+ self . try_to_place ( cx) . unwrap_or_else ( || match self . base {
256+ PlaceBase :: Local ( local) => span_bug ! (
257+ cx. local_decls[ local] . source_info. span,
258+ "could not resolve local: {local:#?} + {:?}" ,
259+ self . projection
260+ ) ,
261+ PlaceBase :: Upvar { var_hir_id, closure_def_id : _ } => span_bug ! (
262+ cx. tcx. hir( ) . span( var_hir_id. 0 ) ,
263+ "could not resolve upvar: {var_hir_id:?} + {:?}" ,
264+ self . projection
265+ ) ,
266+ } )
256267 }
257268
258269 /// Creates a `Place` or returns `None` if an upvar cannot be resolved
0 commit comments