mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Rollup merge of #154031 - TaKO8Ki:fix-153695-never-pattern-array-ice, r=chenyukang
Remove divergence check from check_expr_array Fixes rust-lang/rust#153695. `check_expr_array` currently assumes it should only be entered with` self.diverges == Diverges::Maybe`, but that assumption does not appear to hold in all valid cases. A never-pattern parameter can seed a function or closure body with inherited `Diverges::Always`, and exprs in that body are still typecked.
This commit is contained in:
@@ -1660,14 +1660,6 @@ fn check_expr_array(
|
||||
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| {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
//@ check-pass
|
||||
//@ edition: 2024
|
||||
|
||||
#![feature(never_patterns)]
|
||||
#![allow(incomplete_features)]
|
||||
#![allow(unreachable_code)]
|
||||
|
||||
fn main() {
|
||||
let _ = Some({
|
||||
return;
|
||||
})
|
||||
.map(|!| [1]);
|
||||
}
|
||||
Reference in New Issue
Block a user