diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index 3e9429399b31f..64955003bd2cb 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -3651,7 +3651,10 @@ pub fn expr_requires_coercion<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>) - ExprKind::Struct(qpath, _, _) => { let res = cx.typeck_results().qpath_res(qpath, expr.hir_id); if let Some((_, v_def)) = adt_and_variant_of_res(cx, res) { - let generic_args = cx.typeck_results().node_args(expr.hir_id); + let rustc_ty::Adt(_, generic_args) = cx.typeck_results().expr_ty_adjusted(expr).kind() else { + // This should never happen, but when it does, not linting is the better option. + return true; + }; v_def .fields .iter() diff --git a/tests/ui/crashes/ice-14325.rs b/tests/ui/crashes/ice-14325.rs new file mode 100644 index 0000000000000..d762bd6c9e00e --- /dev/null +++ b/tests/ui/crashes/ice-14325.rs @@ -0,0 +1,17 @@ +//@check-pass + +#![allow(clippy::redundant_pattern_matching)] + +struct S<'a> { + s: &'a str, +} + +fn foo() -> Option> { + if let Some(_) = Some(0) { + Some(S { s: "xyz" }) + } else { + None + } +} + +fn main() {}