Skip to content

ICE: fast reject: kind mismatch: {type error} 3_u8 #136063

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 Jan 25, 2025 · 1 comment
Open

ICE: fast reject: kind mismatch: {type error} 3_u8 #136063

matthiaskrgr opened this issue Jan 25, 2025 · 1 comment
Labels
A-dyn-trait Area: trait objects, vtable layout 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) ❄️ 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 Traitor<const N: u8 = 1, const M: u8 = repeat_36> {}

impl Traitor<2, 3> for bool {}

fn bar<const N: u8>(arg: &dyn Traitor<N>) -> u8 {
    arg.owo()
}

fn main() {
    bar(&true);
}

original:

trait Trait<const N: u8 = 12> {
    fn uwu(&self) -> u8 {
        N
    }
}

impl Trait<2> for u32 {}

fn foo(arg: &dyn Trait) -> isize {
    arg.uwu()
}

trait Traitor<const N: u8 = 1, const M: u8 = repeat_36> {
    fn owo(&self) -> u8 {
        M
    }
}

impl Traitor<2, 3> for bool {}

fn bar<const N: u8>(arg: &dyn Traitor<N>) -> u8 {
    arg.owo()
}

fn main() {
    foo(&10_u32);
    //~^ error: the trait bound `u32: Trait` is not satisfied
    bar(&true);
    //~^ error: the trait bound `bool: Traitor<_>` is not satisfied
}

Version information

rustc 1.86.0-nightly (203e6c127 2025-01-25)
binary: rustc
commit-hash: 203e6c127c50c499be53731a39fe36d24f544502
commit-date: 2025-01-25
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7

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

Program output

error[E0425]: cannot find value `repeat_36` in this scope
 --> /tmp/icemaker_global_tempdir.WTfAIAh7lsb4/rustc_testrunner_tmpdir_reporting.MvFPhVMEvs6Q/mvce.rs:1:46
  |
1 | trait Traitor<const N: u8 = 1, const M: u8 = repeat_36> {}
  |                                              ^^^^^^^^^ not found in this scope

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[E0393]: the type parameter `M` must be explicitly specified
 --> /tmp/icemaker_global_tempdir.WTfAIAh7lsb4/rustc_testrunner_tmpdir_reporting.MvFPhVMEvs6Q/mvce.rs:5:31
  |
1 | trait Traitor<const N: u8 = 1, const M: u8 = repeat_36> {}
  | ------------------------------------------------------- type parameter `M` must be specified for this
...
5 | fn bar<const N: u8>(arg: &dyn Traitor<N>) -> u8 {
  |                               ^^^^^^^^^^ missing reference to `M`
  |
  = note: because the parameter default references `Self`, the parameter must be specified on the object type


thread 'rustc' panicked at /rustc/203e6c127c50c499be53731a39fe36d24f544502/compiler/rustc_type_ir/src/fast_reject.rs:254:22:
kind mismatch: {type error} 3_u8
stack backtrace:
   0:     0x7b60dde902a0 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hdfdabc38b8669c9f
   1:     0x7b60de6150e6 - core::fmt::write::h85841a8a9f23dd59
   2:     0x7b60df5594d1 - std::io::Write::write_fmt::hf2e4fe8e168db1b7
   3:     0x7b60dde90102 - std::sys::backtrace::BacktraceLock::print::h14149197b7c0de32
   4:     0x7b60dde92582 - std::panicking::default_hook::{{closure}}::h9943e5f3f0626409
   5:     0x7b60dde9240a - std::panicking::default_hook::hdd3968de3a098232
   6:     0x7b60dd0459e9 - std[57730b54ef401f3]::panicking::update_hook::<alloc[f5830c3c5cfb9e11]::boxed::Box<rustc_driver_impl[238e9adc12ab3263]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7b60dde93103 - std::panicking::rust_panic_with_hook::h73ef51d9a205dc0a
   8:     0x7b60dde92dfa - std::panicking::begin_panic_handler::{{closure}}::hed515db6078dd255
   9:     0x7b60dde90789 - std::sys::backtrace::__rust_end_short_backtrace::h8ba760917d95b5b1
  10:     0x7b60dde92abd - rust_begin_unwind
  11:     0x7b60dab98400 - core::panicking::panic_fmt::h5ecc779537f0304d
  12:     0x7b60db43899b - <rustc_trait_selection[4ba0541b438290d2]::traits::select::SelectionContext>::assemble_candidates_from_impls
  13:     0x7b60db415705 - <rustc_trait_selection[4ba0541b438290d2]::traits::select::SelectionContext>::candidate_from_obligation::{closure#0}::{closure#0}
  14:     0x7b60dae5c32e - <rustc_trait_selection[4ba0541b438290d2]::traits::select::SelectionContext>::poly_select::{closure#0}
  15:     0x7b60deee6030 - <rustc_trait_selection[4ba0541b438290d2]::traits::fulfill::FulfillProcessor as rustc_data_structures[b1621f9a8426d32f]::obligation_forest::ObligationProcessor>::process_obligation
  16:     0x7b60de610882 - <rustc_data_structures[b1621f9a8426d32f]::obligation_forest::ObligationForest<rustc_trait_selection[4ba0541b438290d2]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[4ba0541b438290d2]::traits::fulfill::FulfillProcessor>
  17:     0x7b60de79f0e4 - <rustc_hir_typeck[f3c634e21e25c7e1]::fn_ctxt::FnCtxt>::confirm_builtin_call
  18:     0x7b60df390bc8 - <rustc_hir_typeck[f3c634e21e25c7e1]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  19:     0x7b60df389dcf - <rustc_hir_typeck[f3c634e21e25c7e1]::fn_ctxt::FnCtxt>::check_expr_block
  20:     0x7b60df3916d4 - <rustc_hir_typeck[f3c634e21e25c7e1]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  21:     0x7b60dec88780 - rustc_hir_typeck[f3c634e21e25c7e1]::check::check_fn
  22:     0x7b60dec9163d - rustc_hir_typeck[f3c634e21e25c7e1]::typeck_with_inspect::{closure#0}
  23:     0x7b60dec8f64c - rustc_query_impl[db064f70679e7e57]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[db064f70679e7e57]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e5994b11539d1088]::query::erase::Erased<[u8; 8usize]>>
  24:     0x7b60de981a4e - rustc_query_system[acb98781fee9c8ed]::query::plumbing::try_execute_query::<rustc_query_impl[db064f70679e7e57]::DynamicConfig<rustc_data_structures[b1621f9a8426d32f]::vec_cache::VecCache<rustc_span[573b00108592c307]::def_id::LocalDefId, rustc_middle[e5994b11539d1088]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[acb98781fee9c8ed]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[db064f70679e7e57]::plumbing::QueryCtxt, false>
  25:     0x7b60de97ff51 - rustc_query_impl[db064f70679e7e57]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  26:     0x7b60de97fc0b - <rustc_middle[e5994b11539d1088]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[f7ab43cc31358404]::check_crate::{closure#4}>::{closure#0}
  27:     0x7b60de97dcbf - rustc_hir_analysis[f7ab43cc31358404]::check_crate
  28:     0x7b60de97a2e2 - rustc_interface[a9a02922dc001c32]::passes::run_required_analyses
  29:     0x7b60df554bde - rustc_interface[a9a02922dc001c32]::passes::analysis
  30:     0x7b60df554baf - rustc_query_impl[db064f70679e7e57]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[db064f70679e7e57]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e5994b11539d1088]::query::erase::Erased<[u8; 0usize]>>
  31:     0x7b60df541b55 - rustc_query_system[acb98781fee9c8ed]::query::plumbing::try_execute_query::<rustc_query_impl[db064f70679e7e57]::DynamicConfig<rustc_query_system[acb98781fee9c8ed]::query::caches::SingleCache<rustc_middle[e5994b11539d1088]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[db064f70679e7e57]::plumbing::QueryCtxt, false>
  32:     0x7b60df54188e - rustc_query_impl[db064f70679e7e57]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  33:     0x7b60df603969 - rustc_interface[a9a02922dc001c32]::passes::create_and_enter_global_ctxt::<core[bef17dfe197dbeb2]::option::Option<rustc_interface[a9a02922dc001c32]::queries::Linker>, rustc_driver_impl[238e9adc12ab3263]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  34:     0x7b60df5ad513 - rustc_interface[a9a02922dc001c32]::interface::run_compiler::<(), rustc_driver_impl[238e9adc12ab3263]::run_compiler::{closure#0}>::{closure#1}
  35:     0x7b60df4a7235 - std[57730b54ef401f3]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[a9a02922dc001c32]::util::run_in_thread_with_globals<rustc_interface[a9a02922dc001c32]::util::run_in_thread_pool_with_globals<rustc_interface[a9a02922dc001c32]::interface::run_compiler<(), rustc_driver_impl[238e9adc12ab3263]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  36:     0x7b60df4a6f19 - <<std[57730b54ef401f3]::thread::Builder>::spawn_unchecked_<rustc_interface[a9a02922dc001c32]::util::run_in_thread_with_globals<rustc_interface[a9a02922dc001c32]::util::run_in_thread_pool_with_globals<rustc_interface[a9a02922dc001c32]::interface::run_compiler<(), rustc_driver_impl[238e9adc12ab3263]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[bef17dfe197dbeb2]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  37:     0x7b60df4a66af - std::sys::pal::unix::thread::Thread::new::thread_start::h58ab2ce80d2171c1
  38:     0x7b60d98a339d - <unknown>
  39:     0x7b60d992849c - <unknown>
  40:                0x0 - <unknown>

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: rustc 1.86.0-nightly (203e6c127 2025-01-25) 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 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors; 1 warning emitted

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

@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 Jan 25, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 25, 2025
@matthiaskrgr
Copy link
Member Author

#![feature(generic_const_exprs)]
trait A<const B: u8 = X> {}
impl A<1> for bool {}
fn bar(arg : &dyn A<x>) { bar(true) }
pub fn main() {}

bisects to #135971

@matthiaskrgr matthiaskrgr added the F-generic_const_exprs `#![feature(generic_const_exprs)]` label Jan 25, 2025
@fmease fmease added A-dyn-trait Area: trait objects, vtable layout and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jan 26, 2025
@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-dyn-trait Area: trait objects, vtable layout 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) ❄️ 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

3 participants