Make use of demand::simple instead of manually checking fail expr type.

This commit is contained in:
Josh Matthews 2011-07-03 23:38:58 -04:00 committed by Brian Anderson
parent a2775a5b72
commit 7e7e326ee6

View file

@ -229,11 +229,6 @@ fn type_is_scalar(&@fn_ctxt fcx, &span sp, ty::t typ) -> bool {
ret ty::type_is_scalar(fcx.ccx.tcx, typ_s);
}
fn type_is_str(&@fn_ctxt fcx, &span sp, ty::t typ) -> bool {
auto typ_s = structurally_resolved_type(fcx, sp, typ);
ret ty::type_is_str(fcx.ccx.tcx, typ_s);
}
// Parses the programmer's textual representation of a type into our internal
// notion of a type. `getter` is a function that returns the type
@ -1667,12 +1662,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
check_expr(fcx, e);
auto tcx = fcx.ccx.tcx;
auto ety = expr_ty(tcx, e);
if (!type_is_str(fcx, e.span, ety)) {
tcx.sess.span_fatal(e.span,
#fmt("mismatched types: expected \
str, found %s",
ty_to_str(tcx, ety)));
}
demand::simple(fcx, e.span, ty::mk_str(tcx), ety);
}
}
write::bot_ty(fcx.ccx.tcx, id);