[ICE]: `Invalid MIR: bad LHS type for binop`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
auto-reduced (treereduce-rust):
#![feature(generic_const_exprs, min_generic_const_args)]
struct Foo {
field: isize,
}
fn foo<const N: usize, const M: usize = { N + 1 }>() {
foo::<{ Foo { field: 1 } }>()
}
original:
#![feature(generic_const_exprs, min_generic_const_args)]
struct Foo {
field: isize,
}
fn foo<const N: usize, const M: usize = { N + 1 }>() {
foo::<{ Foo { field: 1 } }>()
}
fn main() {}
Version information
rustc 1.99.0-nightly (225e91c03 2026-07-13)
binary: rustc
commit-hash: 225e91c03da22cd4b9792b83c1cfc97967101614
commit-date: 2026-07-13
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 22.1.8
Possibly related line of code:
https://github.com/rust-lang/rust/blob/225e91c03da22cd4b9792b83c1cfc97967101614/compiler/rustc_const_eval/src/interpret/operator.rs#L417-L429
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
--> /tmp/icemaker_global_tempdir.t2HbistEZJBr/rustc_testrunner_tmpdir_reporting.hutxlaBp0SfX/mvce.rs:1:12
|
1 | #![feature(generic_const_exprs, min_generic_const_args)]
| ^^^^^^^^^^^^^^^^^^^
|
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
= note: `#[warn(incomplete_features)]` on by default
warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
--> /tmp/icemaker_global_tempdir.t2HbistEZJBr/rustc_testrunner_tmpdir_reporting.hutxlaBp0SfX/mvce.rs:1:33
|
1 | #![feature(generic_const_exprs, min_generic_const_args)]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
error[E0601]: `main` function not found in crate `mvce`
--> /tmp/icemaker_global_tempdir.t2HbistEZJBr/rustc_testrunner_tmpdir_reporting.hutxlaBp0SfX/mvce.rs:7:2
|
7 | }
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.t2HbistEZJBr/rustc_testrunner_tmpdir_reporting.hutxlaBp0SfX/mvce.rs`
error: defaults for generic parameters are not allowed here
--> /tmp/icemaker_global_tempdir.t2HbistEZJBr/rustc_testrunner_tmpdir_reporting.hutxlaBp0SfX/mvce.rs:5:24
|
5 | fn foo<const N: usize, const M: usize = { N + 1 }>() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: internal compiler error: /rustc-dev/225e91c03da22cd4b9792b83c1cfc97967101614/compiler/rustc_const_eval/src/interpret/operator.rs:423:18: Invalid MIR: bad LHS type for binop: Foo
--> /tmp/icemaker_global_tempdir.t2HbistEZJBr/rustc_testrunner_tmpdir_reporting.hutxlaBp0SfX/mvce.rs:5:43
|
5 | fn foo<const N: usize, const M: usize = { N + 1 }>() {
| ^^^^^
thread 'rustc' (207135) panicked at /rustc-dev/225e91c03da22cd4b9792b83c1cfc97967101614/compiler/rustc_const_eval/src/interpret/operator.rs:423:18:
Box<dyn Any>
stack backtrace:
0: 0x7fa06b60aa06 - <<std[f815c803b8bda7b3]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[a425eebf46758491]::fmt::Display>::fmt
1: 0x7fa06bc10dc8 - core[a425eebf46758491]::fmt::write
2: 0x7fa06b61fe7c - <std[f815c803b8bda7b3]::sys::stdio::unix::Stderr as core[a425eebf46758491]::io::write::Write>::write_fmt
3: 0x7fa06b5ded8a - std[f815c803b8bda7b3]::panicking::default_hook::{closure#0}
4: 0x7fa06b5fd123 - std[f815c803b8bda7b3]::panicking::default_hook
5: 0x7fa06a5d4a2b - std[f815c803b8bda7b3]::panicking::update_hook::<alloc[2f076b677b3e1a3b]::boxed::Box<rustc_driver_impl[f6b68445f387381]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x7fa06b5fd5c2 - std[f815c803b8bda7b3]::panicking::panic_with_hook
7: 0x7fa06a601a81 - std[f815c803b8bda7b3]::panicking::begin_panic::<rustc_errors[17885d358a472364]::ExplicitBug>::{closure#0}
8: 0x7fa06a5faa76 - std[f815c803b8bda7b3]::sys::backtrace::__rust_end_short_backtrace::<std[f815c803b8bda7b3]::panicking::begin_panic<rustc_errors[17885d358a472364]::ExplicitBug>::{closure#0}, !>
9: 0x7fa06a5fa7db - std[f815c803b8bda7b3]::panicking::begin_panic::<rustc_errors[17885d358a472364]::ExplicitBug>
10: 0x7fa06a60cc11 - <rustc_errors[17885d358a472364]::diagnostic::BugAbort as rustc_errors[17885d358a472364]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
11: 0x7fa06ab64cfc - <rustc_errors[17885d358a472364]::DiagCtxtHandle>::span_bug::<rustc_span[5e6c73db80a2ecda]::span_encoding::Span, alloc[2f076b677b3e1a3b]::string::String>
12: 0x7fa06ab93916 - rustc_middle[83d6f6fa2ecd6292]::util::bug::opt_span_bug_fmt::<rustc_span[5e6c73db80a2ecda]::span_encoding::Span>::{closure#0}
13: 0x7fa06ab93aa2 - rustc_middle[83d6f6fa2ecd6292]::ty::context::tls::with_opt::<rustc_middle[83d6f6fa2ecd6292]::util::bug::opt_span_bug_fmt<rustc_span[5e6c73db80a2ecda]::span_encoding::Span>::{closure#0}, !>::{closure#0}
14: 0x7fa06ab7f27b - rustc_middle[83d6f6fa2ecd6292]::ty::context::tls::with_context_opt::<rustc_middle[83d6f6fa2ecd6292]::ty::context::tls::with_opt<rustc_middle[83d6f6fa2ecd6292]::util::bug::opt_span_bug_fmt<rustc_span[5e6c73db80a2ecda]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
15: 0x7fa068c20608 - rustc_middle[83d6f6fa2ecd6292]::util::bug::span_bug_fmt::<rustc_span[5e6c73db80a2ecda]::span_encoding::Span>
16: 0x7fa06be73e48 - <rustc_const_eval[61e3780497d06163]::interpret::eval_context::InterpCx<rustc_const_eval[61e3780497d06163]::const_eval::machine::CompileTimeMachine>>::binary_op
17: 0x7fa06cc2cafe - <rustc_const_eval[61e3780497d06163]::interpret::eval_context::InterpCx<rustc_const_eval[61e3780497d06163]::const_eval::machine::CompileTimeMachine>>::eval_rvalue_into_place
18: 0x7fa06cc26510 - rustc_const_eval[61e3780497d06163]::const_eval::eval_queries::eval_to_allocation_raw_provider
19: 0x7fa06cc24b96 - rustc_query_impl[68a2f365f9927c9b]::query_impl::eval_to_allocation_raw::invoke_provider_fn::__rust_begin_short_backtrace
20: 0x7fa06cc205ac - rustc_query_impl[68a2f365f9927c9b]::execution::try_execute_query::<rustc_middle[83d6f6fa2ecd6292]::query::caches::DefaultCache<rustc_middle[83d6f6fa2ecd6292]::ty::PseudoCanonicalInput<rustc_middle[83d6f6fa2ecd6292]::mir::interpret::GlobalId>, rustc_middle[83d6f6fa2ecd6292]::query::erase::ErasedData<[u8; 24usize]>>, false>
21: 0x7fa06cc1f9ff - rustc_query_impl[68a2f365f9927c9b]::query_impl::eval_to_allocation_raw::execute_query_non_incr::__rust_end_short_backtrace
22: 0x7fa06cc1d76d - rustc_const_eval[61e3780497d06163]::const_eval::valtrees::eval_to_valtree
23: 0x7fa06cc1d526 - <rustc_const_eval[61e3780497d06163]::provide::{closure#0} as core[a425eebf46758491]::ops::function::FnOnce<(rustc_middle[83d6f6fa2ecd6292]::ty::context::TyCtxt, rustc_middle[83d6f6fa2ecd6292]::ty::PseudoCanonicalInput<rustc_middle[83d6f6fa2ecd6292]::mir::interpret::GlobalId>)>>::call_once
24: 0x7fa06cc1d4d8 - rustc_query_impl[68a2f365f9927c9b]::query_impl::eval_to_valtree::invoke_provider_fn::__rust_begin_short_backtrace
25: 0x7fa06cc16460 - rustc_query_impl[68a2f365f9927c9b]::execution::try_execute_query::<rustc_middle[83d6f6fa2ecd6292]::query::caches::DefaultCache<rustc_middle[83d6f6fa2ecd6292]::ty::PseudoCanonicalInput<rustc_middle[83d6f6fa2ecd6292]::mir::interpret::GlobalId>, rustc_middle[83d6f6fa2ecd6292]::query::erase::ErasedData<[u8; 16usize]>>, false>
26: 0x7fa06cc16108 - rustc_query_impl[68a2f365f9927c9b]::query_impl::eval_to_valtree::execute_query_non_incr::__rust_end_short_backtrace
27: 0x7fa06c946818 - <rustc_middle[83d6f6fa2ecd6292]::ty::context::TyCtxt>::const_eval_resolve_for_typeck
28: 0x7fa06c945a67 - rustc_trait_selection[9953319ec50c4b70]::traits::try_evaluate_const
29: 0x7fa06d53bd53 - rustc_trait_selection[9953319ec50c4b70]::traits::const_evaluatable::is_const_evaluatable.cold
30: 0x7fa06c2e70bc - <rustc_trait_selection[9953319ec50c4b70]::traits::fulfill::FulfillProcessor as rustc_data_structures[d208358c53517434]::obligation_forest::ObligationProcessor>::process_obligation
31: 0x7fa06bc05c51 - <rustc_data_structures[d208358c53517434]::obligation_forest::ObligationForest<rustc_trait_selection[9953319ec50c4b70]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[9953319ec50c4b70]::traits::fulfill::FulfillProcessor>
32: 0x7fa06bedc227 - <rustc_hir_typeck[f0e17d0ac8b05531]::fn_ctxt::FnCtxt>::check_expr_call
33: 0x7fa06bf03d19 - <rustc_hir_typeck[f0e17d0ac8b05531]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
34: 0x7fa06bf0e4b0 - <rustc_hir_typeck[f0e17d0ac8b05531]::fn_ctxt::FnCtxt>::check_expr_block
35: 0x7fa06bf03cc4 - <rustc_hir_typeck[f0e17d0ac8b05531]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
36: 0x7fa06bf30818 - rustc_hir_typeck[f0e17d0ac8b05531]::check::check_fn
37: 0x7fa06ce60cd2 - rustc_hir_typeck[f0e17d0ac8b05531]::typeck_with_inspect::{closure#0}
38: 0x7fa06ce5f5f0 - rustc_query_impl[68a2f365f9927c9b]::query_impl::typeck_root::invoke_provider_fn::__rust_begin_short_backtrace
39: 0x7fa06c26f4e9 - rustc_query_impl[68a2f365f9927c9b]::execution::try_execute_query::<rustc_data_structures[d208358c53517434]::vec_cache::VecCache<rustc_span[5e6c73db80a2ecda]::def_id::LocalDefId, rustc_middle[83d6f6fa2ecd6292]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[83d6f6fa2ecd6292]::dep_graph::graph::DepNodeIndex>, false>
40: 0x7fa06c26ef43 - rustc_query_impl[68a2f365f9927c9b]::query_impl::typeck_root::execute_query_non_incr::__rust_end_short_backtrace
41: 0x7fa06c271629 - <rustc_middle[83d6f6fa2ecd6292]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[d14ae22442f42ae1]::check_crate::{closure#1}>::{closure#0}
42: 0x7fa06c270f30 - rustc_hir_analysis[d14ae22442f42ae1]::check_crate
43: 0x7fa06c26bc0b - rustc_interface[daa1f9eccb307e6d]::passes::analysis
44: 0x7fa06cdf2687 - rustc_query_impl[68a2f365f9927c9b]::execution::try_execute_query::<rustc_middle[83d6f6fa2ecd6292]::query::caches::SingleCache<rustc_middle[83d6f6fa2ecd6292]::query::erase::ErasedData<[u8; 0usize]>>, false>
45: 0x7fa06cdf2369 - rustc_query_impl[68a2f365f9927c9b]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
46: 0x7fa06cd85d1b - rustc_interface[daa1f9eccb307e6d]::interface::run_compiler::<(), rustc_driver_impl[f6b68445f387381]::run_compiler::{closure#0}>::{closure#1}
47: 0x7fa06cddd0ba - std[f815c803b8bda7b3]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[daa1f9eccb307e6d]::util::run_in_thread_with_globals<rustc_interface[daa1f9eccb307e6d]::util::run_in_thread_pool_with_globals<rustc_interface[daa1f9eccb307e6d]::interface::run_compiler<(), rustc_driver_impl[f6b68445f387381]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
48: 0x7fa06cddce6d - <std[f815c803b8bda7b3]::thread::lifecycle::spawn_unchecked<rustc_interface[daa1f9eccb307e6d]::util::run_in_thread_with_globals<rustc_interface[daa1f9eccb307e6d]::util::run_in_thread_pool_with_globals<rustc_interface[daa1f9eccb307e6d]::interface::run_compiler<(), rustc_driver_impl[f6b68445f387381]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[a425eebf46758491]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
49: 0x7fa06cde1290 - <std[f815c803b8bda7b3]::sys::thread::unix::Thread>::new::thread_start
50: 0x7fa066697739 - <unknown>
51: 0x7fa06671bedc - <unknown>
52: 0x0 - <unknown>
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: rustc 1.99.0-nightly (225e91c03 2026-07-13) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `foo::{constant#0}`
#1 [eval_to_valtree] evaluating type-level constant
#2 [typeck_root] type-checking `foo`
#3 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 3 previous errors; 2 warnings emitted
For more information about this error, try `rustc --explain E0601`.
@rustbot label +F-generic_const_exprs +F-min_generic_const_args
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the reduced program in a.rs with the nightly rustc command shown in the issue, then read compiler/rustc_const_eval/src/interpret/operator.rs around lines 417-429 and follow the binary_op call in the backtrace. Determine why the Foo constant reaches the invalid MIR check; done means the reproducer no longer triggers an internal compiler error and instead produces valid diagnostics or evaluation behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100