Skip to content

Commit

Permalink
Fix ICE in consts::binop
Browse files Browse the repository at this point in the history
  • Loading branch information
ebroto committed Jun 12, 2020
1 parent f065d4b commit b21ef2b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clippy_lints/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
let l = self.expr(left)?;
let r = self.expr(right);
match (l, r) {
(Constant::Int(l), Some(Constant::Int(r))) => match self.tables.expr_ty(left).kind {
(Constant::Int(l), Some(Constant::Int(r))) => match self.tables.expr_ty_opt(left)?.kind {
ty::Int(ity) => {
let l = sext(self.lcx.tcx, l, ity);
let r = sext(self.lcx.tcx, r, ity);
Expand Down
13 changes: 13 additions & 0 deletions tests/ui/crashes/ice-5389.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#![allow(clippy::explicit_counter_loop)]

fn main() {
let v = vec![1, 2, 3];
let mut i = 0;
let max_storage_size = [0; 128 * 1024];
for item in &v {
bar(i, *item);
i += 1;
}
}

fn bar(_: usize, _: u32) {}

0 comments on commit b21ef2b

Please sign in to comment.