Skip to content

ICE: assertion failed: assert_eq!(self.diverges.get(), Diverges::Maybe) in rustc_hir_typeck/src/expr.rs #141592

@cushionbadak

Description

@cushionbadak

Code

#![feature(never_patterns)] #![allow(incomplete_features)] fn main() { let _ = "12".lines().map(|!| [1]); }

A mutant of glacier2's fixed/72372.rs

Meta

rustc --version --verbose:

rustc 1.89.0-nightly (283db70ac 2025-05-25) binary: rustc commit-hash: 283db70ace62a0ae704a624e43b68c2ee44b87a6 commit-date: 2025-05-25 host: aarch64-apple-darwin release: 1.89.0-nightly LLVM version: 20.1.5 

Error output

command: rustc

thread 'rustc' panicked at compiler/rustc_hir_typeck/src/expr.rs:1802:13: assertion `left == right` failed left: Always { span: never_4.rs:5:31: 5:32 (#0), custom_note: Some("any code following a never pattern is unreachable") } right: Maybe 
Backtrace

thread 'rustc' panicked at compiler/rustc_hir_typeck/src/expr.rs:1802:13: assertion `left == right` failed left: Always { span: never_4.rs:5:31: 5:32 (#0), custom_note: Some("any code following a never pattern is unreachable") } right: Maybe stack backtrace: 0: __rustc::rust_begin_unwind 1: core::panicking::panic_fmt 2: core::panicking::assert_failed_inner 3: core::panicking::assert_failed::<rustc_hir_typeck::diverges::Diverges, rustc_hir_typeck::diverges::Diverges> 4: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_kind 5: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args 6: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_return_or_body_tail 7: rustc_hir_typeck::check::check_fn 8: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_kind 9: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args 10: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_argument_types 11: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_kind 12: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args 13: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_decl 14: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block 15: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args 16: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_return_or_body_tail 17: rustc_hir_typeck::check::check_fn 18: rustc_hir_typeck::typeck_with_inspect::{closure#0} 19: rustc_hir_typeck::typeck [... omitted 1 frame ...] 20: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis::check_crate::{closure#1}>::{closure#0} 21: rustc_hir_analysis::check_crate 22: rustc_interface::passes::run_required_analyses 23: rustc_interface::passes::analysis [... omitted 1 frame ...] 24: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}> 25: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1} note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. error: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md note: please make sure that you have updated to the latest nightly note: please attach the file at `/Users/jisukbyun/workspace/250203 scratch/rustc-ice-2025-05-26T15_22_30-94759.txt` to your bug report query stack during panic: #0 [typeck] type-checking `main` #1 [analysis] running analysis passes on this crate end of query stack 

Bisects to

tool version: cargo-bisect-rustc 0.6.9
command: cargo-bisect-rustc --start=2023-05-01 --end=2025-05-22 --regress ice --preserve --script rustc -- never_4.rs

******************************************************************************** Regression in nightly-2024-01-24 ******************************************************************************** fetching https://static.rust-lang.org/dist/2024-01-23/channel-rust-nightly-git-commit-hash.txt nightly manifest 2024-01-23: 40 B / 40 B [=======================================================] 100.00 % 825.50 KB/s converted 2024-01-23 to d5fd0997291ca0135401a39dff25c8a9c13b8961 fetching https://static.rust-lang.org/dist/2024-01-24/channel-rust-nightly-git-commit-hash.txt nightly manifest 2024-01-24: 40 B / 40 B [=======================================================] 100.00 % 938.10 KB/s converted 2024-01-24 to 5d3d3479d774754856db2db3e439dfb88ef3c52f looking for regression commit between 2024-01-23 and 2024-01-24 fetching (via remote github) commits from max(d5fd0997291ca0135401a39dff25c8a9c13b8961, 2024-01-21) to 5d3d3479d774754856db2db3e439dfb88ef3c52f ending github query because we found starting sha: d5fd0997291ca0135401a39dff25c8a9c13b8961 get_commits_between returning commits, len: 9 commit[0] 2024-01-22: Auto merge of #120242 - matthiaskrgr:rollup-a93yj3i, r=matthiaskrgr commit[1] 2024-01-22: Auto merge of #120251 - matthiaskrgr:rollup-gttrw68, r=matthiaskrgr commit[2] 2024-01-23: Auto merge of #120017 - nnethercote:lint-api, r=oli-obk commit[3] 2024-01-23: Auto merge of #119892 - joboet:libs_use_assert_unchecked, r=Nilstrieb,cuviper commit[4] 2024-01-23: Auto merge of #117958 - risc0:erik/target-triple, r=davidtwco,Mark-Simulacrum commit[5] 2024-01-23: Auto merge of #116152 - cjgillot:unchunck, r=nnethercote commit[6] 2024-01-23: Auto merge of #119044 - RalfJung:intern-without-types, r=oli-obk commit[7] 2024-01-23: Auto merge of #119433 - taiki-e:rc-uninit-ref, r=Nilstrieb commit[8] 2024-01-23: Auto merge of #120281 - fmease:rollup-9nxail8, r=fmease ERROR: no CI builds available between d5fd0997291ca0135401a39dff25c8a9c13b8961 and 5d3d3479d774754856db2db3e439dfb88ef3c52f within last 167 days 

PR-120104 in 120251 might be the cause

Notes

  • ICE location: compiler/rustc_hir_typeck/src/expr.rs Line-1781
    fn check_expr_array(
    &self,
    args: &'tcx [hir::Expr<'tcx>],
    expected: Expectation<'tcx>,
    expr: &'tcx hir::Expr<'tcx>,
    ) -> Ty<'tcx> {
    let element_ty = if !args.is_empty() {
    let coerce_to = expected
    .to_option(self)
    .and_then(|uty| match *self.try_structurally_resolve_type(expr.span, uty).kind() {
    ty::Array(ty, _) | ty::Slice(ty) => Some(ty),
    _ => None,
    })
    .unwrap_or_else(|| self.next_ty_var(expr.span));
    let mut coerce = CoerceMany::with_coercion_sites(coerce_to, args);
    assert_eq!(self.diverges.get(), Diverges::Maybe);

@rustbot label +F-never_patterns

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-never_patterns`#![feature(never_patterns)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions