about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAriel Ben-Yehuda <arielb1@mail.tau.ac.il>2015-11-25 18:17:16 +0200
committerNiko Matsakis <niko@alum.mit.edu>2016-01-08 20:20:02 -0500
commita3cbfa58be12a3ae0c4efd71c3e8c39554924e08 (patch)
treebb7a9cdb5a42db2b79224e55135d1b5c89e67337
parent77756cb12ae718cd3b20c0da2b3b89c881910b1d (diff)
downloadrust-a3cbfa58be12a3ae0c4efd71c3e8c39554924e08.tar.gz
rust-a3cbfa58be12a3ae0c4efd71c3e8c39554924e08.zip
improve cast handling - this fixes test failures
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).
-rw-r--r--src/librustc_typeck/check/mod.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index dbc22bcde9e..e644178ddd6 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -3514,9 +3514,10 @@ fn check_expr_with_unifier<'a, 'tcx, F>(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);