diff options
| author | Stefan Plantikow <stefan.plantikow@googlemail.com> | 2011-12-05 01:23:10 +0100 |
|---|---|---|
| committer | Stefan Plantikow <stefan.plantikow@googlemail.com> | 2011-12-05 01:23:10 +0100 |
| commit | a69eab16ec3435bd505a7dafcb9a82b5eace49a2 (patch) | |
| tree | 49b053d2d8effef75ece72d2d070c07f702640c7 /src/comp/middle | |
| parent | f1eb7ce013526c6ae75e92a31fe3b89b4cf44b3f (diff) | |
| download | rust-a69eab16ec3435bd505a7dafcb9a82b5eace49a2.tar.gz rust-a69eab16ec3435bd505a7dafcb9a82b5eace49a2.zip | |
typeck: Fix for #932
Diffstat (limited to 'src/comp/middle')
| -rw-r--r-- | src/comp/middle/typeck.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 9731bcaf444..bb82a959784 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -2116,6 +2116,20 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier, let t_1 = ast_ty_to_ty_crate(fcx.ccx, t); let t_e = expr_ty(tcx, e); + if ty::type_is_nil(tcx, t_e) { + tcx.sess.span_err(expr.span, + "cast from nil: " + + ty_to_str(tcx, expr_ty(tcx, e)) + " as " + + ty_to_str(tcx, t_1)); + } + + if ty::type_is_nil(tcx, t_1) { + tcx.sess.span_err(expr.span, + "cast to nil: " + + ty_to_str(tcx, expr_ty(tcx, e)) + " as " + + ty_to_str(tcx, t_1)); + } + // FIXME there are more forms of cast to support, eventually. if !( type_is_scalar(fcx, expr.span, t_e) && type_is_scalar(fcx, expr.span, t_1)) { |
