Skip to content

Commit af33de7

Browse files
committed
Auto merge of rust-lang#9244 - Jarcho:ice-9242, r=flip1995
Fix ICE in `question_mark` fixes rust-lang#9242 changelog: [`question_mark`](https://rust-lang.github.io/rust-clippy/master/#question_mark): Fix ICE on zero field tuple structs
2 parents 20e4204 + 2255cfd commit af33de7

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

clippy_lints/src/question_mark.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ fn check_if_let_some_or_err_and_early_return<'tcx>(cx: &LateContext<'tcx>, expr:
123123
if_chain! {
124124
if let Some(higher::IfLet { let_pat, let_expr, if_then, if_else }) = higher::IfLet::hir(cx, expr);
125125
if !is_else_clause(cx.tcx, expr);
126-
if let PatKind::TupleStruct(ref path1, fields, None) = let_pat.kind;
127-
if let PatKind::Binding(annot, bind_id, ident, _) = fields[0].kind;
126+
if let PatKind::TupleStruct(ref path1, [field], None) = let_pat.kind;
127+
if let PatKind::Binding(annot, bind_id, ident, _) = field.kind;
128128
let caller_ty = cx.typeck_results().expr_ty(let_expr);
129129
let if_block = IfBlockType::IfLet(path1, caller_ty, ident.name, let_expr, if_then, if_else);
130130
if (is_early_return(sym::Option, cx, &if_block) && path_to_local_id(peel_blocks(if_then), bind_id))

tests/ui/crashes/ice-9242.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
enum E {
2+
X(),
3+
Y,
4+
}
5+
6+
fn main() {
7+
let _ = if let E::X() = E::X() { 1 } else { 2 };
8+
}

0 commit comments

Comments
 (0)