Skip to content

Rustc crashes at compiler/rustc_middle/src/ty/instance.rs, caused by assertion left matches right failed #136138

Open
@wangbo15

Description

@wangbo15

Code

Note that if we remove the first line #![feature(min_generic_const_args)], the panic disappeares.

#![feature(min_generic_const_args)]
struct U;
struct S<const N: U>()
where
    S<{ U }>:;
fn main() {}

Meta

rustc --version --verbose:

rustc 1.86.0-nightly (f85c6de55 2025-01-26)
binary: rustc
commit-hash: f85c6de55206dbee5ffedfd821df1503a7b92346
commit-date: 2025-01-26
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7

Error output

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


thread 'rustc' panicked at compiler/rustc_middle/src/ty/instance.rs:531:9:
assertion `left matches right` failed: `Instance::try_resolve` should only be used to resolve instances of functions, statics, and consts; to resolve associated types, use `try_normalize_erasing_regions`.
  left: Ctor(Struct, Const)
 right: DefKind::Fn | DefKind::AssocFn | DefKind::Const | DefKind::AssocConst |
DefKind::AnonConst | DefKind::InlineConst | DefKind::Static { .. } |
DefKind::Ctor(_, CtorKind::Fn) | DefKind::Closure |
DefKind::SyntheticCoroutineBody
stack backtrace:
   0:     0x7fa280d3c210 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hec9bc6463e252640
   1:     0x7fa2815acee6 - core::fmt::write::h962cad0079919c7e
   2:     0x7fa2824aac51 - std::io::Write::write_fmt::h081e59591f35f868
   3:     0x7fa280d3c072 - std::sys::backtrace::BacktraceLock::print::he0deffbd85e9a2c5
   4:     0x7fa280d3e4f2 - std::panicking::default_hook::{{closure}}::h99776b3a5456e866
   5:     0x7fa280d3e37a - std::panicking::default_hook::hcad38b9ed4b5517d
   6:     0x7fa27fef3279 - std[cc940dec3ff43b12]::panicking::update_hook::<alloc[5f7a888829935c2b]::boxed::Box<rustc_driver_impl[af2bdb3744899392]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7fa280d3f073 - std::panicking::rust_panic_with_hook::hbfeeff1ab3569ba1
   8:     0x7fa280d3ed6a - std::panicking::begin_panic_handler::{{closure}}::h32c93c4f5d28ab99
   9:     0x7fa280d3c6e9 - std::sys::backtrace::__rust_end_short_backtrace::h1884c239824d44f7
  10:     0x7fa280d3ea2d - rust_begin_unwind
  11:     0x7fa27d9d1bd0 - core::panicking::panic_fmt::he58927c3c03479ba
  12:     0x7fa27f915586 - core::panicking::assert_failed_inner::hfb3c935e17727acd
  13:     0x7fa28049b942 - core[c1de5c9ad145c0db]::panicking::assert_matches_failed::<rustc_hir[2d8a80fbfdaaf69c]::def::DefKind>
  14:     0x7fa2817a1f93 - <rustc_middle[ea35cf57050946b4]::ty::instance::Instance>::try_resolve
  15:     0x7fa282284cf1 - <rustc_middle[ea35cf57050946b4]::ty::context::TyCtxt>::const_eval_resolve_for_typeck
  16:     0x7fa282284a77 - rustc_trait_selection[9f2c8c71993b8584]::traits::try_evaluate_const
  17:     0x7fa282284513 - <rustc_trait_selection[9f2c8c71993b8584]::traits::normalize::AssocTypeNormalizer as rustc_type_ir[de1b3d84f3386c16]::fold::TypeFolder<rustc_middle[ea35cf57050946b4]::ty::context::TyCtxt>>::fold_const
  18:     0x7fa281dd0361 - <rustc_trait_selection[9f2c8c71993b8584]::traits::normalize::AssocTypeNormalizer as rustc_type_ir[de1b3d84f3386c16]::fold::FallibleTypeFolder<rustc_middle[ea35cf57050946b4]::ty::context::TyCtxt>>::try_fold_binder::<rustc_type_ir[de1b3d84f3386c16]::predicate_kind::PredicateKind<rustc_middle[ea35cf57050946b4]::ty::context::TyCtxt>>
  19:     0x7fa2819bcdb8 - rustc_trait_selection[9f2c8c71993b8584]::traits::normalize::normalize_with_depth_to::<rustc_middle[ea35cf57050946b4]::ty::predicate::Predicate>
  20:     0x7fa2819bbb57 - rustc_trait_selection[9f2c8c71993b8584]::traits::wf::clause_obligations
  21:     0x7fa2819c0388 - rustc_hir_analysis[ce12ae6d63b57b8a]::check::wfcheck::check_where_clauses
  22:     0x7fa281bd5e00 - rustc_hir_analysis[ce12ae6d63b57b8a]::check::wfcheck::check_type_defn
  23:     0x7fa281bcf821 - rustc_hir_analysis[ce12ae6d63b57b8a]::check::wfcheck::check_well_formed
  24:     0x7fa281bce247 - rustc_query_impl[52b9445d4dcf70be]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[52b9445d4dcf70be]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ea35cf57050946b4]::query::erase::Erased<[u8; 1usize]>>
  25:     0x7fa281bcdce9 - rustc_query_system[b5c6449b7ccd2566]::query::plumbing::try_execute_query::<rustc_query_impl[52b9445d4dcf70be]::DynamicConfig<rustc_data_structures[aef26e4d10f0fc6d]::vec_cache::VecCache<rustc_span[d5a27b28009c9e0]::def_id::LocalDefId, rustc_middle[ea35cf57050946b4]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[b5c6449b7ccd2566]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[52b9445d4dcf70be]::plumbing::QueryCtxt, false>
  26:     0x7fa281bcd746 - rustc_query_impl[52b9445d4dcf70be]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  27:     0x7fa281bcb36c - rustc_hir_analysis[ce12ae6d63b57b8a]::check::wfcheck::check_mod_type_wf
  28:     0x7fa281bcb18b - rustc_query_impl[52b9445d4dcf70be]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[52b9445d4dcf70be]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ea35cf57050946b4]::query::erase::Erased<[u8; 1usize]>>
  29:     0x7fa2824b2ac8 - rustc_query_system[b5c6449b7ccd2566]::query::plumbing::try_execute_query::<rustc_query_impl[52b9445d4dcf70be]::DynamicConfig<rustc_query_system[b5c6449b7ccd2566]::query::caches::DefaultCache<rustc_span[d5a27b28009c9e0]::def_id::LocalModDefId, rustc_middle[ea35cf57050946b4]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[52b9445d4dcf70be]::plumbing::QueryCtxt, false>
  30:     0x7fa2824b2870 - rustc_query_impl[52b9445d4dcf70be]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  31:     0x7fa2819371e6 - rustc_hir_analysis[ce12ae6d63b57b8a]::check_crate
  32:     0x7fa281933aa2 - rustc_interface[d0d5d02e7a56d74f]::passes::run_required_analyses
  33:     0x7fa2824a635e - rustc_interface[d0d5d02e7a56d74f]::passes::analysis
  34:     0x7fa2824a632f - rustc_query_impl[52b9445d4dcf70be]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[52b9445d4dcf70be]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ea35cf57050946b4]::query::erase::Erased<[u8; 0usize]>>
  35:     0x7fa282493315 - rustc_query_system[b5c6449b7ccd2566]::query::plumbing::try_execute_query::<rustc_query_impl[52b9445d4dcf70be]::DynamicConfig<rustc_query_system[b5c6449b7ccd2566]::query::caches::SingleCache<rustc_middle[ea35cf57050946b4]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[52b9445d4dcf70be]::plumbing::QueryCtxt, false>
  36:     0x7fa28249304e - rustc_query_impl[52b9445d4dcf70be]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  37:     0x7fa2824b9429 - rustc_interface[d0d5d02e7a56d74f]::passes::create_and_enter_global_ctxt::<core[c1de5c9ad145c0db]::option::Option<rustc_interface[d0d5d02e7a56d74f]::queries::Linker>, rustc_driver_impl[af2bdb3744899392]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  38:     0x7fa282504213 - rustc_interface[d0d5d02e7a56d74f]::interface::run_compiler::<(), rustc_driver_impl[af2bdb3744899392]::run_compiler::{closure#0}>::{closure#1}
  39:     0x7fa282400eb5 - std[cc940dec3ff43b12]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[d0d5d02e7a56d74f]::util::run_in_thread_with_globals<rustc_interface[d0d5d02e7a56d74f]::util::run_in_thread_pool_with_globals<rustc_interface[d0d5d02e7a56d74f]::interface::run_compiler<(), rustc_driver_impl[af2bdb3744899392]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  40:     0x7fa282400b99 - <<std[cc940dec3ff43b12]::thread::Builder>::spawn_unchecked_<rustc_interface[d0d5d02e7a56d74f]::util::run_in_thread_with_globals<rustc_interface[d0d5d02e7a56d74f]::util::run_in_thread_pool_with_globals<rustc_interface[d0d5d02e7a56d74f]::interface::run_compiler<(), rustc_driver_impl[af2bdb3744899392]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[c1de5c9ad145c0db]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  41:     0x7fa28240032b - std::sys::pal::unix::thread::Thread::new::thread_start::hb22e947f5885a296
  42:     0x7fa27c756609 - start_thread
                               at /build/glibc-LcI20x/glibc-2.31/nptl/pthread_create.c:477:8
  43:     0x7fa27c67b353 - clone
                               at /build/glibc-LcI20x/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95:0
  44:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.
Backtrace

<backtrace>

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-min_generic_const_args`#![feature(min_generic_const_args)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-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