Disallow dereference of !

Later compiler passes are not prepared to deal with deref of
`ty_bot` and will generate various ICEs, so disallow it outright for now.

Closes issue #17373
This commit is contained in:
Brian Koropoff 2014-09-19 23:46:55 -07:00
parent 31f6d45a18
commit c48faaff64

View File

@ -3869,14 +3869,19 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
check_expr_with_expectation_and_lvalue_pref(
fcx, &**oprnd, expected_inner, lvalue_pref);
let mut oprnd_t = fcx.expr_ty(&**oprnd);
if !ty::type_is_error(oprnd_t) && !ty::type_is_bot(oprnd_t) {
if !ty::type_is_error(oprnd_t) {
match unop {
ast::UnBox => {
if !ty::type_is_bot(oprnd_t) {
oprnd_t = ty::mk_box(tcx, oprnd_t)
}
}
ast::UnUniq => {
if !ty::type_is_bot(oprnd_t) {
oprnd_t = ty::mk_uniq(tcx, oprnd_t);
}
}
ast::UnDeref => {
oprnd_t = structurally_resolved_type(fcx, expr.span, oprnd_t);
oprnd_t = match ty::deref(oprnd_t, true) {
@ -3912,6 +3917,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
};
}
ast::UnNot => {
if !ty::type_is_bot(oprnd_t) {
oprnd_t = structurally_resolved_type(fcx, oprnd.span,
oprnd_t);
if !(ty::type_is_integral(oprnd_t) ||
@ -3921,7 +3927,9 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
expr, &**oprnd, oprnd_t);
}
}
}
ast::UnNeg => {
if !ty::type_is_bot(oprnd_t) {
oprnd_t = structurally_resolved_type(fcx, oprnd.span,
oprnd_t);
if !(ty::type_is_integral(oprnd_t) ||
@ -3933,6 +3941,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
}
}
}
}
fcx.write_ty(id, oprnd_t);
}
ast::ExprAddrOf(mutbl, ref oprnd) => {