@@ -588,18 +588,22 @@ impl Context {
588588 // foo(bar(&1))
589589 // the lifetime of `1` doesn't outlast the call to `bar`, so it's not
590590 // vald for the call to `foo`. To work around this all arguments to the
591- // fmt! string are shoved into locals.
591+ // fmt! string are shoved into locals. Furthermore, we shove the address
592+ // of each variable because we don't want to move out of the arguments
593+ // passed to this function.
592594 for ( i, & e) in self . args . iter ( ) . enumerate ( ) {
593595 if self . arg_types [ i] . is_none ( ) { loop } // error already generated
594596
595597 let name = self . ecx . ident_of ( fmt ! ( "__arg%u" , i) ) ;
598+ let e = self . ecx . expr_addr_of ( e. span , e) ;
596599 lets. push ( self . ecx . stmt_let ( e. span , false , name, e) ) ;
597600 locals. push ( self . format_arg ( e. span , Left ( i) , name) ) ;
598601 }
599602 for ( & name, & e) in self . names . iter ( ) {
600603 if !self . name_types . contains_key ( & name) { loop }
601604
602605 let lname = self . ecx . ident_of ( fmt ! ( "__arg%s" , name) ) ;
606+ let e = self . ecx . expr_addr_of ( e. span , e) ;
603607 lets. push ( self . ecx . stmt_let ( e. span , false , lname, e) ) ;
604608 names[ * self . name_positions . get ( & name) ] =
605609 Some ( self . format_arg ( e. span , Right ( name) , lname) ) ;
@@ -643,7 +647,7 @@ impl Context {
643647 Right ( s) => * self . name_types . get ( & s)
644648 } ;
645649
646- let argptr = self . ecx . expr_addr_of ( sp , self . ecx . expr_ident ( sp, ident) ) ;
650+ let argptr = self . ecx . expr_ident ( sp, ident) ;
647651 let fmt_trait = match ty {
648652 Unknown => "Default" ,
649653 Known ( tyname) => {
0 commit comments