diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 17c7c4b76b2d6..184c0d5a53d16 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -1660,14 +1660,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expr: &'tcx hir::Expr<'tcx>, ) -> Ty<'tcx> { let element_ty = if !args.is_empty() { - // This shouldn't happen unless there's another error - // (e.g., never patterns in inappropriate contexts). - if self.diverges.get() != Diverges::Maybe { - self.dcx() - .struct_span_err(expr.span, "unexpected divergence state in checking array") - .delay_as_bug(); - } - let coerce_to = expected .to_option(self) .and_then(|uty| { diff --git a/tests/ui/reachable/never-pattern-closure-param-array.rs b/tests/ui/reachable/never-pattern-closure-param-array.rs new file mode 100644 index 0000000000000..83bbc4b39b772 --- /dev/null +++ b/tests/ui/reachable/never-pattern-closure-param-array.rs @@ -0,0 +1,13 @@ +//@ check-pass +//@ edition: 2024 + +#![feature(never_patterns)] +#![allow(incomplete_features)] +#![allow(unreachable_code)] + +fn main() { + let _ = Some({ + return; + }) + .map(|!| [1]); +}