@@ -4,6 +4,7 @@ import ast::mutability;
4
4
import ast:: local_def;
5
5
import ast:: path_to_str;
6
6
import ast:: respan;
7
+ import ast:: spanned;
7
8
import syntax:: walk;
8
9
import metadata:: csearch;
9
10
import driver:: session;
@@ -2177,16 +2178,21 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
2177
2178
case ( none) { /* no-op */ }
2178
2179
case ( some ( ?b_0) ) { check_expr ( fcx, b_0) ; }
2179
2180
}
2180
- let field[ ] fields_t = ~[ ] ;
2181
+ let ( spanned [ field] ) [ ] fields_t = ~[ ] ;
2181
2182
for ( ast:: field f in fields) {
2182
2183
check_expr ( fcx, f. node . expr ) ;
2183
2184
auto expr_t = expr_ty ( fcx. ccx . tcx , f. node . expr ) ;
2184
2185
auto expr_mt = rec ( ty=expr_t, mut=f. node . mut ) ;
2185
- fields_t += ~[ rec ( ident=f. node . ident , mt=expr_mt) ] ;
2186
+ // for the most precise error message,
2187
+ // should be f.node.expr.span, not f.span
2188
+ fields_t += ~[ respan ( f. node . expr . span ,
2189
+ rec ( ident=f. node . ident , mt=expr_mt) ) ] ;
2186
2190
}
2187
2191
alt ( base) {
2188
2192
case ( none) {
2189
- auto typ = ty:: mk_rec ( fcx. ccx . tcx , fields_t) ;
2193
+ fn get_node ( & spanned[ field] f ) -> field { f. node }
2194
+ auto typ = ty:: mk_rec ( fcx. ccx . tcx ,
2195
+ ivec:: map ( get_node, fields_t) ) ;
2190
2196
write:: ty_only_fixup ( fcx, id, typ) ;
2191
2197
}
2192
2198
case ( some ( ?bexpr) ) {
@@ -2202,20 +2208,20 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
2202
2208
}
2203
2209
}
2204
2210
write:: ty_only_fixup ( fcx, id, bexpr_t) ;
2205
- for ( ty:: field f in fields_t) {
2211
+ for ( spanned [ ty:: field] f in fields_t) {
2206
2212
auto found = false ;
2207
2213
for ( ty:: field bf in base_fields) {
2208
- if ( str:: eq( f. ident, bf. ident) ) {
2209
- demand:: simple( fcx, expr . span, bf. mt. ty,
2210
- f. mt. ty) ;
2214
+ if ( str:: eq( f. node . ident, bf. ident) ) {
2215
+ demand:: simple( fcx, f . span, bf. mt. ty,
2216
+ f. node . mt. ty) ;
2211
2217
found = true ;
2212
2218
}
2213
2219
}
2214
2220
if ( !found) {
2215
- fcx. ccx . tcx . sess . span_fatal ( expr . span ,
2221
+ fcx. ccx. tcx. sess. span_fatal( f . span,
2216
2222
"unknown field in \
2217
2223
record update: "
2218
- + f. ident ) ;
2224
+ + f. node . ident) ;
2219
2225
}
2220
2226
}
2221
2227
}
0 commit comments