Skip to content

Commit a92c3fb

Browse files
committed
Disallow index of !
This avoids ICEs in later passes that cannot cope with this construct
1 parent c48faaf commit a92c3fb

File tree

1 file changed

+4
-4
lines changed
  • src/librustc/middle/typeck/check

1 file changed

+4
-4
lines changed

src/librustc/middle/typeck/check/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4394,21 +4394,21 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
43944394
check_expr(fcx, &**idx);
43954395
let raw_base_t = fcx.expr_ty(&**base);
43964396
let idx_t = fcx.expr_ty(&**idx);
4397-
if ty::type_is_error(raw_base_t) || ty::type_is_bot(raw_base_t) {
4397+
if ty::type_is_error(raw_base_t) {
43984398
fcx.write_ty(id, raw_base_t);
4399-
} else if ty::type_is_error(idx_t) || ty::type_is_bot(idx_t) {
4399+
} else if ty::type_is_error(idx_t) {
44004400
fcx.write_ty(id, idx_t);
44014401
} else {
44024402
let (_, autoderefs, field_ty) =
44034403
autoderef(fcx, expr.span, raw_base_t, Some(base.id),
44044404
lvalue_pref, |base_t, _| ty::index(base_t));
44054405
match field_ty {
4406-
Some(ty) => {
4406+
Some(ty) if !ty::type_is_bot(ty) => {
44074407
check_expr_has_type(fcx, &**idx, ty::mk_uint());
44084408
fcx.write_ty(id, ty);
44094409
fcx.write_autoderef_adjustment(base.id, base.span, autoderefs);
44104410
}
4411-
None => {
4411+
_ => {
44124412
// This is an overloaded method.
44134413
let base_t = structurally_resolved_type(fcx,
44144414
expr.span,

0 commit comments

Comments
 (0)