@@ -9,6 +9,7 @@ use rustc::mir::visit::{Visitor, PlaceContext, MutatingUseContext, NonMutatingUs
99use  rustc:: mir:: traversal; 
1010use  rustc:: ty; 
1111use  rustc:: ty:: layout:: { LayoutOf ,  HasTyCtxt } ; 
12+ use  syntax_pos:: DUMMY_SP ; 
1213use  super :: FunctionCx ; 
1314use  crate :: traits:: * ; 
1415
@@ -20,10 +21,13 @@ pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
2021
2122    analyzer. visit_body ( mir) ; 
2223
23-     for  ( index,  ty)  in  mir. local_decls . iter ( ) . map ( |l| l. ty ) . enumerate ( )  { 
24+     for  ( index,  ( ty,  span) )  in  mir. local_decls . iter ( ) 
25+         . map ( |l| ( l. ty ,  l. source_info . span ) ) 
26+         . enumerate ( ) 
27+     { 
2428        let  ty = fx. monomorphize ( & ty) ; 
2529        debug ! ( "local {} has type {:?}" ,  index,  ty) ; 
26-         let  layout = fx. cx . layout_of ( ty) ; 
30+         let  layout = fx. cx . spanned_layout_of ( ty,  span ) ; 
2731        if  fx. cx . is_backend_immediate ( layout)  { 
2832            // These sorts of types are immediates that we can store 
2933            // in an Value without an alloca. 
@@ -93,10 +97,12 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
9397        } 
9498    } 
9599
96-     fn  process_place ( & mut  self , 
97-                      place_ref :  & mir:: PlaceRef < ' _ ,  ' tcx > , 
98-                      context :  PlaceContext , 
99-                      location :  Location )  { 
100+     fn  process_place ( 
101+         & mut  self , 
102+         place_ref :  & mir:: PlaceRef < ' _ ,  ' tcx > , 
103+         context :  PlaceContext , 
104+         location :  Location , 
105+     )  { 
100106        let  cx = self . fx . cx ; 
101107
102108        if  let  Some ( proj)  = place_ref. projection  { 
@@ -116,12 +122,17 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
116122                    . projection_ty ( cx. tcx ( ) ,  & proj. elem ) 
117123                    . ty ; 
118124                let  elem_ty = self . fx . monomorphize ( & elem_ty) ; 
119-                 if  cx. layout_of ( elem_ty) . is_zst ( )  { 
125+                 let  span = if  let  mir:: PlaceBase :: Local ( index)  = place_ref. base  { 
126+                     self . fx . mir . local_decls [ * index] . source_info . span 
127+                 }  else  { 
128+                     DUMMY_SP 
129+                 } ; 
130+                 if  cx. spanned_layout_of ( elem_ty,  span) . is_zst ( )  { 
120131                    return ; 
121132                } 
122133
123134                if  let  mir:: ProjectionElem :: Field ( ..)  = proj. elem  { 
124-                     let  layout = cx. layout_of ( base_ty. ty ) ; 
135+                     let  layout = cx. spanned_layout_of ( base_ty. ty ,  span ) ; 
125136                    if  cx. is_backend_immediate ( layout)  || cx. is_backend_scalar_pair ( layout)  { 
126137                        // Recurse with the same context, instead of `Projection`, 
127138                        // potentially stopping at non-operand projections, 
@@ -188,7 +199,8 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
188199            projection :  None , 
189200        }  = * place { 
190201            self . assign ( index,  location) ; 
191-             if  !self . fx . rvalue_creates_operand ( rvalue)  { 
202+             let  decl_span = self . fx . mir . local_decls [ index] . source_info . span ; 
203+             if  !self . fx . rvalue_creates_operand ( rvalue,  decl_span)  { 
192204                self . not_ssa ( index) ; 
193205            } 
194206        }  else  { 
0 commit comments