]> git.lizzy.rs Git - rust.git/commitdiff
improve cast handling - this fixes test failures
authorAriel Ben-Yehuda <arielb1@mail.tau.ac.il>
Wed, 25 Nov 2015 16:17:16 +0000 (18:17 +0200)
committerNiko Matsakis <niko@alum.mit.edu>
Sat, 9 Jan 2016 01:20:02 +0000 (20:20 -0500)
the problem is that now "type_is_known_to_be_sized" now returns
false when called on a type with ty_err inside - this prevents
spurious errors (we may want to move the check to check::cast
anyway - see #12894).

src/librustc_typeck/check/mod.rs

index dbc22bcde9ec749257469c0549575992c268b7a7..e644178ddd62f26bec6680ae47689213f15f95a1 100644 (file)
@@ -3514,9 +3514,10 @@ fn check_expr_struct<'a, 'tcx>(fcx: &FnCtxt<'a,'tcx>,
         let t_cast = structurally_resolved_type(fcx, expr.span, t_cast);
         check_expr_with_expectation(fcx, e, ExpectCastableToType(t_cast));
         let t_expr = fcx.expr_ty(e);
+        let t_cast = fcx.infcx().resolve_type_vars_if_possible(&t_cast);
 
         // Eagerly check for some obvious errors.
-        if t_expr.references_error() {
+        if t_expr.references_error() || t_cast.references_error() {
             fcx.write_error(id);
         } else if !fcx.type_is_known_to_be_sized(t_cast, expr.span) {
             report_cast_to_unsized_type(fcx, expr.span, t.span, e.span, t_cast, t_expr, id);