]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_mir/build/expr/as_lvalue.rs
Rollup merge of #41249 - GuillaumeGomez:rustdoc-render, r=steveklabnik,frewsxcv
[rust.git] / src / librustc_mir / build / expr / as_lvalue.rs
index 0487e277a338bb84ebfe0634ffb4ab76031e698c..df2841a66826980d6cd1ae96739c3ed4cba53b05 100644 (file)
@@ -56,11 +56,14 @@ fn expr_as_lvalue(&mut self,
                 let (usize_ty, bool_ty) = (this.hir.usize_ty(), this.hir.bool_ty());
 
                 let slice = unpack!(block = this.as_lvalue(block, lhs));
-
-                let idx = unpack!(block = this.as_operand(block, index));
+                // extent=None so lvalue indexes live forever. They are scalars so they
+                // do not need storage annotations, and they are often copied between
+                // places.
+                let idx = unpack!(block = this.as_operand(block, None, index));
 
                 // bounds check:
-                let (len, lt) = (this.temp(usize_ty.clone()), this.temp(bool_ty));
+                let (len, lt) = (this.temp(usize_ty.clone(), expr_span),
+                                 this.temp(bool_ty, expr_span));
                 this.cfg.push_assign(block, source_info, // len = len(slice)
                                      &len, Rvalue::Len(slice.clone()));
                 this.cfg.push_assign(block, source_info, // lt = idx < len
@@ -84,7 +87,7 @@ fn expr_as_lvalue(&mut self,
                 block.and(Lvalue::Local(index))
             }
             ExprKind::StaticRef { id } => {
-                block.and(Lvalue::Static(id))
+                block.and(Lvalue::Static(Box::new(Static { def_id: id, ty: expr.ty })))
             }
 
             ExprKind::Array { .. } |
@@ -99,6 +102,7 @@ fn expr_as_lvalue(&mut self,
             ExprKind::Use { .. } |
             ExprKind::NeverToAny { .. } |
             ExprKind::ReifyFnPointer { .. } |
+            ExprKind::ClosureFnPointer { .. } |
             ExprKind::UnsafeFnPointer { .. } |
             ExprKind::Unsize { .. } |
             ExprKind::Repeat { .. } |
@@ -120,7 +124,7 @@ fn expr_as_lvalue(&mut self,
                     Some(Category::Lvalue) => false,
                     _ => true,
                 });
-                this.as_temp(block, expr)
+                this.as_temp(block, expr.temp_lifetime, expr)
             }
         }
     }