Skip to content

ICE: Invalid operation on bool: MulWithOverflow #136766

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

Open
matthiaskrgr opened this issue Feb 9, 2025 · 8 comments
Open

ICE: Invalid operation on bool: MulWithOverflow #136766

matthiaskrgr opened this issue Feb 9, 2025 · 8 comments
Assignees
Labels
C-bug Category: This is a bug. F-generic_const_exprs `#![feature(generic_const_exprs)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-slow Issue: Problems and improvements with respect to performance of generated code. S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

#![feature(generic_const_exprs)]
trait A<const B: bool> {}

impl A<true> for () {}

fn needs_a<const N: usize>(_: [(&'a T, &'a U); N * N])
where
    (): A<N>,
{
}

pub fn main() {
    needs_a([]);
}

original:

//@ revisions: current next
//@[next] compile-flags: -Znext-solver
//@ ignore-compare-mode-next-solver (explicit revisions)

trait A<const B: bool> {}

impl A<true> for () {}

fn needs_a<const N: usize>(_: [(&'a T, &'a U); N * N]) where (): A<N> {}
//~^ ERROR the constant `N` is not of type `bool`

pub fn main() {
    needs_a([]);
    //~^ ERROR the constant `true` is not of type `usize`
    //~| ERROR mismatched types
    // FIXME(const_generics): we should hide this error as we've already errored above
}

Version information

rustc 1.86.0-nightly (43ca9d18e 2025-02-08)
binary: rustc
commit-hash: 43ca9d18e333797f0aa3b525501a7cec8d61a96b
commit-date: 2025-02-08
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7

Possibly related line of code:

Le => l <= r,
Gt => l > r,
Ge => l >= r,
BitAnd => l & r,
BitOr => l | r,
BitXor => l ^ r,
_ => span_bug!(self.cur_span(), "Invalid operation on bool: {:?}", bin_op),
};
ImmTy::from_bool(res, *self.tcx)
}
fn binary_float_op<F: Float + FloatConvert<F> + Into<Scalar<M::Provenance>>>(
&self,

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(generic_const_exprs)

Program output

error[E0261]: use of undeclared lifetime name `'a`
 --> /tmp/icemaker_global_tempdir.Tw5KION65QBu/rustc_testrunner_tmpdir_reporting.KAL2r19SbBmX/mvce.rs:5:34
  |
5 | fn needs_a<const N: usize>(_: [(&'a T, &'a U); N * N])
  |            -                     ^^ undeclared lifetime
  |            |
  |            help: consider introducing lifetime `'a` here: `'a,`

error[E0261]: use of undeclared lifetime name `'a`
 --> /tmp/icemaker_global_tempdir.Tw5KION65QBu/rustc_testrunner_tmpdir_reporting.KAL2r19SbBmX/mvce.rs:5:41
  |
5 | fn needs_a<const N: usize>(_: [(&'a T, &'a U); N * N])
  |            -                            ^^ undeclared lifetime
  |            |
  |            help: consider introducing lifetime `'a` here: `'a,`

error[E0412]: cannot find type `T` in this scope
 --> /tmp/icemaker_global_tempdir.Tw5KION65QBu/rustc_testrunner_tmpdir_reporting.KAL2r19SbBmX/mvce.rs:5:37
  |
1 | trait A<const B: bool> {}
  | ---------------------- similarly named trait `A` defined here
...
5 | fn needs_a<const N: usize>(_: [(&'a T, &'a U); N * N])
  |                                     ^
  |
help: a trait with a similar name exists
  |
5 | fn needs_a<const N: usize>(_: [(&'a A, &'a U); N * N])
  |                                     ~
help: you might be missing a type parameter
  |
5 | fn needs_a<const N: usize, T>(_: [(&'a T, &'a U); N * N])
  |                          +++

error[E0412]: cannot find type `U` in this scope
 --> /tmp/icemaker_global_tempdir.Tw5KION65QBu/rustc_testrunner_tmpdir_reporting.KAL2r19SbBmX/mvce.rs:5:44
  |
1 | trait A<const B: bool> {}
  | ---------------------- similarly named trait `A` defined here
...
5 | fn needs_a<const N: usize>(_: [(&'a T, &'a U); N * N])
  |                                            ^
  |
help: a trait with a similar name exists
  |
5 | fn needs_a<const N: usize>(_: [(&'a T, &'a A); N * N])
  |                                            ~
help: you might be missing a type parameter
  |
5 | fn needs_a<const N: usize, U>(_: [(&'a T, &'a U); N * N])
  |                          +++

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> <crate attribute>:1:9
  |
1 | feature(generic_const_exprs)
  |         ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
  = note: `#[warn(incomplete_features)]` on by default

error: the constant `N` is not of type `bool`
 --> /tmp/icemaker_global_tempdir.Tw5KION65QBu/rustc_testrunner_tmpdir_reporting.KAL2r19SbBmX/mvce.rs:7:9
  |
7 |     (): A<N>,
  |         ^^^^ expected `bool`, found `usize`
  |
note: required by a const generic parameter in `A`
 --> /tmp/icemaker_global_tempdir.Tw5KION65QBu/rustc_testrunner_tmpdir_reporting.KAL2r19SbBmX/mvce.rs:1:9
  |
1 | trait A<const B: bool> {}
  |         ^^^^^^^^^^^^^ required by this const generic parameter in `A`

error: internal compiler error: compiler/rustc_const_eval/src/interpret/operator.rs:52:18: Invalid operation on bool: MulWithOverflow
 --> /tmp/icemaker_global_tempdir.Tw5KION65QBu/rustc_testrunner_tmpdir_reporting.KAL2r19SbBmX/mvce.rs:5:48
  |
5 | fn needs_a<const N: usize>(_: [(&'a T, &'a U); N * N])
  |                                                ^^^^^


thread 'rustc' panicked at compiler/rustc_const_eval/src/interpret/operator.rs:52:18:
Box<dyn Any>
stack backtrace:
   0:     0x73590802c500 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h1b226bb815bf78f5
   1:     0x7359088146e8 - core::fmt::write::h5f68f60039d1d2a6
   2:     0x735909b64791 - std::io::Write::write_fmt::h2f9a797f5ecd0cae
   3:     0x73590802c362 - std::sys::backtrace::BacktraceLock::print::h0b9c3be369c24724
   4:     0x73590802e7e2 - std::panicking::default_hook::{{closure}}::h793d3a348a3aeaff
   5:     0x73590802e66a - std::panicking::default_hook::h56b0b57f5f9ffa8a
   6:     0x735907188839 - std[3fff7a6371a6e7c2]::panicking::update_hook::<alloc[62c04a7c9cb01615]::boxed::Box<rustc_driver_impl[afdcaabde0c38b30]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x73590802f323 - std::panicking::rust_panic_with_hook::hcb5df778ecc712ed
   8:     0x7359071c3bf1 - std[3fff7a6371a6e7c2]::panicking::begin_panic::<rustc_errors[70c172070bd433dc]::ExplicitBug>::{closure#0}
   9:     0x7359071b8b66 - std[3fff7a6371a6e7c2]::sys::backtrace::__rust_end_short_backtrace::<std[3fff7a6371a6e7c2]::panicking::begin_panic<rustc_errors[70c172070bd433dc]::ExplicitBug>::{closure#0}, !>
  10:     0x7359071b58e9 - std[3fff7a6371a6e7c2]::panicking::begin_panic::<rustc_errors[70c172070bd433dc]::ExplicitBug>
  11:     0x7359071cdbc1 - <rustc_errors[70c172070bd433dc]::diagnostic::BugAbort as rustc_errors[70c172070bd433dc]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x735907729d9c - <rustc_errors[70c172070bd433dc]::DiagCtxtHandle>::span_bug::<rustc_span[b8e92fef1403c7b]::span_encoding::Span, alloc[62c04a7c9cb01615]::string::String>
  13:     0x7359077ab057 - rustc_middle[5a19c9913f5418cc]::util::bug::opt_span_bug_fmt::<rustc_span[b8e92fef1403c7b]::span_encoding::Span>::{closure#0}
  14:     0x735907793bca - rustc_middle[5a19c9913f5418cc]::ty::context::tls::with_opt::<rustc_middle[5a19c9913f5418cc]::util::bug::opt_span_bug_fmt<rustc_span[b8e92fef1403c7b]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  15:     0x735907793a5b - rustc_middle[5a19c9913f5418cc]::ty::context::tls::with_context_opt::<rustc_middle[5a19c9913f5418cc]::ty::context::tls::with_opt<rustc_middle[5a19c9913f5418cc]::util::bug::opt_span_bug_fmt<rustc_span[b8e92fef1403c7b]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  16:     0x735905c3dff7 - rustc_middle[5a19c9913f5418cc]::util::bug::span_bug_fmt::<rustc_span[b8e92fef1403c7b]::span_encoding::Span>
  17:     0x7359088a1f31 - <rustc_const_eval[e4956babb8e22105]::interpret::eval_context::InterpCx<rustc_const_eval[e4956babb8e22105]::const_eval::machine::CompileTimeMachine>>::binary_op
  18:     0x7359093eba6b - <rustc_const_eval[e4956babb8e22105]::interpret::eval_context::InterpCx<rustc_const_eval[e4956babb8e22105]::const_eval::machine::CompileTimeMachine>>::eval_rvalue_into_place
  19:     0x7359065818a9 - rustc_const_eval[e4956babb8e22105]::const_eval::eval_queries::eval_to_allocation_raw_provider
  20:     0x735908ef975c - rustc_query_impl[568d4bcab549c9ff]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[568d4bcab549c9ff]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5a19c9913f5418cc]::query::erase::Erased<[u8; 24usize]>>
  21:     0x735908ef90fa - rustc_query_system[cf17836f2ec93676]::query::plumbing::try_execute_query::<rustc_query_impl[568d4bcab549c9ff]::DynamicConfig<rustc_query_system[cf17836f2ec93676]::query::caches::DefaultCache<rustc_middle[5a19c9913f5418cc]::ty::PseudoCanonicalInput<rustc_middle[5a19c9913f5418cc]::mir::interpret::GlobalId>, rustc_middle[5a19c9913f5418cc]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[568d4bcab549c9ff]::plumbing::QueryCtxt, false>
  22:     0x735908ef8d7b - rustc_query_impl[568d4bcab549c9ff]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
  23:     0x735908eff16d - rustc_const_eval[e4956babb8e22105]::const_eval::valtrees::eval_to_valtree
  24:     0x735908efef3e - <rustc_const_eval[e4956babb8e22105]::provide::{closure#0} as core[5ee9194023cfa8f]::ops::function::FnOnce<(rustc_middle[5a19c9913f5418cc]::ty::context::TyCtxt, rustc_middle[5a19c9913f5418cc]::ty::PseudoCanonicalInput<rustc_middle[5a19c9913f5418cc]::mir::interpret::GlobalId>)>>::call_once
  25:     0x735908efeed0 - rustc_query_impl[568d4bcab549c9ff]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[568d4bcab549c9ff]::query_impl::eval_to_valtree::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5a19c9913f5418cc]::query::erase::Erased<[u8; 24usize]>>
  26:     0x735908efee89 - <rustc_query_impl[568d4bcab549c9ff]::query_impl::eval_to_valtree::dynamic_query::{closure#2} as core[5ee9194023cfa8f]::ops::function::FnOnce<(rustc_middle[5a19c9913f5418cc]::ty::context::TyCtxt, rustc_middle[5a19c9913f5418cc]::ty::PseudoCanonicalInput<rustc_middle[5a19c9913f5418cc]::mir::interpret::GlobalId>)>>::call_once
  27:     0x735908ef91d3 - rustc_query_system[cf17836f2ec93676]::query::plumbing::try_execute_query::<rustc_query_impl[568d4bcab549c9ff]::DynamicConfig<rustc_query_system[cf17836f2ec93676]::query::caches::DefaultCache<rustc_middle[5a19c9913f5418cc]::ty::PseudoCanonicalInput<rustc_middle[5a19c9913f5418cc]::mir::interpret::GlobalId>, rustc_middle[5a19c9913f5418cc]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[568d4bcab549c9ff]::plumbing::QueryCtxt, false>
  28:     0x735908ef8b13 - rustc_query_impl[568d4bcab549c9ff]::query_impl::eval_to_valtree::get_query_non_incr::__rust_end_short_backtrace
  29:     0x73590906724c - rustc_middle[5a19c9913f5418cc]::query::plumbing::query_get_at::<rustc_query_system[cf17836f2ec93676]::query::caches::DefaultCache<rustc_middle[5a19c9913f5418cc]::ty::PseudoCanonicalInput<rustc_middle[5a19c9913f5418cc]::mir::interpret::GlobalId>, rustc_middle[5a19c9913f5418cc]::query::erase::Erased<[u8; 24usize]>>>
  30:     0x735909066862 - <rustc_middle[5a19c9913f5418cc]::ty::context::TyCtxt>::const_eval_global_id_for_typeck
  31:     0x7359090666f9 - <rustc_middle[5a19c9913f5418cc]::ty::context::TyCtxt>::const_eval_resolve_for_typeck
  32:     0x735909066437 - rustc_trait_selection[59d4f5ca90fd2e37]::traits::try_evaluate_const
  33:     0x73590a48ddfc - rustc_trait_selection[59d4f5ca90fd2e37]::traits::const_evaluatable::is_const_evaluatable.cold
  34:     0x7359091b80c2 - <rustc_trait_selection[59d4f5ca90fd2e37]::traits::fulfill::FulfillProcessor as rustc_data_structures[e2e7e2ff480ff884]::obligation_forest::ObligationProcessor>::process_obligation
  35:     0x735908807a4b - <rustc_data_structures[e2e7e2ff480ff884]::obligation_forest::ObligationForest<rustc_trait_selection[59d4f5ca90fd2e37]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[59d4f5ca90fd2e37]::traits::fulfill::FulfillProcessor>
  36:     0x73590892c7ea - <rustc_hir_typeck[1a28ab23194131d9]::fn_ctxt::FnCtxt>::try_structurally_resolve_type
  37:     0x7359094a6a2b - <rustc_hir_typeck[1a28ab23194131d9]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  38:     0x7359094a82bb - <rustc_hir_typeck[1a28ab23194131d9]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  39:     0x7359094a174f - <rustc_hir_typeck[1a28ab23194131d9]::fn_ctxt::FnCtxt>::check_expr_block
  40:     0x7359094a91fe - <rustc_hir_typeck[1a28ab23194131d9]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  41:     0x735908cf55d7 - rustc_hir_typeck[1a28ab23194131d9]::check::check_fn
  42:     0x735908cfe472 - rustc_hir_typeck[1a28ab23194131d9]::typeck_with_inspect::{closure#0}
  43:     0x735908cfc44c - rustc_query_impl[568d4bcab549c9ff]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[568d4bcab549c9ff]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5a19c9913f5418cc]::query::erase::Erased<[u8; 8usize]>>
  44:     0x735908c01b4e - rustc_query_system[cf17836f2ec93676]::query::plumbing::try_execute_query::<rustc_query_impl[568d4bcab549c9ff]::DynamicConfig<rustc_data_structures[e2e7e2ff480ff884]::vec_cache::VecCache<rustc_span[b8e92fef1403c7b]::def_id::LocalDefId, rustc_middle[5a19c9913f5418cc]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[cf17836f2ec93676]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[568d4bcab549c9ff]::plumbing::QueryCtxt, false>
  45:     0x735908c00d1f - rustc_query_impl[568d4bcab549c9ff]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  46:     0x735908c009d9 - <rustc_middle[5a19c9913f5418cc]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[3b61b7cada22afae]::check_crate::{closure#3}>::{closure#0}
  47:     0x735908c00049 - rustc_hir_analysis[3b61b7cada22afae]::check_crate
  48:     0x735908bfaba5 - rustc_interface[88e21834afb68210]::passes::run_required_analyses
  49:     0x7359092f409e - rustc_interface[88e21834afb68210]::passes::analysis
  50:     0x7359092f406f - rustc_query_impl[568d4bcab549c9ff]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[568d4bcab549c9ff]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5a19c9913f5418cc]::query::erase::Erased<[u8; 0usize]>>
  51:     0x7359097d56d5 - rustc_query_system[cf17836f2ec93676]::query::plumbing::try_execute_query::<rustc_query_impl[568d4bcab549c9ff]::DynamicConfig<rustc_query_system[cf17836f2ec93676]::query::caches::SingleCache<rustc_middle[5a19c9913f5418cc]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[568d4bcab549c9ff]::plumbing::QueryCtxt, false>
  52:     0x7359097d540e - rustc_query_impl[568d4bcab549c9ff]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  53:     0x735909748bab - rustc_interface[88e21834afb68210]::passes::create_and_enter_global_ctxt::<core[5ee9194023cfa8f]::option::Option<rustc_interface[88e21834afb68210]::queries::Linker>, rustc_driver_impl[afdcaabde0c38b30]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  54:     0x7359097b989c - rustc_interface[88e21834afb68210]::interface::run_compiler::<(), rustc_driver_impl[afdcaabde0c38b30]::run_compiler::{closure#0}>::{closure#1}
  55:     0x7359096af804 - std[3fff7a6371a6e7c2]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[88e21834afb68210]::util::run_in_thread_with_globals<rustc_interface[88e21834afb68210]::util::run_in_thread_pool_with_globals<rustc_interface[88e21834afb68210]::interface::run_compiler<(), rustc_driver_impl[afdcaabde0c38b30]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  56:     0x7359096af4d9 - <<std[3fff7a6371a6e7c2]::thread::Builder>::spawn_unchecked_<rustc_interface[88e21834afb68210]::util::run_in_thread_with_globals<rustc_interface[88e21834afb68210]::util::run_in_thread_pool_with_globals<rustc_interface[88e21834afb68210]::interface::run_compiler<(), rustc_driver_impl[afdcaabde0c38b30]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[5ee9194023cfa8f]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  57:     0x7359096aec6f - std::sys::pal::unix::thread::Thread::new::thread_start::hb3b2c97ca272329f
  58:     0x7359038a339d - <unknown>
  59:     0x73590392849c - <unknown>
  60:                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.86.0-nightly (43ca9d18e 2025-02-08) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z crate-attr=feature(generic_const_exprs) -Z dump-mir-dir=dir

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `needs_a::{constant#0}`
#1 [eval_to_valtree] evaluating type-level constant
#2 [typeck] type-checking `main`
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 6 previous errors; 1 warning emitted

Some errors have detailed explanations: E0261, E0412.
For more information about an error, try `rustc --explain E0261`.

@rustbot label +F-generic_const_exprs

@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. 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. labels Feb 9, 2025
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. F-generic_const_exprs `#![feature(generic_const_exprs)]` labels Feb 9, 2025
@matthiaskrgr
Copy link
Member Author

smaller

#![feature(generic_const_exprs)]
trait A<const B: bool>{}
impl A<true> for () {}
fn c<const D: usize>(E: [u8; D * D]) where() : A<D>{}
fn main() { c }

bisects to nightly-2024-02-15, could be related to #120847

fetching (via remote github) commits from max(a84bb95a1f65bfe25038f188763a18e096a86ab2, 2024-02-12) to ee9c7c940c07d8b67c9a6b2ec930db70dcd23a46
ending github query because we found starting sha: a84bb95a1f65bfe25038f188763a18e096a86ab2
get_commits_between returning commits, len: 9
  commit[0] 2024-02-13: Auto merge of #121036 - matthiaskrgr:rollup-ul05q8e, r=matthiaskrgr
  commit[1] 2024-02-14: Auto merge of #120942 - compiler-errors:deep-assoc-hang, r=lcnr
  commit[2] 2024-02-14: Auto merge of #121055 - matthiaskrgr:rollup-bzn5sda, r=matthiaskrgr
  commit[3] 2024-02-14: Auto merge of #120454 - clubby789:cargo-update, r=Nilstrieb
  commit[4] 2024-02-14: Auto merge of #121018 - oli-obk:impl_unsafety, r=TaKO8Ki
  commit[5] 2024-02-14: Auto merge of #100603 - tmandry:zst-guards, r=dtolnay
  commit[6] 2024-02-14: Auto merge of #121078 - oli-obk:rollup-p11zsav, r=oli-obk
  commit[7] 2024-02-14: Auto merge of #121086 - GuillaumeGomez:rollup-y82fs9y, r=GuillaumeGomez
  commit[8] 2024-02-14: Auto merge of #120847 - oli-obk:track_errors9, r=compiler-errors

@chenyukang
Copy link
Member

chenyukang commented Feb 9, 2025

@RalfJung
seems all the binary_*_op in const eval didn't consider the already reported error may introduce an invalid operation:
https://github.com/chenyukang/rust/blob/ace6bb9869747b50d7d4bfaacc65d0592ec94aef/compiler/rustc_const_eval/src/interpret/operator.rs#L20-L84

For this test code, the reported error is:

error: the constant `D` is not of type `bool`
 --> ./t/now.rs:6:9
  |
6 |     (): A<D>,
  |         ^^^^ expected `bool`, found `usize`
  |
note: required by a const generic parameter in `A`
 --> ./t/now.rs:2:9
  |
2 | trait A<const B: bool> {}
  |         ^^^^^^^^^^^^^ required by this const generic parameter in `A`

@RalfJung
Copy link
Member

Looks like a tainting bug, we shouldn't try to interpret MIR that does not type-check.

Cc @oli-obk

@oli-obk

This comment has been minimized.

@oli-obk oli-obk added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Feb 10, 2025
@matthiaskrgr

This comment has been minimized.

@oli-obk

This comment has been minimized.

@matthiaskrgr

This comment has been minimized.

@oli-obk

This comment has been minimized.

@oli-obk oli-obk removed the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Feb 10, 2025
@chenyukang chenyukang self-assigned this Feb 10, 2025
@Noratrieb Noratrieb added I-slow Issue: Problems and improvements with respect to performance of generated code. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 1, 2025
@Noratrieb Noratrieb marked this as a duplicate of #136755 Mar 1, 2025
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Mar 9, 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-generic_const_exprs `#![feature(generic_const_exprs)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-slow Issue: Problems and improvements with respect to performance of generated code. S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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

6 participants