#![feature(generic_const_exprs)]
trait NodeIndex: Copy {}
struct Interface<'a, T: NodeIndex> {
borrow: &'a (),
_phantom: std::marker::PhantomData<fn() -> T>,
}
trait Component: 'static {
type NodeIndex: NodeIndex;
fn exec(&mut self, nodes: Interface<'_, Self::NodeIndex>);
}
trait SimpleComponent: 'static {
const NODES: usize;
fn exec(&mut self, input: [f32; Self::NODES]) -> [f32; Self::NODES];
}
#[derive(Copy, Clone)]
struct Node<const NODES: usize>(u8);
impl<const NODES: usize> NodeIndex for Node<NODES> {}
impl<T: SimpleComponent> Component for T
where
[(); T::NODES]:, // This where bound causes the ICE
{
type NodeIndex = Node<{T::NODES}>;
fn exec(&mut self, nodes: Interface<'_, Self::NodeIndex>) { /* ICEs even if the function is empty */ }
}
The above code doesn't reproduce the error, but has a similar structure to what causes the ICE in a larger codebase. Even in the codebase where it ICEs, creating a trait with the exact same definition (call it ComponentCopy), and then replacing the impl Component for T with:
- impl<T: SimpleComponent> Component for T where [(); T::NODES]: { ... }
+ impl<T: SimpleComponent> ComponentCopy for T where [(); T::NODES]: { /* same as above */ }
+ impl<T: ComponentCopy> Component for T { /* forward the assoc. type and method */ }
doesn't cause the ICE anymore.
There isn't even a span attached to the delayed error.
note: no errors encountered even though delayed bugs were created
note: those delayed bugs will now be shown as internal compiler errors
error: internal compiler error: Missing value for constant, but no error reported?
|
= note: delayed at compiler\rustc_trait_selection\src\traits\const_evaluatable.rs:74:68
Backtrace
```
delayed bug: Missing value for constant, but no error reported?
0: std::backtrace_rs::backtrace::dbghelp64::trace
at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
1: std::backtrace_rs::backtrace::trace_unsynchronized
at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
2: std::backtrace::Backtrace::create
at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library\std\src\backtrace.rs:331
3: std::backtrace::Backtrace::capture
at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library\std\src\backtrace.rs:296
4: ::steal_fulfilled_expectation_ids
5: ::emit_diagnostic
6: ::emit_producing_guarantee
7: >::decorate_lint
8: rustc_trait_selection::traits::const_evaluatable::is_const_evaluatable
9: ::evaluate_root_obligation
10: rustc_traits::evaluate_obligation::evaluate_obligation
11: rustc_query_impl::plumbing::query_key_hash_verify_all
12: rustc_ty_utils::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
13: rustc_query_impl::plumbing::query_key_hash_verify_all
14: ::evaluate_obligation_no_overflow
15: ::predicate_may_hold
16: ::load_operand
17: rustc_hir_typeck::method::probe::method_autoderef_steps
18: rustc_hir_typeck::method::probe::method_autoderef_steps
19: rustc_hir_typeck::typeck
20: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
21: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
22: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
23: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
24: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
25: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
26: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
27: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
28: rustc_hir_typeck::typeck
29: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
30: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
31: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
32: rustc_hir_typeck::typeck
33: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
34: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
35: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
36: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
37: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
38: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
39: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
40: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
41: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
42: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
43: rustc_hir_typeck::typeck
44: rustc_hir_typeck::typeck
45: rustc_query_impl::plumbing::query_key_hash_verify_all
46: rustc_ty_utils::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
47: rustc_query_impl::plumbing::query_key_hash_verify_all
48: ::borrow
49: rustc_hir_analysis::check_crate
50: rustc_interface::passes::analysis
51: ::write_str
52: rustc_ty_utils::ty::adt_sized_constraint
53: rustc_query_impl::query_system
54: _wpgmptr
55: _wpgmptr
56: _wpgmptr
57: alloc::boxed::impl$48::call_once
at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library\alloc\src\boxed.rs:2148
58: alloc::boxed::impl$48::call_once
at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library\alloc\src\boxed.rs:2148
59: std::sys::pal::windows::thread::impl$0::new::thread_start
at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library\std\src\sys\pal\windows\thread.rs:55
60: BaseThreadInitThunk
61: RtlUserThreadStart
rustc version: 1.82.0-nightly (28a58f2fa 2024-07-31)
platform: x86_64-pc-windows-msvc
```
Code
The above code doesn't reproduce the error, but has a similar structure to what causes the ICE in a larger codebase. Even in the codebase where it ICEs, creating a trait with the exact same definition (call it
ComponentCopy
), and then replacing theimpl Component for T
with:doesn't cause the ICE anymore.
There isn't even a span attached to the delayed error.
Meta
rustc --version --verbose
:Error output
Backtrace
``` delayed bug: Missing value for constant, but no error reported? 0: std::backtrace_rs::backtrace::dbghelp64::trace at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91 1: std::backtrace_rs::backtrace::trace_unsynchronized at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66 2: std::backtrace::Backtrace::create at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library\std\src\backtrace.rs:331 3: std::backtrace::Backtrace::capture at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library\std\src\backtrace.rs:296 4:::steal_fulfilled_expectation_ids
5: ::emit_diagnostic
6: ::emit_producing_guarantee
7: >::decorate_lint
8: rustc_trait_selection::traits::const_evaluatable::is_const_evaluatable
9: ::evaluate_root_obligation
10: rustc_traits::evaluate_obligation::evaluate_obligation
11: rustc_query_impl::plumbing::query_key_hash_verify_all
12: rustc_ty_utils::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
13: rustc_query_impl::plumbing::query_key_hash_verify_all
14: ::evaluate_obligation_no_overflow
15: ::predicate_may_hold
16: ::load_operand
17: rustc_hir_typeck::method::probe::method_autoderef_steps
18: rustc_hir_typeck::method::probe::method_autoderef_steps
19: rustc_hir_typeck::typeck
20: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
21: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
22: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
23: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
24: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
25: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
26: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
27: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
28: rustc_hir_typeck::typeck
29: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
30: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
31: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
32: rustc_hir_typeck::typeck
33: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
34: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
35: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
36: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
37: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
38: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
39: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
40: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
41: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
42: <::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor>::visit_ty
43: rustc_hir_typeck::typeck
44: rustc_hir_typeck::typeck
45: rustc_query_impl::plumbing::query_key_hash_verify_all
46: rustc_ty_utils::ty::self_ty_of_trait_impl_enabling_order_dep_trait_object_hack
47: rustc_query_impl::plumbing::query_key_hash_verify_all
48: ::borrow
49: rustc_hir_analysis::check_crate
50: rustc_interface::passes::analysis
51: ::write_str
52: rustc_ty_utils::ty::adt_sized_constraint
53: rustc_query_impl::query_system
54: _wpgmptr
55: _wpgmptr
56: _wpgmptr
57: alloc::boxed::impl$48::call_once
at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library\alloc\src\boxed.rs:2148
58: alloc::boxed::impl$48::call_once
at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library\alloc\src\boxed.rs:2148
59: std::sys::pal::windows::thread::impl$0::new::thread_start
at /rustc/28a58f2fa7f0c46b8fab8237c02471a915924fe5/library\std\src\sys\pal\windows\thread.rs:55
60: BaseThreadInitThunk
61: RtlUserThreadStart
rustc version: 1.82.0-nightly (28a58f2fa 2024-07-31)
platform: x86_64-pc-windows-msvc
```