diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index fdfc6f68590a4..e86230437f277 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -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. diff --git a/src/test/ui/issues/issue-63364.rs b/src/test/ui/issues/issue-63364.rs new file mode 100644 index 0000000000000..5223267a69a49 --- /dev/null +++ b/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); + } +} diff --git a/src/test/ui/issues/issue-63364.stderr b/src/test/ui/issues/issue-63364.stderr new file mode 100644 index 0000000000000..60ff318f35a1c --- /dev/null +++ b/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 +