Skip to content

ICE: None in rustc_mir_build/src/builder/matches/mod.rs #141589

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cushionbadak opened this issue May 26, 2025 · 2 comments
Closed

ICE: None in rustc_mir_build/src/builder/matches/mod.rs #141589

cushionbadak opened this issue May 26, 2025 · 2 comments
Labels
C-bug Category: This is a bug. F-never_patterns `#![feature(never_patterns)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@cushionbadak
Copy link

cushionbadak commented May 26, 2025

Code

#![feature(never_patterns)]
#![allow(incomplete_features)]
enum Void {}

enum Either {
    One(X),
    Two(X),
}

struct X;

fn move_into_fnmut() {
    let x = Either::One(X);
    || {
        let Either::Two(!) = x;
    };
}

fn main() {}

A mutant of glacier2's fixed/109523.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 --edition=2021

error: mismatched types
  --> never_1.rs:15:25
   |
15 |         let Either::Two(!) = x;
   |                         ^ a never pattern must be used on an uninhabited type
   |
   = note: the matched value is of type `X`


thread 'rustc' panicked at compiler/rustc_mir_build/src/builder/matches/mod.rs:2110:44:
called `Option::unwrap()` on a `None` value
Backtrace

thread 'rustc' panicked at compiler/rustc_mir_build/src/builder/matches/mod.rs:2110:44:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: core::option::unwrap_failed
   4: <rustc_mir_build::builder::Builder>::match_candidates_inner
   5: <rustc_mir_build::builder::Builder>::lower_match_tree
   6: <rustc_mir_build::builder::Builder>::place_into_pattern
   7: <rustc_mir_build::builder::Builder>::ast_block_stmts
   8: <rustc_mir_build::builder::Builder>::expr_into_dest
   9: <rustc_mir_build::builder::Builder>::as_temp_inner
  10: <rustc_mir_build::builder::Builder>::expr_into_dest
  11: <rustc_mir_build::builder::Builder>::expr_into_dest::{closure#0}
  12: <rustc_mir_build::builder::Builder>::expr_into_dest
  13: rustc_mir_build::builder::construct_fn
  14: rustc_mir_build::builder::build_mir
  15: rustc_mir_transform::mir_built
      [... omitted 1 frame ...]
  16: <rustc_mir_build::check_unsafety::UnsafetyVisitor>::visit_inner_body
  17: <rustc_mir_build::check_unsafety::UnsafetyVisitor as rustc_middle::thir::visit::Visitor>::visit_expr
  18: <rustc_mir_build::check_unsafety::UnsafetyVisitor as rustc_middle::thir::visit::Visitor>::visit_expr
  19: <rustc_mir_build::check_unsafety::UnsafetyVisitor as rustc_middle::thir::visit::Visitor>::visit_block
  20: <rustc_mir_build::check_unsafety::UnsafetyVisitor as rustc_middle::thir::visit::Visitor>::visit_expr
  21: <rustc_mir_build::check_unsafety::UnsafetyVisitor as rustc_middle::thir::visit::Visitor>::visit_expr
  22: rustc_mir_build::check_unsafety::check_unsafety
      [... omitted 1 frame ...]
  23: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
  24: rustc_interface::passes::run_required_analyses
  25: rustc_interface::passes::analysis
      [... omitted 1 frame ...]
  26: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
  27: 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-26T13_36_19-63737.txt` to your bug report

query stack during panic:
#0 [mir_built] building MIR for `move_into_fnmut::{closure#0}`
#1 [check_unsafety] unsafety-checking `move_into_fnmut`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 1 previous error

Bisects to

cargo-bisect-rustc 0.6.9

command: cargo-bisect-rustc --start=2023-05-01 --end=2024-05-01 --regress ice --preserve --script rustc -- never_1.rs --edition=2021

********************************************************************************
Regression in nightly-2024-01-21
********************************************************************************

fetching https://static.rust-lang.org/dist/2024-01-20/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2024-01-20: 40 B / 40 B [=======================================================] 100.00 % 779.89 KB/s converted 2024-01-20 to 88189a71e4e4376eea82ac61db6a539612eb200a
fetching https://static.rust-lang.org/dist/2024-01-21/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2024-01-21: 40 B / 40 B [=======================================================] 100.00 % 761.38 KB/s converted 2024-01-21 to 4cb17b4e78e0540e49d2da884cc621a6bf6f47fa
looking for regression commit between 2024-01-20 and 2024-01-21
fetching (via remote github) commits from max(88189a71e4e4376eea82ac61db6a539612eb200a, 2024-01-18) to 4cb17b4e78e0540e49d2da884cc621a6bf6f47fa
ending github query because we found starting sha: 88189a71e4e4376eea82ac61db6a539612eb200a
get_commits_between returning commits, len: 11
  commit[0] 2024-01-19: Auto merge of #120123 - lcnr:sadboi-compat, r=jackh726
  commit[1] 2024-01-20: Auto merge of #116672 - maurer:128-align, r=nikic
  commit[2] 2024-01-20: Auto merge of #120136 - matthiaskrgr:rollup-3zzb0z9, r=matthiaskrgr
  commit[3] 2024-01-20: Auto merge of #119821 - oli-obk:reveal_all_const_evals, r=lcnr
  commit[4] 2024-01-20: Auto merge of #120157 - matthiaskrgr:rollup-f0p3wkk, r=matthiaskrgr
  commit[5] 2024-01-20: Auto merge of #120003 - Mark-Simulacrum:opt-promoted, r=davidtwco
  commit[6] 2024-01-20: Auto merge of #116185 - Zoxc:rem-one-thread, r=cjgillot
  commit[7] 2024-01-20: Auto merge of #108359 - Zoxc:side-effects-tweak, r=cjgillot
  commit[8] 2024-01-20: Auto merge of #117756 - a1phyr:hashmap_fold, r=the8472
  commit[9] 2024-01-20: Auto merge of #120170 - GuillaumeGomez:rollup-edqdf30, r=GuillaumeGomez
  commit[10] 2024-01-20: Auto merge of #111803 - scottmcm:simple-swap-alternative, r=Mark-Simulacrum
ERROR: no CI builds available between 88189a71e4e4376eea82ac61db6a539612eb200a and 4cb17b4e78e0540e49d2da884cc621a6bf6f47fa within last 167 days

I guess it bisects to PR-120136, which includes PR-120009.

Notes

@rustbot label +F-never_patterns

@cushionbadak cushionbadak added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels May 26, 2025
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. F-never_patterns `#![feature(never_patterns)]` labels May 26, 2025
@matthiaskrgr
Copy link
Member

matthiaskrgr commented May 26, 2025

Yeah this looks like a duplicate of #137467 (comment)

in general, if you take a pattern that is already know to crash the compiler, then add another feature (making the crash depend on that presence of this feature) and file that as a different ice as "the other one did not need the feature", I don't think this is very helpful 😅

@cushionbadak
Copy link
Author

Got it. I’ll be more careful not to submit cases like this in the future.

I posted this one because the ICE in issue-137467 happens with an or pattern on the LHS of a let binding, while this report involves the never_patterns feature, so I thought they might be different in terms of the actual cause.

@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-never_patterns `#![feature(never_patterns)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants