@@ -1039,10 +1039,9 @@ impl LoweringContext<'_> {
1039
1039
) -> hir:: Expr {
1040
1040
// expand <head>
1041
1041
let mut head = self . lower_expr ( head) ;
1042
- let head_sp = head. span ;
1043
1042
let desugared_span = self . mark_span_with_reason (
1044
1043
DesugaringKind :: ForLoop ,
1045
- head_sp ,
1044
+ head . span ,
1046
1045
None ,
1047
1046
) ;
1048
1047
head. span = desugared_span;
@@ -1088,21 +1087,21 @@ impl LoweringContext<'_> {
1088
1087
1089
1088
// `match ::std::iter::Iterator::next(&mut iter) { ... }`
1090
1089
let match_expr = {
1091
- let iter = P ( self . expr_ident ( head_sp , iter, iter_pat_nid) ) ;
1092
- let ref_mut_iter = self . expr_mut_addr_of ( head_sp , iter) ;
1090
+ let iter = P ( self . expr_ident ( desugared_span , iter, iter_pat_nid) ) ;
1091
+ let ref_mut_iter = self . expr_mut_addr_of ( desugared_span , iter) ;
1093
1092
let next_path = & [ sym:: iter, sym:: Iterator , sym:: next] ;
1094
1093
let next_expr = P ( self . expr_call_std_path (
1095
- head_sp ,
1094
+ desugared_span ,
1096
1095
next_path,
1097
1096
hir_vec ! [ ref_mut_iter] ,
1098
1097
) ) ;
1099
1098
let arms = hir_vec ! [ pat_arm, break_arm] ;
1100
1099
1101
- self . expr_match ( head_sp , next_expr, arms, hir:: MatchSource :: ForLoopDesugar )
1100
+ self . expr_match ( desugared_span , next_expr, arms, hir:: MatchSource :: ForLoopDesugar )
1102
1101
} ;
1103
- let match_stmt = self . stmt_expr ( head_sp , match_expr) ;
1102
+ let match_stmt = self . stmt_expr ( desugared_span , match_expr) ;
1104
1103
1105
- let next_expr = P ( self . expr_ident ( head_sp , next_ident, next_pat_hid) ) ;
1104
+ let next_expr = P ( self . expr_ident ( desugared_span , next_ident, next_pat_hid) ) ;
1106
1105
1107
1106
// `let mut __next`
1108
1107
let next_let = self . stmt_let_pat (
@@ -1117,7 +1116,7 @@ impl LoweringContext<'_> {
1117
1116
let pat = self . lower_pat ( pat) ;
1118
1117
let pat_let = self . stmt_let_pat (
1119
1118
ThinVec :: new ( ) ,
1120
- head_sp ,
1119
+ desugared_span ,
1121
1120
Some ( next_expr) ,
1122
1121
pat,
1123
1122
hir:: LocalSource :: ForLoopDesugar ,
@@ -1154,14 +1153,14 @@ impl LoweringContext<'_> {
1154
1153
let into_iter_path =
1155
1154
& [ sym:: iter, sym:: IntoIterator , sym:: into_iter] ;
1156
1155
P ( self . expr_call_std_path (
1157
- head_sp ,
1156
+ desugared_span ,
1158
1157
into_iter_path,
1159
1158
hir_vec ! [ head] ,
1160
1159
) )
1161
1160
} ;
1162
1161
1163
1162
let match_expr = P ( self . expr_match (
1164
- head_sp ,
1163
+ desugared_span ,
1165
1164
into_iter_expr,
1166
1165
hir_vec ! [ iter_arm] ,
1167
1166
hir:: MatchSource :: ForLoopDesugar ,
@@ -1173,7 +1172,7 @@ impl LoweringContext<'_> {
1173
1172
// surrounding scope of the `match` since the `match` is not a terminating scope.
1174
1173
//
1175
1174
// Also, add the attributes to the outer returned expr node.
1176
- self . expr_drop_temps ( head_sp , match_expr, e. attrs . clone ( ) )
1175
+ self . expr_drop_temps ( desugared_span , match_expr, e. attrs . clone ( ) )
1177
1176
}
1178
1177
1179
1178
/// Desugar `ExprKind::Try` from: `<expr>?` into:
0 commit comments