@@ -4,7 +4,6 @@ use crate::build::expr::category::Category;
4
4
use crate :: build:: ForGuard :: { OutsideGuard , RefWithinGuard } ;
5
5
use crate :: build:: { BlockAnd , BlockAndExtension , Builder , Capture , CaptureMap } ;
6
6
use rustc_hir:: def_id:: LocalDefId ;
7
- use rustc_middle:: bug;
8
7
use rustc_middle:: hir:: place:: Projection as HirProjection ;
9
8
use rustc_middle:: hir:: place:: ProjectionKind as HirProjectionKind ;
10
9
use rustc_middle:: middle:: region;
@@ -13,6 +12,7 @@ use rustc_middle::mir::*;
13
12
use rustc_middle:: thir:: * ;
14
13
use rustc_middle:: ty:: AdtDef ;
15
14
use rustc_middle:: ty:: { self , CanonicalUserTypeAnnotation , Ty , Variance } ;
15
+ use rustc_middle:: { bug, span_bug} ;
16
16
use rustc_span:: Span ;
17
17
use rustc_target:: abi:: { FieldIdx , VariantIdx , FIRST_VARIANT } ;
18
18
use tracing:: { debug, instrument, trace} ;
@@ -252,7 +252,18 @@ fn strip_prefix<'a, 'tcx>(
252
252
253
253
impl < ' tcx > PlaceBuilder < ' tcx > {
254
254
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
+ } )
256
267
}
257
268
258
269
/// Creates a `Place` or returns `None` if an upvar cannot be resolved
0 commit comments