Skip to content

ICE: mgca: can't type-check body of DefId #16691

@matthiaskrgr

Description

@matthiaskrgr

Summary

#![feature(min_generic_const_args)]
trait Trait {
    type const N: usize;
    fn process(&self, _: [u8; Self::N]) -> [u8; Self::N];
}
impl Trait for u8 {
    type const N: usize = 2;
    fn process(&self, [x, y]: [u8; Self::N]) -> [u8; Self::N] {
        [x, y]
    }
}
impl<const N: usize> Trait for [u8; N] {
    type const N: usize = N;
    fn process(&self, other: [u8; N]) -> [u8; N] {
        let result = [0; _];
        for i in 0..Self::N {}
        result
    }
}
fn main() {}

Version

rustc 1.96.0-nightly (e370b60cf 2026-03-07)
binary: rustc
commit-hash: e370b60cf2b0d3e4b55923ec1558c5b5f8970cfb
commit-date: 2026-03-07
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.0

Error output

Backtrace

warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
--> code.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

warning: anonymous parameters are deprecated and will be removed in the next edition
--> code.rs:4:23
|
4 |     fn process(&self, [u8; Self::N]) -> [u8; Self::N];
|                       ^^^^^^^^^^^^^ help: try naming the parameter or explicitly ignoring it: `_: [u8; Self::N]`
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2018/trait-fn-parameters.html>
= note: `#[warn(anonymous_parameters)]` (part of `#[warn(rust_2018_compatibility)]`) on by default

warning: unused variable: `other`
--> code.rs:14:23
 |
14 |     fn process(&self, other: [u8; N]) -> [u8; N] {
 |                       ^^^^^ help: if this is intentional, prefix it with an underscore: `_other`
 |
 = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default

warning: unused variable: `i`
--> code.rs:16:13
 |
16 |         for i in 0..Self::N {}
 |             ^ help: if this is intentional, prefix it with an underscore: `_i`

warning: trait `Trait` is never used
--> code.rs:2:7
|
2 | trait Trait {
|       ^^^^^
|
= note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

error: internal compiler error: /rustc-dev/e370b60cf2b0d3e4b55923ec1558c5b5f8970cfb/compiler/rustc_hir_typeck/src/lib.rs:120:9: can't type-check body of DefId(0:11 ~ code[fab7]::{impl#1}::N#1)
--> code.rs:13:5
 |
13 |     type const N: usize = N;
 |     ^^^^^^^^^^^^^^^^^^^


thread 'rustc' (134872) panicked at /rustc-dev/e370b60cf2b0d3e4b55923ec1558c5b5f8970cfb/compiler/rustc_hir_typeck/src/lib.rs:120:9:
Box<dyn Any>
stack backtrace:
 0:     0x7fe8fa35b86b - <<std[92ef11c3f66f728e]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[1078981a1131c02b]::fmt::Display>::fmt
 1:     0x7fe8faa204c8 - core[1078981a1131c02b]::fmt::write
 2:     0x7fe8fa372876 - <std[92ef11c3f66f728e]::sys::stdio::unix::Stderr as std[92ef11c3f66f728e]::io::Write>::write_fmt
 3:     0x7fe8fa331958 - std[92ef11c3f66f728e]::panicking::default_hook::{closure#0}
 4:     0x7fe8fa34ece3 - std[92ef11c3f66f728e]::panicking::default_hook
 5:     0x7fe8f9340e0c - std[92ef11c3f66f728e]::panicking::update_hook::<alloc[d9c42a2929f4f6e]::boxed::Box<rustc_driver_impl[a6f36c6b22ba11cd]::install_ice_hook::{closure#1}>>::{closure#0}
 6:     0x7fe8fa34efc2 - std[92ef11c3f66f728e]::panicking::panic_with_hook
 7:     0x7fe8f9371631 - std[92ef11c3f66f728e]::panicking::begin_panic::<rustc_errors[50bfb750f4f7ce2f]::ExplicitBug>::{closure#0}
 8:     0x7fe8f936a316 - std[92ef11c3f66f728e]::sys::backtrace::__rust_end_short_backtrace::<std[92ef11c3f66f728e]::panicking::begin_panic<rustc_errors[50bfb750f4f7ce2f]::ExplicitBug>::{closure#0}, !>
 9:     0x7fe8f936a07b - std[92ef11c3f66f728e]::panicking::begin_panic::<rustc_errors[50bfb750f4f7ce2f]::ExplicitBug>
10:     0x7fe8f937cc81 - <rustc_errors[50bfb750f4f7ce2f]::diagnostic::BugAbort as rustc_errors[50bfb750f4f7ce2f]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
11:     0x7fe8f9931b9c - <rustc_errors[50bfb750f4f7ce2f]::DiagCtxtHandle>::span_bug::<rustc_span[4b139d490b30f989]::span_encoding::Span, alloc[d9c42a2929f4f6e]::string::String>
12:     0x7fe8f9959136 - rustc_middle[98005fe3d9eab612]::util::bug::opt_span_bug_fmt::<rustc_span[4b139d490b30f989]::span_encoding::Span>::{closure#0}
13:     0x7fe8f99592e2 - rustc_middle[98005fe3d9eab612]::ty::context::tls::with_opt::<rustc_middle[98005fe3d9eab612]::util::bug::opt_span_bug_fmt<rustc_span[4b139d490b30f989]::span_encoding::Span>::{closure#0}, !>::{closure#0}
14:     0x7fe8f9949f8b - rustc_middle[98005fe3d9eab612]::ty::context::tls::with_context_opt::<rustc_middle[98005fe3d9eab612]::ty::context::tls::with_opt<rustc_middle[98005fe3d9eab612]::util::bug::opt_span_bug_fmt<rustc_span[4b139d490b30f989]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
15:     0x7fe8f7b25238 - rustc_middle[98005fe3d9eab612]::util::bug::span_bug_fmt::<rustc_span[4b139d490b30f989]::span_encoding::Span>
16:     0x7fe8f7e219bb - rustc_hir_typeck[c0439e63c0b286b6]::typeck_with_inspect::{closure#0}::{closure#0}
17:     0x7fe8fb7af354 - rustc_hir_typeck[c0439e63c0b286b6]::typeck_with_inspect::{closure#0}
18:     0x7fe8fb7a9bf2 - rustc_query_impl[5b5448f076d29498]::query_impl::typeck::invoke_provider_fn::__rust_begin_short_backtrace
19:     0x7fe8fab7f6b4 - rustc_query_impl[5b5448f076d29498]::execution::try_execute_query::<rustc_data_structures[a22cd8b0fa62f221]::vec_cache::VecCache<rustc_span[4b139d490b30f989]::def_id::LocalDefId, rustc_middle[98005fe3d9eab612]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[98005fe3d9eab612]::dep_graph::graph::DepNodeIndex>, false>
20:     0x7fe8fab7f103 - rustc_query_impl[5b5448f076d29498]::query_impl::typeck::execute_query_non_incr::__rust_end_short_backtrace
21:     0x7fe8fae0d625 - rustc_mir_build[d7ec12acaf97c554]::thir::pattern::check_match::check_match
22:     0x7fe8fae0ca87 - rustc_query_impl[5b5448f076d29498]::query_impl::check_match::invoke_provider_fn::__rust_begin_short_backtrace
23:     0x7fe8fafab748 - rustc_query_impl[5b5448f076d29498]::execution::try_execute_query::<rustc_data_structures[a22cd8b0fa62f221]::vec_cache::VecCache<rustc_span[4b139d490b30f989]::def_id::LocalDefId, rustc_middle[98005fe3d9eab612]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[98005fe3d9eab612]::dep_graph::graph::DepNodeIndex>, false>
24:     0x7fe8fafab40e - rustc_query_impl[5b5448f076d29498]::query_impl::check_match::execute_query_non_incr::__rust_end_short_backtrace
25:     0x7fe8fb59890a - rustc_mir_build[d7ec12acaf97c554]::builder::build_mir_inner_impl
26:     0x7fe8faa0b56a - rustc_mir_transform[68b849d5d490c165]::mir_built
27:     0x7fe8fab7f6b4 - rustc_query_impl[5b5448f076d29498]::execution::try_execute_query::<rustc_data_structures[a22cd8b0fa62f221]::vec_cache::VecCache<rustc_span[4b139d490b30f989]::def_id::LocalDefId, rustc_middle[98005fe3d9eab612]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[98005fe3d9eab612]::dep_graph::graph::DepNodeIndex>, false>
28:     0x7fe8fab7f1c3 - rustc_query_impl[5b5448f076d29498]::query_impl::mir_built::execute_query_non_incr::__rust_end_short_backtrace
29:     0x7fe8facd8f43 - rustc_query_impl[5b5448f076d29498]::query_impl::trivial_const::invoke_provider_fn::__rust_begin_short_backtrace
30:     0x7fe8facd8415 - rustc_query_impl[5b5448f076d29498]::execution::try_execute_query::<rustc_middle[98005fe3d9eab612]::query::caches::DefIdCache<rustc_middle[98005fe3d9eab612]::query::erase::ErasedData<[u8; 32usize]>>, false>
31:     0x7fe8facd7a50 - rustc_query_impl[5b5448f076d29498]::query_impl::trivial_const::execute_query_non_incr::__rust_end_short_backtrace
32:     0x7fe8fb069ada - rustc_const_eval[f64d1caae8237491]::const_eval::eval_queries::eval_to_const_value_raw_provider
33:     0x7fe8fb069816 - rustc_query_impl[5b5448f076d29498]::query_impl::eval_to_const_value_raw::invoke_provider_fn::__rust_begin_short_backtrace
34:     0x7fe8fb0685fe - rustc_query_impl[5b5448f076d29498]::execution::try_execute_query::<rustc_middle[98005fe3d9eab612]::query::caches::DefaultCache<rustc_middle[98005fe3d9eab612]::ty::PseudoCanonicalInput<rustc_middle[98005fe3d9eab612]::mir::interpret::GlobalId>, rustc_middle[98005fe3d9eab612]::query::erase::ErasedData<[u8; 24usize]>>, false>
35:     0x7fe8fb06817f - rustc_query_impl[5b5448f076d29498]::query_impl::eval_to_const_value_raw::execute_query_non_incr::__rust_end_short_backtrace
36:     0x7fe8fb5ff4a9 - <rustc_middle[98005fe3d9eab612]::ty::context::TyCtxt>::const_eval_resolve
37:     0x5597f1ee5d52 - <clippy_utils[a257c9b1569fa654]::consts::ConstEvalCtxt>::qpath
38:     0x5597f1dc85fe - <clippy_lints[42bdea7d1400a731]::ranges::Ranges as rustc_lint[2be3f3ab913f870d]::passes::LateLintPass>::check_expr
39:     0x7fe8f982b8c0 - <rustc_lint[2be3f3ab913f870d]::late::LateContextAndPass<rustc_lint[2be3f3ab913f870d]::late::RuntimeCombinedLateLintPass> as rustc_hir[29a2a15b7f6dbd65]::intravisit::Visitor>::visit_expr::{closure#0}::{closure#0}
40:     0x7fe8f98a7c14 - <rustc_lint[2be3f3ab913f870d]::late::LateContextAndPass<rustc_lint[2be3f3ab913f870d]::late::RuntimeCombinedLateLintPass> as rustc_hir[29a2a15b7f6dbd65]::intravisit::Visitor>::visit_expr
41:     0x7fe8f982bc06 - <rustc_lint[2be3f3ab913f870d]::late::LateContextAndPass<rustc_lint[2be3f3ab913f870d]::late::RuntimeCombinedLateLintPass> as rustc_hir[29a2a15b7f6dbd65]::intravisit::Visitor>::visit_expr::{closure#0}::{closure#0}
42:     0x7fe8f98a7c14 - <rustc_lint[2be3f3ab913f870d]::late::LateContextAndPass<rustc_lint[2be3f3ab913f870d]::late::RuntimeCombinedLateLintPass> as rustc_hir[29a2a15b7f6dbd65]::intravisit::Visitor>::visit_expr
43:     0x7fe8f982bd25 - <rustc_lint[2be3f3ab913f870d]::late::LateContextAndPass<rustc_lint[2be3f3ab913f870d]::late::RuntimeCombinedLateLintPass> as rustc_hir[29a2a15b7f6dbd65]::intravisit::Visitor>::visit_expr::{closure#0}::{closure#0}
44:     0x7fe8f98a7c14 - <rustc_lint[2be3f3ab913f870d]::late::LateContextAndPass<rustc_lint[2be3f3ab913f870d]::late::RuntimeCombinedLateLintPass> as rustc_hir[29a2a15b7f6dbd65]::intravisit::Visitor>::visit_expr
45:     0x7fe8f982ba97 - <rustc_lint[2be3f3ab913f870d]::late::LateContextAndPass<rustc_lint[2be3f3ab913f870d]::late::RuntimeCombinedLateLintPass> as rustc_hir[29a2a15b7f6dbd65]::intravisit::Visitor>::visit_expr::{closure#0}::{closure#0}
46:     0x7fe8f98a7c14 - <rustc_lint[2be3f3ab913f870d]::late::LateContextAndPass<rustc_lint[2be3f3ab913f870d]::late::RuntimeCombinedLateLintPass> as rustc_hir[29a2a15b7f6dbd65]::intravisit::Visitor>::visit_expr
47:     0x7fe8f98a7dd9 - <rustc_lint[2be3f3ab913f870d]::late::LateContextAndPass<rustc_lint[2be3f3ab913f870d]::late::RuntimeCombinedLateLintPass> as rustc_hir[29a2a15b7f6dbd65]::intravisit::Visitor>::visit_block
48:     0x7fe8f982bd0c - <rustc_lint[2be3f3ab913f870d]::late::LateContextAndPass<rustc_lint[2be3f3ab913f870d]::late::RuntimeCombinedLateLintPass> as rustc_hir[29a2a15b7f6dbd65]::intravisit::Visitor>::visit_expr::{closure#0}::{closure#0}
49:     0x7fe8f98a7c14 - <rustc_lint[2be3f3ab913f870d]::late::LateContextAndPass<rustc_lint[2be3f3ab913f870d]::late::RuntimeCombinedLateLintPass> as rustc_hir[29a2a15b7f6dbd65]::intravisit::Visitor>::visit_expr
50:     0x7fe8f98a83f1 - <rustc_lint[2be3f3ab913f870d]::late::LateContextAndPass<rustc_lint[2be3f3ab913f870d]::late::RuntimeCombinedLateLintPass> as rustc_hir[29a2a15b7f6dbd65]::intravisit::Visitor>::visit_nested_body
51:     0x7fe8f98a8a2e - <rustc_lint[2be3f3ab913f870d]::late::LateContextAndPass<rustc_lint[2be3f3ab913f870d]::late::RuntimeCombinedLateLintPass> as rustc_hir[29a2a15b7f6dbd65]::intravisit::Visitor>::visit_fn
52:     0x7fe8f98bed44 - <rustc_lint[2be3f3ab913f870d]::late::LateContextAndPass<rustc_lint[2be3f3ab913f870d]::late::RuntimeCombinedLateLintPass> as rustc_hir[29a2a15b7f6dbd65]::intravisit::Visitor>::visit_nested_item
53:     0x7fe8f9849529 - <rustc_lint[2be3f3ab913f870d]::late::LateContextAndPass<rustc_lint[2be3f3ab913f870d]::late::RuntimeCombinedLateLintPass>>::process_mod
54:     0x7fe8fb9cf1b7 - rustc_lint[2be3f3ab913f870d]::late::check_crate::{closure#0}
55:     0x7fe8fb9ce4bf - rustc_lint[2be3f3ab913f870d]::late::check_crate
56:     0x7fe8fb9cb836 - rustc_interface[fed58bb9f00253d1]::passes::analysis::{closure#0}::{closure#0}::{closure#2}
57:     0x7fe8fb9cb617 - rustc_data_structures[a22cd8b0fa62f221]::sync::parallel::par_fns
58:     0x7fe8fb9cb5a6 - rustc_interface[fed58bb9f00253d1]::passes::analysis::{closure#0}::{closure#0}
59:     0x7fe8fb9cb617 - rustc_data_structures[a22cd8b0fa62f221]::sync::parallel::par_fns
60:     0x7fe8fab7c335 - rustc_interface[fed58bb9f00253d1]::passes::analysis
61:     0x7fe8fbcb5f48 - rustc_query_impl[5b5448f076d29498]::execution::try_execute_query::<rustc_middle[98005fe3d9eab612]::query::caches::SingleCache<rustc_middle[98005fe3d9eab612]::query::erase::ErasedData<[u8; 0usize]>>, false>
62:     0x7fe8fbcb5cb3 - rustc_query_impl[5b5448f076d29498]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
63:     0x7fe8fbc6f308 - rustc_interface[fed58bb9f00253d1]::interface::run_compiler::<(), rustc_driver_impl[a6f36c6b22ba11cd]::run_compiler::{closure#0}>::{closure#1}
64:     0x7fe8fbc9873e - std[92ef11c3f66f728e]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[fed58bb9f00253d1]::util::run_in_thread_with_globals<rustc_interface[fed58bb9f00253d1]::util::run_in_thread_pool_with_globals<rustc_interface[fed58bb9f00253d1]::interface::run_compiler<(), rustc_driver_impl[a6f36c6b22ba11cd]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
65:     0x7fe8fbc98fe0 - <std[92ef11c3f66f728e]::thread::lifecycle::spawn_unchecked<rustc_interface[fed58bb9f00253d1]::util::run_in_thread_with_globals<rustc_interface[fed58bb9f00253d1]::util::run_in_thread_pool_with_globals<rustc_interface[fed58bb9f00253d1]::interface::run_compiler<(), rustc_driver_impl[a6f36c6b22ba11cd]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[1078981a1131c02b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
66:     0x7fe8fbc99e6c - <std[92ef11c3f66f728e]::sys::thread::unix::Thread>::new::thread_start
67:     0x7fe8f56a598b - <unknown>
68:     0x7fe8f5729a0c - <unknown>
69:                0x0 - <unknown>

note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new?template=ice.yml

note: please make sure that you have updated to the latest nightly

note: please attach the file at `/home/matthias/vcs/github/CRED/rustc-ice-2026-03-08T09_16_39-134855.txt` to your bug report

note: rustc 1.96.0-nightly (e370b60cf 2026-03-07) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `<impl at code.rs:12:1: 12:39>::N`
#1 [check_match] match-checking `<impl at code.rs:12:1: 12:39>::N`
#2 [mir_built] building MIR for `<impl at code.rs:12:1: 12:39>::N`
#3 [trivial_const] checking if `<impl at code.rs:12:1: 12:39>::N` is a trivial const
#4 [eval_to_const_value_raw] simplifying constant for the type system `<impl at code.rs:12:1: 12:39>::N`
#5 [analysis] running analysis passes on crate `code`
end of query stack
note: Clippy version: clippy 0.1.96 (e370b60cf2 2026-03-07)

error: aborting due to 1 previous error; 5 warnings emitted

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-ICEIssue: Clippy panicked, giving an Internal Compilation Error (ICE) ❄️

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions