Skip to content

Commit

Permalink
Return early to avoid failing assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTitor committed Aug 8, 2019
1 parent 476af31 commit e2b3543
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/librustc_lint/types.rs
Expand Up @@ -73,7 +73,9 @@ fn lint_overflowing_range_endpoint<'a, 'tcx>(
// We only want to handle exclusive (`..`) ranges,
// which are represented as `ExprKind::Struct`.
if let ExprKind::Struct(_, eps, _) = &parent_expr.node {
debug_assert_eq!(eps.len(), 2);
if eps.len() != 2 {
return false;
}
// We can suggest using an inclusive range
// (`..=`) instead only if it is the `end` that is
// overflowing and only by 1.
Expand Down
10 changes: 10 additions & 0 deletions src/test/ui/issues/issue-63364.rs
@@ -0,0 +1,10 @@
fn part(_: u16) -> u32 {
1
}

fn main() {
for n in 100_000.. {
//~^ ERROR: literal out of range for `u16`
let _ = part(n);
}
}
10 changes: 10 additions & 0 deletions src/test/ui/issues/issue-63364.stderr
@@ -0,0 +1,10 @@
error: literal out of range for `u16`
--> $DIR/issue-63364.rs:6:14
|
LL | for n in 100_000.. {
| ^^^^^^^
|
= note: `#[deny(overflowing_literals)]` on by default

error: aborting due to previous error

0 comments on commit e2b3543

Please sign in to comment.