@@ -376,6 +376,7 @@ struct Builder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
376376 local_decls : IndexVec < Local , LocalDecl < ' tcx > > ,
377377 canonical_user_type_annotations : ty:: CanonicalUserTypeAnnotations < ' tcx > ,
378378 upvar_decls : Vec < UpvarDecl > ,
379+ upvar_mutbls : Vec < Mutability > ,
379380 unit_temp : Option < Place < ' tcx > > ,
380381
381382 /// 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>,
625626 let fn_def_id = tcx_hir. local_def_id_from_hir_id ( fn_id) ;
626627
627628 // Gather the upvars of a closure, if any.
629+ let mut upvar_mutbls = vec ! [ ] ;
628630 // In analyze_closure() in upvar.rs we gathered a list of upvars used by a
629631 // closure and we stored in a map called upvar_list in TypeckTables indexed
630632 // 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>,
644646 } ;
645647 let mut decl = UpvarDecl {
646648 debug_name : keywords:: Invalid . name ( ) ,
647- var_hir_id : ClearCrossCrate :: Set ( var_hir_id) ,
648649 by_ref,
649- mutability : Mutability :: Not ,
650650 } ;
651+ let mut mutability = Mutability :: Not ;
651652 if let Some ( Node :: Binding ( pat) ) = tcx_hir. find ( var_node_id) {
652653 if let hir:: PatKind :: Binding ( _, _, ident, _) = pat. node {
653654 decl. debug_name = ident. name ;
654655 if let Some ( & bm) = hir. tables . pat_binding_modes ( ) . get ( pat. hir_id ) {
655656 if bm == ty:: BindByValue ( hir:: MutMutable ) {
656- decl . mutability = Mutability :: Mut ;
657+ mutability = Mutability :: Mut ;
657658 } else {
658- decl . mutability = Mutability :: Not ;
659+ mutability = Mutability :: Not ;
659660 }
660661 } else {
661662 tcx. sess . delay_span_bug ( pat. span , "missing binding mode" ) ;
662663 }
663664 }
664665 }
666+ upvar_mutbls. push ( mutability) ;
665667 decl
666668 } )
667669 . collect ( ) ;
@@ -672,7 +674,8 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
672674 safety,
673675 return_ty,
674676 return_ty_span,
675- upvar_decls) ;
677+ upvar_decls,
678+ upvar_mutbls) ;
676679
677680 let call_site_scope = region:: Scope {
678681 id : body. value . hir_id . local_id ,
@@ -734,7 +737,7 @@ fn construct_const<'a, 'gcx, 'tcx>(
734737 let ty = hir. tables ( ) . expr_ty_adjusted ( ast_expr) ;
735738 let owner_id = tcx. hir ( ) . body_owner ( body_id) ;
736739 let span = tcx. hir ( ) . span ( owner_id) ;
737- let mut builder = Builder :: new ( hir, span, 0 , Safety :: Safe , ty, ty_span, vec ! [ ] ) ;
740+ let mut builder = Builder :: new ( hir, span, 0 , Safety :: Safe , ty, ty_span, vec ! [ ] , vec ! [ ] ) ;
738741
739742 let mut block = START_BLOCK ;
740743 let expr = builder. hir . mirror ( ast_expr) ;
@@ -762,7 +765,7 @@ fn construct_error<'a, 'gcx, 'tcx>(hir: Cx<'a, 'gcx, 'tcx>,
762765 let owner_id = hir. tcx ( ) . hir ( ) . body_owner ( body_id) ;
763766 let span = hir. tcx ( ) . hir ( ) . span ( owner_id) ;
764767 let ty = hir. tcx ( ) . types . err ;
765- let mut builder = Builder :: new ( hir, span, 0 , Safety :: Safe , ty, span, vec ! [ ] ) ;
768+ let mut builder = Builder :: new ( hir, span, 0 , Safety :: Safe , ty, span, vec ! [ ] , vec ! [ ] ) ;
766769 let source_info = builder. source_info ( span) ;
767770 builder. cfg . terminate ( START_BLOCK , source_info, TerminatorKind :: Unreachable ) ;
768771 builder. finish ( None )
@@ -775,7 +778,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
775778 safety : Safety ,
776779 return_ty : Ty < ' tcx > ,
777780 return_span : Span ,
778- upvar_decls : Vec < UpvarDecl > )
781+ upvar_decls : Vec < UpvarDecl > ,
782+ upvar_mutbls : Vec < Mutability > )
779783 -> Builder < ' a , ' gcx , ' tcx > {
780784 let lint_level = LintLevel :: Explicit ( hir. root_lint_level ) ;
781785 let mut builder = Builder {
@@ -798,6 +802,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
798802 ) ,
799803 canonical_user_type_annotations : IndexVec :: new ( ) ,
800804 upvar_decls,
805+ upvar_mutbls,
801806 var_indices : Default :: default ( ) ,
802807 unit_temp : None ,
803808 cached_resume_block : None ,
0 commit comments