about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/mir/mod.rs15
-rw-r--r--src/librustc_mir/build/expr/as_rvalue.rs4
-rw-r--r--src/librustc_mir/build/mod.rs21
3 files changed, 20 insertions, 20 deletions
diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs
index 555374a138c..7c432c9c7eb 100644
--- a/src/librustc/mir/mod.rs
+++ b/src/librustc/mir/mod.rs
@@ -4,7 +4,7 @@
 
 use crate::hir::def::{CtorKind, Namespace};
 use crate::hir::def_id::DefId;
-use crate::hir::{self, HirId, InlineAsm as HirInlineAsm};
+use crate::hir::{self, InlineAsm as HirInlineAsm};
 use crate::mir::interpret::{ConstValue, InterpError, Scalar};
 use crate::mir::visit::MirVisitable;
 use rustc_apfloat::ieee::{Double, Single};
@@ -138,16 +138,16 @@ pub struct Mir<'tcx> {
     /// If this MIR was built for a constant, this will be 0.
     pub arg_count: usize,
 
-    /// Names and capture modes of all the closure upvars, assuming
-    /// the first argument is either the closure or a reference to it.
-    pub upvar_decls: Vec<UpvarDecl>,
-
     /// Mark an argument local (which must be a tuple) as getting passed as
     /// its individual components at the LLVM level.
     ///
     /// This is used for the "rust-call" ABI.
     pub spread_arg: Option<Local>,
 
+    /// Names and capture modes of all the closure upvars, assuming
+    /// the first argument is either the closure or a reference to it.
+    pub upvar_decls: Vec<UpvarDecl>,
+
     /// Mark this MIR of a const context other than const functions as having converted a `&&` or
     /// `||` expression into `&` or `|` respectively. This is problematic because if we ever stop
     /// this conversion from happening and use short circuiting, we will cause the following code
@@ -986,13 +986,8 @@ impl<'tcx> LocalDecl<'tcx> {
 pub struct UpvarDecl {
     pub debug_name: Name,
 
-    /// `HirId` of the captured variable
-    pub var_hir_id: ClearCrossCrate<HirId>,
-
     /// If true, the capture is behind a reference.
     pub by_ref: bool,
-
-    pub mutability: Mutability,
 }
 
 ///////////////////////////////////////////////////////////////////////////
diff --git a/src/librustc_mir/build/expr/as_rvalue.rs b/src/librustc_mir/build/expr/as_rvalue.rs
index b9fec22da63..c58b570d8fc 100644
--- a/src/librustc_mir/build/expr/as_rvalue.rs
+++ b/src/librustc_mir/build/expr/as_rvalue.rs
@@ -556,10 +556,10 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
                 );
                 // Not in a closure
                 debug_assert!(
-                    this.upvar_decls.len() > upvar_index.index(),
+                    this.upvar_mutbls.len() > upvar_index.index(),
                     "Unexpected capture place"
                 );
-                this.upvar_decls[upvar_index.index()].mutability
+                this.upvar_mutbls[upvar_index.index()]
             }
             _ => bug!("Unexpected capture place"),
         };
diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs
index 7fe86d11c9e..cd2fa10927f 100644
--- a/src/librustc_mir/build/mod.rs
+++ b/src/librustc_mir/build/mod.rs
@@ -376,6 +376,7 @@ struct Builder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
     local_decls: IndexVec<Local, LocalDecl<'tcx>>,
     canonical_user_type_annotations: ty::CanonicalUserTypeAnnotations<'tcx>,
     upvar_decls: Vec<UpvarDecl>,
+    upvar_mutbls: Vec<Mutability>,
     unit_temp: Option<Place<'tcx>>,
 
     /// Cached block with the `RESUME` terminator; this is created
@@ -625,6 +626,7 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
     let fn_def_id = tcx_hir.local_def_id_from_hir_id(fn_id);
 
     // Gather the upvars of a closure, if any.
+    let mut upvar_mutbls = vec![];
     // In analyze_closure() in upvar.rs we gathered a list of upvars used by a
     // closure and we stored in a map called upvar_list in TypeckTables indexed
     // with the closure's DefId. Here, we run through that vec of UpvarIds for
@@ -644,24 +646,24 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
             };
             let mut decl = UpvarDecl {
                 debug_name: keywords::Invalid.name(),
-                var_hir_id: ClearCrossCrate::Set(var_hir_id),
                 by_ref,
-                mutability: Mutability::Not,
             };
+            let mut mutability = Mutability::Not;
             if let Some(Node::Binding(pat)) = tcx_hir.find(var_node_id) {
                 if let hir::PatKind::Binding(_, _, ident, _) = pat.node {
                     decl.debug_name = ident.name;
                     if let Some(&bm) = hir.tables.pat_binding_modes().get(pat.hir_id) {
                         if bm == ty::BindByValue(hir::MutMutable) {
-                            decl.mutability = Mutability::Mut;
+                            mutability = Mutability::Mut;
                         } else {
-                            decl.mutability = Mutability::Not;
+                            mutability = Mutability::Not;
                         }
                     } else {
                         tcx.sess.delay_span_bug(pat.span, "missing binding mode");
                     }
                 }
             }
+            upvar_mutbls.push(mutability);
             decl
         })
         .collect();
@@ -672,7 +674,8 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
         safety,
         return_ty,
         return_ty_span,
-        upvar_decls);
+        upvar_decls,
+        upvar_mutbls);
 
     let call_site_scope = region::Scope {
         id: body.value.hir_id.local_id,
@@ -734,7 +737,7 @@ fn construct_const<'a, 'gcx, 'tcx>(
     let ty = hir.tables().expr_ty_adjusted(ast_expr);
     let owner_id = tcx.hir().body_owner(body_id);
     let span = tcx.hir().span(owner_id);
-    let mut builder = Builder::new(hir, span, 0, Safety::Safe, ty, ty_span,vec![]);
+    let mut builder = Builder::new(hir, span, 0, Safety::Safe, ty, ty_span, vec![], vec![]);
 
     let mut block = START_BLOCK;
     let expr = builder.hir.mirror(ast_expr);
@@ -762,7 +765,7 @@ fn construct_error<'a, 'gcx, 'tcx>(hir: Cx<'a, 'gcx, 'tcx>,
     let owner_id = hir.tcx().hir().body_owner(body_id);
     let span = hir.tcx().hir().span(owner_id);
     let ty = hir.tcx().types.err;
-    let mut builder = Builder::new(hir, span, 0, Safety::Safe, ty, span, vec![]);
+    let mut builder = Builder::new(hir, span, 0, Safety::Safe, ty, span, vec![], vec![]);
     let source_info = builder.source_info(span);
     builder.cfg.terminate(START_BLOCK, source_info, TerminatorKind::Unreachable);
     builder.finish(None)
@@ -775,7 +778,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
            safety: Safety,
            return_ty: Ty<'tcx>,
            return_span: Span,
-           upvar_decls: Vec<UpvarDecl>)
+           upvar_decls: Vec<UpvarDecl>,
+           upvar_mutbls: Vec<Mutability>)
            -> Builder<'a, 'gcx, 'tcx> {
         let lint_level = LintLevel::Explicit(hir.root_lint_level);
         let mut builder = Builder {
@@ -798,6 +802,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
             ),
             canonical_user_type_annotations: IndexVec::new(),
             upvar_decls,
+            upvar_mutbls,
             var_indices: Default::default(),
             unit_temp: None,
             cached_resume_block: None,