@@ -908,21 +908,6 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
908
908
let promoted = & mut self . promoted ;
909
909
let promoted_id = Promoted :: new ( next_promoted_id) ;
910
910
let tcx = self . tcx ;
911
- let mut promoted_place = |ty, span| {
912
- promoted. span = span;
913
- promoted. local_decls [ RETURN_PLACE ] = LocalDecl :: new_return_place ( ty, span) ;
914
- Place {
915
- base : PlaceBase :: Static ( box Static {
916
- kind : StaticKind :: Promoted (
917
- promoted_id,
918
- InternalSubsts :: identity_for_item ( tcx, def_id) ,
919
- ) ,
920
- ty,
921
- def_id,
922
- } ) ,
923
- projection : List :: empty ( ) ,
924
- }
925
- } ;
926
911
let ( blocks, local_decls) = self . source . basic_blocks_and_local_decls_mut ( ) ;
927
912
match candidate {
928
913
Candidate :: Ref ( loc) => {
@@ -1031,8 +1016,25 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
1031
1016
TerminatorKind :: Call { ref mut args, .. } => {
1032
1017
let ty = args[ index] . ty ( local_decls, self . tcx ) ;
1033
1018
let span = terminator. source_info . span ;
1034
- let operand = Operand :: Copy ( promoted_place ( ty, span) ) ;
1035
- Rvalue :: Use ( mem:: replace ( & mut args[ index] , operand) )
1019
+
1020
+ promoted. span = span;
1021
+ promoted. local_decls [ RETURN_PLACE ] =
1022
+ LocalDecl :: new_return_place ( ty, span) ;
1023
+
1024
+ let promoted_operand = Operand :: Constant ( Box :: new ( Constant {
1025
+ span,
1026
+ user_ty : None ,
1027
+ literal : tcx. mk_const ( ty:: Const {
1028
+ ty,
1029
+ val : ty:: ConstKind :: Unevaluated (
1030
+ def_id,
1031
+ InternalSubsts :: identity_for_item ( tcx, def_id) ,
1032
+ Some ( promoted_id) ,
1033
+ ) ,
1034
+ } ) ,
1035
+ } ) ) ;
1036
+
1037
+ Rvalue :: Use ( mem:: replace ( & mut args[ index] , promoted_operand) )
1036
1038
}
1037
1039
// We expected a `TerminatorKind::Call` for which we'd like to promote an
1038
1040
// argument. `qualify_consts` saw a `TerminatorKind::Call` here, but
0 commit comments