Return early to avoid failing assertion
This commit is contained in:
parent
476af31d59
commit
e2b3543eab
@ -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.
|
||||
|
10
src/test/ui/issues/issue-63364.rs
Normal file
10
src/test/ui/issues/issue-63364.rs
Normal file
@ -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
src/test/ui/issues/issue-63364.stderr
Normal file
10
src/test/ui/issues/issue-63364.stderr
Normal file
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user