Skip to content

[ICE]: This ought to be unreachable, the entrypoints of WF should still have InherentSelf-form alias consts. #162146

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(inherent_associated_types)]
#![feature(macroless_generic_const_args)]
#![feature(generic_const_args)]
struct Foo<const A: usize, const B: usize>;

impl<const A: usize> Foo<1, A> {
    const SIZE: usize;

    fn to_bytes(&self) -> [u8; Self::SIZE];
} // ok

original:

//@ check-pass

struct Foo<const A: usize, const B: usize>;

impl<const A: usize> Foo<1, A> {
    const SIZE: usize;

    fn to_bytes(&self) -> [u8; Self::SIZE];
} // ok

fn main() {}

Version information

rustc 1.100.0-nightly (a4330234a 2026-09-01)
binary: rustc
commit-hash: a4330234a776684c36428d001721d0320d24dd77
commit-date: 2026-09-01
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.0

Possibly related line of code:

match alias_const.kind {
ty::AliasConstKind::InherentSelf { .. } => {
self.add_wf_preds_for_inherent_projection(alias_const.into());
return; // Subtree is handled by above function
}
// please ping khyperia and/or BoxyUwU if this `bug!` fires
ty::AliasConstKind::InherentImpl { .. } => bug!(
"This ought to be unreachable, the entrypoints of WF should still have InherentSelf-form alias consts."
),
ty::AliasConstKind::Projection { def_id }
| ty::AliasConstKind::Free { def_id }
| ty::AliasConstKind::Anon { def_id } => {
self.nominal_obligations(

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

Program output

error: associated constant in `impl` without body
 --> /tmp/icemaker_global_tempdir.c0PRprlesLQf/rustc_testrunner_tmpdir_reporting.TIx9DK3gKKQA/mvce.rs:4:5
  |
4 |     const SIZE: usize;
  |     ^^^^^^^^^^^^^^^^^-
  |                      |
  |                      help: provide a definition for the constant: `= <expr>;`

error: associated function in `impl` without body
 --> /tmp/icemaker_global_tempdir.c0PRprlesLQf/rustc_testrunner_tmpdir_reporting.TIx9DK3gKKQA/mvce.rs:6:5
  |
6 |     fn to_bytes(&self) -> [u8; Self::SIZE];
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
  |                                           |
  |                                           help: provide a definition for the function: `{ <body> }`

error: `generic_const_args` requires `min_generic_const_args` to be enabled
 --> <crate attribute>:1:12
  |
1 | #![feature(generic_const_args)]
  |            ^^^^^^^^^^^^^^^^^^
  |
  = help: enable all of these features

error: `macroless_generic_const_args` requires `min_generic_const_args` to be enabled
 --> <crate attribute>:1:12
  |
1 | #![feature(macroless_generic_const_args)]
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: enable all of these features

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

warning: the feature `macroless_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
 --> <crate attribute>:1:12
  |
1 | #![feature(macroless_generic_const_args)]
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #159006 <https://github.com/rust-lang/rust/issues/159006> for more information

warning: the feature `generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
 --> <crate attribute>:1:12
  |
1 | #![feature(generic_const_args)]
  |            ^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #151972 <https://github.com/rust-lang/rust/issues/151972> for more information

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.c0PRprlesLQf/rustc_testrunner_tmpdir_reporting.TIx9DK3gKKQA/mvce.rs:7:2
  |
7 | } // ok
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.c0PRprlesLQf/rustc_testrunner_tmpdir_reporting.TIx9DK3gKKQA/mvce.rs`

error: internal compiler error: /rustc-dev/a4330234a776684c36428d001721d0320d24dd77/compiler/rustc_trait_selection/src/traits/wf.rs:1103:68: This ought to be unreachable, the entrypoints of WF should still have InherentSelf-form alias consts.


thread 'rustc' (3760825) panicked at /rustc-dev/a4330234a776684c36428d001721d0320d24dd77/compiler/rustc_trait_selection/src/traits/wf.rs:1103:68:
Box<dyn Any>
stack backtrace:
   0:     0x7fe00ca87576 - <<std[30cbc90d73eb2f7]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[37d23c544a63de81]::fmt::Display>::fmt
   1:     0x7fe00d01138f - core[37d23c544a63de81]::fmt::write
   2:     0x7fe00ca9c64c - <std[30cbc90d73eb2f7]::sys::stdio::unix::Stderr as core[37d23c544a63de81]::io::write::Write>::write_fmt
   3:     0x7fe00ca59e4a - std[30cbc90d73eb2f7]::panicking::default_hook::{closure#0}
   4:     0x7fe00ca7b8a3 - std[30cbc90d73eb2f7]::panicking::default_hook
   5:     0x7fe00b9f1d8f - std[30cbc90d73eb2f7]::panicking::update_hook::<alloc[1ae459ecdd033a44]::boxed::Box<rustc_driver_impl[42633c3e3ce72fef]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fe00ca7bd42 - std[30cbc90d73eb2f7]::panicking::panic_with_hook
   7:     0x7fe00ba20324 - std[30cbc90d73eb2f7]::panicking::begin_panic::<rustc_errors[9274a714df388628]::ExplicitBug>::{closure#0}
   8:     0x7fe00ba190d6 - std[30cbc90d73eb2f7]::sys::backtrace::__rust_end_short_backtrace::<std[30cbc90d73eb2f7]::panicking::begin_panic<rustc_errors[9274a714df388628]::ExplicitBug>::{closure#0}, !>
   9:     0x7fe00ba18e0b - std[30cbc90d73eb2f7]::panicking::begin_panic::<rustc_errors[9274a714df388628]::ExplicitBug>
  10:     0x7fe00ba2bd71 - <rustc_errors[9274a714df388628]::diagnostic::BugAbort as rustc_errors[9274a714df388628]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7fe00bfb8d59 - rustc_middle[a86b7b2986aebea0]::util::bug::opt_span_bug_fmt::<rustc_span[b1cb78db3bb7e75b]::span_encoding::Span>::{closure#0}
  12:     0x7fe00bfb9152 - rustc_middle[a86b7b2986aebea0]::ty::context::tls::with_opt::<rustc_middle[a86b7b2986aebea0]::util::bug::opt_span_bug_fmt<rustc_span[b1cb78db3bb7e75b]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7fe00bfa3f70 - rustc_middle[a86b7b2986aebea0]::ty::context::tls::with_context_opt::<rustc_middle[a86b7b2986aebea0]::ty::context::tls::with_opt<rustc_middle[a86b7b2986aebea0]::util::bug::opt_span_bug_fmt<rustc_span[b1cb78db3bb7e75b]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7fe008c1e6f4 - rustc_middle[a86b7b2986aebea0]::util::bug::bug_fmt
  15:     0x7fe00d2bba3b - <rustc_trait_selection[dd61d12ef2e98b62]::traits::wf::WfPredicates as rustc_type_ir[740cb680109dbe18]::visit::TypeVisitor<rustc_middle[a86b7b2986aebea0]::ty::context::TyCtxt>>::visit_const
  16:     0x7fe00d2b3b83 - <rustc_trait_selection[dd61d12ef2e98b62]::traits::wf::WfPredicates as rustc_type_ir[740cb680109dbe18]::visit::TypeVisitor<rustc_middle[a86b7b2986aebea0]::ty::context::TyCtxt>>::visit_ty
  17:     0x7fe00de2ba1e - <rustc_next_trait_solver[1853f23884fbb7e4]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[dd61d12ef2e98b62]::solve::delegate::SolverDelegate, rustc_middle[a86b7b2986aebea0]::ty::context::TyCtxt>>::evaluate_goal_no_fast_paths
  18:     0x7fe00de2116c - <rustc_trait_selection[dd61d12ef2e98b62]::traits::engine::ObligationCtxt<rustc_trait_selection[dd61d12ef2e98b62]::traits::FulfillmentError>>::evaluate_obligations_error_on_ambiguity
  19:     0x7fe00d84175a - rustc_hir_analysis[e3348fb73159a1b9]::check::wfcheck::enter_wf_checking_ctxt::<rustc_hir_analysis[e3348fb73159a1b9]::check::wfcheck::check_associated_item::{closure#0}>
  20:     0x7fe00e221a98 - rustc_hir_analysis[e3348fb73159a1b9]::check::check::check_item_type
  21:     0x7fe00e21dff2 - rustc_hir_analysis[e3348fb73159a1b9]::check::wfcheck::check_well_formed
  22:     0x7fe00e21dfd3 - rustc_query_impl[97c88ea65335a4b0]::query_vtables::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
  23:     0x7fe00e21d5fb - rustc_query_impl[97c88ea65335a4b0]::execution::try_execute_query::<rustc_data_structures[2f5d70850e22934]::vec_cache::VecCache<rustc_span[b1cb78db3bb7e75b]::def_id::LocalDefId, rustc_middle[a86b7b2986aebea0]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[a86b7b2986aebea0]::dep_graph::graph::DepNodeIndex>, false>
  24:     0x7fe00e21d395 - rustc_query_impl[97c88ea65335a4b0]::query_vtables::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
  25:     0x7fe00e21a8a7 - rustc_hir_analysis[e3348fb73159a1b9]::check::wfcheck::check_type_wf
  26:     0x7fe00e21a711 - rustc_query_impl[97c88ea65335a4b0]::query_vtables::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
  27:     0x7fe00e2038c9 - rustc_query_impl[97c88ea65335a4b0]::execution::try_execute_query::<rustc_middle[a86b7b2986aebea0]::query::caches::SingleCache<rustc_middle[a86b7b2986aebea0]::query::erase::ErasedData<[u8; 1usize]>>, false>
  28:     0x7fe00e2036ad - rustc_query_impl[97c88ea65335a4b0]::query_vtables::check_type_wf::execute_query_non_incr::__rust_end_short_backtrace
  29:     0x7fe00d827fa4 - rustc_hir_analysis[e3348fb73159a1b9]::check_crate
  30:     0x7fe00dd8003c - rustc_interface[a3585332d3a3ff1e]::passes::analysis
  31:     0x7fe00e2051ca - rustc_query_impl[97c88ea65335a4b0]::execution::try_execute_query::<rustc_middle[a86b7b2986aebea0]::query::caches::SingleCache<rustc_middle[a86b7b2986aebea0]::query::erase::ErasedData<[u8; 0usize]>>, false>
  32:     0x7fe00e204f6b - rustc_query_impl[97c88ea65335a4b0]::query_vtables::analysis::execute_query_non_incr::__rust_end_short_backtrace
  33:     0x7fe00e35a659 - rustc_interface[a3585332d3a3ff1e]::interface::run_compiler::<(), rustc_driver_impl[42633c3e3ce72fef]::run_compiler::{closure#0}>::{closure#2}
  34:     0x7fe00e3ad7c2 - std[30cbc90d73eb2f7]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[a3585332d3a3ff1e]::util::run_in_thread_with_globals<rustc_interface[a3585332d3a3ff1e]::util::run_in_thread_pool_with_globals<rustc_interface[a3585332d3a3ff1e]::interface::run_compiler<(), rustc_driver_impl[42633c3e3ce72fef]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  35:     0x7fe00e3ad56d - <std[30cbc90d73eb2f7]::thread::lifecycle::spawn_unchecked<rustc_interface[a3585332d3a3ff1e]::util::run_in_thread_with_globals<rustc_interface[a3585332d3a3ff1e]::util::run_in_thread_pool_with_globals<rustc_interface[a3585332d3a3ff1e]::interface::run_compiler<(), rustc_driver_impl[42633c3e3ce72fef]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[37d23c544a63de81]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  36:     0x7fe00e3b5ec7 - <std[30cbc90d73eb2f7]::sys::thread::unix::Thread>::new::thread_start
  37:     0x7fe0076980a2 - <unknown>
  38:     0x7fe00772080c - <unknown>
  39:                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.100.0-nightly (a4330234a 2026-09-01) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z crate-attr=feature(inherent_associated_types) -Z crate-attr=feature(macroless_generic_const_args) -Z crate-attr=feature(generic_const_args) -Z dump-mir-dir=dir

query stack during panic:
#0 [check_well_formed] checking that `<impl at /tmp/icemaker_global_tempdir.c0PRprlesLQf/rustc_testrunner_tmpdir_reporting.TIx9DK3gKKQA/mvce.rs:3:1: 3:31>::to_bytes` is well-formed
#1 [check_type_wf] checking that types are well-formed
#2 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 6 previous errors; 3 warnings emitted

For more information about this error, try `rustc --explain E0601`.

@rustbot label +F-inherent_associated_types +F-macroless_generic_const_args +F-generic_const_args

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-generic_const_args`#![feature(generic_const_args)]`F-inherent_associated_types`#![feature(inherent_associated_types)]`F-min_generic_const_args`#![feature(min_generic_const_args)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-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