Skip to content

Commit e2b3543

Browse files
committed
Return early to avoid failing assertion
1 parent 476af31 commit e2b3543

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

src/librustc_lint/types.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ fn lint_overflowing_range_endpoint<'a, 'tcx>(
7373
// We only want to handle exclusive (`..`) ranges,
7474
// which are represented as `ExprKind::Struct`.
7575
if let ExprKind::Struct(_, eps, _) = &parent_expr.node {
76-
debug_assert_eq!(eps.len(), 2);
76+
if eps.len() != 2 {
77+
return false;
78+
}
7779
// We can suggest using an inclusive range
7880
// (`..=`) instead only if it is the `end` that is
7981
// overflowing and only by 1.

src/test/ui/issues/issue-63364.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
fn part(_: u16) -> u32 {
2+
1
3+
}
4+
5+
fn main() {
6+
for n in 100_000.. {
7+
//~^ ERROR: literal out of range for `u16`
8+
let _ = part(n);
9+
}
10+
}

src/test/ui/issues/issue-63364.stderr

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: literal out of range for `u16`
2+
--> $DIR/issue-63364.rs:6:14
3+
|
4+
LL | for n in 100_000.. {
5+
| ^^^^^^^
6+
|
7+
= note: `#[deny(overflowing_literals)]` on by default
8+
9+
error: aborting due to previous error
10+

0 commit comments

Comments
 (0)