Skip to content

Commit fd0bd39

Browse files
author
Ariel Ben-Yehuda
committed
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).
1 parent eb84141 commit fd0bd39

File tree

1 file changed

+2
-1
lines changed
  • src/librustc_typeck/check

1 file changed

+2
-1
lines changed

src/librustc_typeck/check/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -3507,9 +3507,10 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
35073507
let t_cast = structurally_resolved_type(fcx, expr.span, t_cast);
35083508
check_expr_with_expectation(fcx, e, ExpectCastableToType(t_cast));
35093509
let t_expr = fcx.expr_ty(e);
3510+
let t_cast = fcx.infcx().resolve_type_vars_if_possible(&t_cast);
35103511

35113512
// Eagerly check for some obvious errors.
3512-
if t_expr.references_error() {
3513+
if t_expr.references_error() || t_cast.references_error() {
35133514
fcx.write_error(id);
35143515
} else if !fcx.type_is_known_to_be_sized(t_cast, expr.span) {
35153516
report_cast_to_unsized_type(fcx, expr.span, t.span, e.span, t_cast, t_expr, id);

0 commit comments

Comments
 (0)