Skip to content

Commit 572c405

Browse files
committed
fix ice when checking rustc libstd
thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', src/tools/clippy/clippy_lints/src/matches.rs:1595:53 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace I don't have a minimised testcase because I don't have time to reduce libstd down to a few lines right now.
1 parent 7c7683c commit 572c405

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: clippy_lints/src/matches.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1590,9 +1590,9 @@ fn is_none_arm(cx: &LateContext<'_>, arm: &Arm<'_>) -> bool {
15901590
// Checks if arm has the form `Some(ref v) => Some(v)` (checks for `ref` and `ref mut`)
15911591
fn is_ref_some_arm(cx: &LateContext<'_>, arm: &Arm<'_>) -> Option<BindingAnnotation> {
15921592
if_chain! {
1593-
if let PatKind::TupleStruct(ref qpath, pats, _) = arm.pat.kind;
1593+
if let PatKind::TupleStruct(ref qpath, [first_pat, ..], _) = arm.pat.kind;
15941594
if is_lang_ctor(cx, qpath, OptionSome);
1595-
if let PatKind::Binding(rb, .., ident, _) = pats[0].kind;
1595+
if let PatKind::Binding(rb, .., ident, _) = first_pat.kind;
15961596
if rb == BindingAnnotation::Ref || rb == BindingAnnotation::RefMut;
15971597
if let ExprKind::Call(e, args) = remove_blocks(arm.body).kind;
15981598
if let ExprKind::Path(ref some_path) = e.kind;

0 commit comments

Comments
 (0)