mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-03 12:13:43 +00:00
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:
parent
31f6d45a18
commit
c48faaff64
@ -3869,13 +3869,18 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
|
|||||||
check_expr_with_expectation_and_lvalue_pref(
|
check_expr_with_expectation_and_lvalue_pref(
|
||||||
fcx, &**oprnd, expected_inner, lvalue_pref);
|
fcx, &**oprnd, expected_inner, lvalue_pref);
|
||||||
let mut oprnd_t = fcx.expr_ty(&**oprnd);
|
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 {
|
match unop {
|
||||||
ast::UnBox => {
|
ast::UnBox => {
|
||||||
oprnd_t = ty::mk_box(tcx, oprnd_t)
|
if !ty::type_is_bot(oprnd_t) {
|
||||||
|
oprnd_t = ty::mk_box(tcx, oprnd_t)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ast::UnUniq => {
|
ast::UnUniq => {
|
||||||
oprnd_t = ty::mk_uniq(tcx, oprnd_t);
|
if !ty::type_is_bot(oprnd_t) {
|
||||||
|
oprnd_t = ty::mk_uniq(tcx, oprnd_t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ast::UnDeref => {
|
ast::UnDeref => {
|
||||||
oprnd_t = structurally_resolved_type(fcx, expr.span, oprnd_t);
|
oprnd_t = structurally_resolved_type(fcx, expr.span, oprnd_t);
|
||||||
@ -3912,23 +3917,27 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
ast::UnNot => {
|
ast::UnNot => {
|
||||||
oprnd_t = structurally_resolved_type(fcx, oprnd.span,
|
if !ty::type_is_bot(oprnd_t) {
|
||||||
oprnd_t);
|
oprnd_t = structurally_resolved_type(fcx, oprnd.span,
|
||||||
if !(ty::type_is_integral(oprnd_t) ||
|
oprnd_t);
|
||||||
ty::get(oprnd_t).sty == ty::ty_bool) {
|
if !(ty::type_is_integral(oprnd_t) ||
|
||||||
oprnd_t = check_user_unop(fcx, "!", "not",
|
ty::get(oprnd_t).sty == ty::ty_bool) {
|
||||||
tcx.lang_items.not_trait(),
|
oprnd_t = check_user_unop(fcx, "!", "not",
|
||||||
expr, &**oprnd, oprnd_t);
|
tcx.lang_items.not_trait(),
|
||||||
|
expr, &**oprnd, oprnd_t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::UnNeg => {
|
ast::UnNeg => {
|
||||||
oprnd_t = structurally_resolved_type(fcx, oprnd.span,
|
if !ty::type_is_bot(oprnd_t) {
|
||||||
oprnd_t);
|
oprnd_t = structurally_resolved_type(fcx, oprnd.span,
|
||||||
if !(ty::type_is_integral(oprnd_t) ||
|
oprnd_t);
|
||||||
ty::type_is_fp(oprnd_t)) {
|
if !(ty::type_is_integral(oprnd_t) ||
|
||||||
oprnd_t = check_user_unop(fcx, "-", "neg",
|
ty::type_is_fp(oprnd_t)) {
|
||||||
tcx.lang_items.neg_trait(),
|
oprnd_t = check_user_unop(fcx, "-", "neg",
|
||||||
expr, &**oprnd, oprnd_t);
|
tcx.lang_items.neg_trait(),
|
||||||
|
expr, &**oprnd, oprnd_t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user