diff options
| author | bors <bors@rust-lang.org> | 2021-12-25 13:38:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-12-25 13:38:08 +0000 |
| commit | 547efad9454123b5d37e627eb8643666aa3ddf3b (patch) | |
| tree | 684957a1be46a35444c82862538b88ef36805125 | |
| parent | eb24acf60d02ecc0d1f2ef8ff041f7b10429b545 (diff) | |
| parent | 23ffa3ca0485bcdf1b0c553dbc134f33f16c7036 (diff) | |
| download | rust-547efad9454123b5d37e627eb8643666aa3ddf3b.tar.gz rust-547efad9454123b5d37e627eb8643666aa3ddf3b.zip | |
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`]
| -rw-r--r-- | clippy_lints/src/casts/unnecessary_cast.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/clippy_lints/src/casts/unnecessary_cast.rs b/clippy_lints/src/casts/unnecessary_cast.rs index 9ed359922fd..1915d990c12 100644 --- a/clippy_lints/src/casts/unnecessary_cast.rs +++ b/clippy_lints/src/casts/unnecessary_cast.rs @@ -49,8 +49,9 @@ pub(super) fn check( if cast_from.kind() == cast_to.kind() => { if let Some(src) = snippet_opt(cx, lit.span) { - let num_lit = NumericLiteral::from_lit_kind(&src, &lit.node).unwrap(); - lint_unnecessary_cast(cx, expr, num_lit.integer, cast_from, cast_to); + if let Some(num_lit) = NumericLiteral::from_lit_kind(&src, &lit.node) { + lint_unnecessary_cast(cx, expr, num_lit.integer, cast_from, cast_to); + } } }, _ => { |
