Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/librustc_lint/types.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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