Skip to content

Commit 144b8cf

Browse files
committed
Factor write_ty out of check_struct_expr
1 parent f22dd2e commit 144b8cf

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

src/librustc_typeck/check/_match.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
497497
}
498498
return;
499499
};
500+
self.write_ty(pat.id, pat_ty);
500501

501502
// Type check the path.
502503
self.demand_eqtype(pat.span, expected, pat_ty);

src/librustc_typeck/check/mod.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,7 +1711,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
17111711
self.add_obligations_for_parameters(cause, &bounds);
17121712

17131713
let ty_substituted = self.instantiate_type_scheme(path.span, substs, &ty);
1714-
self.write_ty(node_id, ty_substituted);
17151714
self.write_substs(node_id, ty::ItemSubsts {
17161715
substs: substs
17171716
});
@@ -3190,12 +3189,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
31903189
}
31913190

31923191
fn check_struct_fields_on_error(&self,
3193-
id: ast::NodeId,
31943192
fields: &'gcx [hir::Field],
3195-
base_expr: &'gcx Option<P<hir::Expr>>) -> Ty<'tcx> {
3196-
// Make sure to still write the types
3197-
// otherwise we might ICE
3198-
let ty = self.write_error(id);
3193+
base_expr: &'gcx Option<P<hir::Expr>>) {
31993194
for field in fields {
32003195
self.check_expr(&field.expr);
32013196
}
@@ -3205,7 +3200,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
32053200
},
32063201
None => {}
32073202
}
3208-
ty
32093203
}
32103204

32113205
pub fn check_struct_path(&self,
@@ -3262,7 +3256,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
32623256
expr.span) {
32633257
variant_ty
32643258
} else {
3265-
return self.check_struct_fields_on_error(expr.id, fields, base_expr);
3259+
self.check_struct_fields_on_error(fields, base_expr);
3260+
return self.tcx().types.err;
32663261
};
32673262

32683263
self.check_expr_struct_fields(expr_t, path.span, variant, fields,
@@ -3286,6 +3281,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
32863281
}
32873282
}
32883283
}
3284+
self.require_type_is_sized(expr_t, expr.span, traits::StructInitializerSized);
32893285
expr_t
32903286
}
32913287

@@ -3690,9 +3686,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
36903686
}
36913687
hir::ExprStruct(ref path, ref fields, ref base_expr) => {
36923688
let ty = self.check_expr_struct(expr, path, fields, base_expr);
3693-
3694-
self.require_type_is_sized(ty, expr.span, traits::StructInitializerSized);
3695-
ty
3689+
self.write_ty(id, ty)
36963690
}
36973691
hir::ExprField(ref base, ref field) => {
36983692
let ty = self.check_field(expr, lvalue_pref, &base, field);

0 commit comments

Comments
 (0)