@@ -463,62 +463,60 @@ impl FunctionCx<'a, 'll, 'tcx> {
463463 }
464464 } ;
465465
466- if !place. has_no_projection ( ) {
467- let tcx = cx. tcx ;
468- for ( i, elem) in place. elems . iter ( ) . cloned ( ) . enumerate ( ) . rev ( ) {
469- let base = place. elem_base ( tcx, i) ;
470- result = match elem {
471- mir:: ProjectionElem :: Deref => {
472- // Load the pointer from its location.
473- self . codegen_consume ( bx, & base) . deref ( bx. cx )
474- }
475- mir:: ProjectionElem :: Field ( ref field, _) => {
476- result. project_field ( bx, field. index ( ) )
477- }
478- mir:: ProjectionElem :: Index ( index) => {
479- let index = & mir:: Operand :: Copy ( mir:: Place :: local ( index) ) ;
480- let index = self . codegen_operand ( bx, index) ;
481- let llindex = index. immediate ( ) ;
482- result. project_index ( bx, llindex)
483- }
484- mir:: ProjectionElem :: ConstantIndex { offset,
485- from_end : false ,
486- min_length : _ } => {
487- let lloffset = C_usize ( bx. cx , offset as u64 ) ;
488- result. project_index ( bx, lloffset)
489- }
490- mir:: ProjectionElem :: ConstantIndex { offset,
491- from_end : true ,
492- min_length : _ } => {
493- let lloffset = C_usize ( bx. cx , offset as u64 ) ;
494- let lllen = result. len ( bx. cx ) ;
495- let llindex = bx. sub ( lllen, lloffset) ;
496- result. project_index ( bx, llindex)
466+ let tcx = cx. tcx ;
467+ for ( i, elem) in place. elems . iter ( ) . cloned ( ) . enumerate ( ) . rev ( ) {
468+ let base = place. elem_base ( tcx, i) ;
469+ result = match elem {
470+ mir:: ProjectionElem :: Deref => {
471+ // Load the pointer from its location.
472+ self . codegen_consume ( bx, & base) . deref ( bx. cx )
473+ }
474+ mir:: ProjectionElem :: Field ( ref field, _) => {
475+ result. project_field ( bx, field. index ( ) )
476+ }
477+ mir:: ProjectionElem :: Index ( index) => {
478+ let index = & mir:: Operand :: Copy ( mir:: Place :: local ( index) ) ;
479+ let index = self . codegen_operand ( bx, index) ;
480+ let llindex = index. immediate ( ) ;
481+ result. project_index ( bx, llindex)
482+ }
483+ mir:: ProjectionElem :: ConstantIndex { offset,
484+ from_end : false ,
485+ min_length : _ } => {
486+ let lloffset = C_usize ( bx. cx , offset as u64 ) ;
487+ result. project_index ( bx, lloffset)
488+ }
489+ mir:: ProjectionElem :: ConstantIndex { offset,
490+ from_end : true ,
491+ min_length : _ } => {
492+ let lloffset = C_usize ( bx. cx , offset as u64 ) ;
493+ let lllen = result. len ( bx. cx ) ;
494+ let llindex = bx. sub ( lllen, lloffset) ;
495+ result. project_index ( bx, llindex)
496+ }
497+ mir:: ProjectionElem :: Subslice { from, to } => {
498+ let mut subslice = result. project_index ( bx,
499+ C_usize ( bx. cx , from as u64 ) ) ;
500+ let projected_ty = PlaceTy :: Ty { ty : result. layout . ty }
501+ . projection_ty ( tcx, & elem) . to_ty ( bx. tcx ( ) ) ;
502+ subslice. layout = bx. cx . layout_of ( self . monomorphize ( & projected_ty) ) ;
503+
504+ if subslice. layout . is_unsized ( ) {
505+ subslice. llextra = Some ( bx. sub ( result. llextra . unwrap ( ) ,
506+ C_usize ( bx. cx , ( from as u64 ) + ( to as u64 ) ) ) ) ;
497507 }
498- mir:: ProjectionElem :: Subslice { from, to } => {
499- let mut subslice = result. project_index ( bx,
500- C_usize ( bx. cx , from as u64 ) ) ;
501- let projected_ty = PlaceTy :: Ty { ty : result. layout . ty }
502- . projection_ty ( tcx, & elem) . to_ty ( bx. tcx ( ) ) ;
503- subslice. layout = bx. cx . layout_of ( self . monomorphize ( & projected_ty) ) ;
504-
505- if subslice. layout . is_unsized ( ) {
506- subslice. llextra = Some ( bx. sub ( result. llextra . unwrap ( ) ,
507- C_usize ( bx. cx , ( from as u64 ) + ( to as u64 ) ) ) ) ;
508- }
509508
510- // Cast the place pointer type to the new
511- // array or slice type (*[%_; new_len]).
512- subslice. llval = bx. pointercast ( subslice. llval ,
513- subslice. layout . llvm_type ( bx. cx ) . ptr_to ( ) ) ;
509+ // Cast the place pointer type to the new
510+ // array or slice type (*[%_; new_len]).
511+ subslice. llval = bx. pointercast ( subslice. llval ,
512+ subslice. layout . llvm_type ( bx. cx ) . ptr_to ( ) ) ;
514513
515- subslice
516- }
517- mir:: ProjectionElem :: Downcast ( _, v) => {
518- result. project_downcast ( bx, v)
519- }
520- } ;
521- }
514+ subslice
515+ }
516+ mir:: ProjectionElem :: Downcast ( _, v) => {
517+ result. project_downcast ( bx, v)
518+ }
519+ } ;
522520 }
523521 debug ! ( "codegen_place(place={:?}) => {:?}" , place, result) ;
524522 result
0 commit comments