Skip to content
Permalink
Browse files

review comments

  • Loading branch information...
estebank committed Sep 21, 2019
1 parent 2ae87ff commit 0e6fb8e8da2f3256f9e2c2c079b8174acf80d94d
Showing with 14 additions and 11 deletions.
  1. +14 −11 src/librustc_typeck/check/writeback.rs
@@ -192,20 +192,23 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
// All valid indexing looks like this; might encounter non-valid indexes at this point.
let base_ty = tables.expr_ty_adjusted_opt(&base).map(|t| &t.kind);
if base_ty.is_none() {
// When encountering `return [0][0]` outside of a `fn` body we can encounter a base
// that isn't in the type table. We assume more relevant errors have already been
// emitted, so we delay an ICE if none have. (#64638)
self.tcx().sess.delay_span_bug(e.span, &format!("bad base: `{:?}`", base));
return;
}
if let Some(ty::Ref(_, base_ty, _)) = base_ty {
let index_ty = match tables.expr_ty_adjusted_opt(&index) {
Some(t) => t,
None => {
self.tcx().sess.delay_span_bug(
e.span,
&format!("bad index {:?} for base: `{:?}`", index, base),
);
self.fcx.tcx.types.err
}
};
let index_ty = tables.expr_ty_adjusted_opt(&index).unwrap_or_else(|| {
// When encountering `return [0][0]` outside of a `fn` body we would attempt
// to access an unexistend index. We assume that more relevant errors will
// already have been emitted, so we only gate on this with an ICE if no
// error has been emitted. (#64638)
self.tcx().sess.delay_span_bug(
e.span,
&format!("bad index {:?} for base: `{:?}`", index, base),
);
self.fcx.tcx.types.err
});
let index_ty = self.fcx.resolve_vars_if_possible(&index_ty);

if base_ty.builtin_index().is_some() && index_ty == self.fcx.tcx.types.usize {

0 comments on commit 0e6fb8e

Please sign in to comment.
You can’t perform that action at this time.