Skip to content

Commit 547efad

Browse files
committed
Auto merge of #8167 - rust-lang:fix-8166, r=xFredNet
fix an ICE on unwrapping a None This very likely fixes #8166 though I wasn't able to meaningfully reduce a test case. This line is the only call to `unwrap` within that function, which was the one in the stack trace that triggered the ICE, so I think we'll be OK. `@hackmad` can you pull and build this branch and check if it indeed fixes your problem? --- changelog: Fixed ICE in [`unnecessary_cast`]
2 parents eb24acf + 23ffa3c commit 547efad

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

clippy_lints/src/casts/unnecessary_cast.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ pub(super) fn check(
4949
if cast_from.kind() == cast_to.kind() =>
5050
{
5151
if let Some(src) = snippet_opt(cx, lit.span) {
52-
let num_lit = NumericLiteral::from_lit_kind(&src, &lit.node).unwrap();
53-
lint_unnecessary_cast(cx, expr, num_lit.integer, cast_from, cast_to);
52+
if let Some(num_lit) = NumericLiteral::from_lit_kind(&src, &lit.node) {
53+
lint_unnecessary_cast(cx, expr, num_lit.integer, cast_from, cast_to);
54+
}
5455
}
5556
},
5657
_ => {

0 commit comments

Comments
 (0)