Skip to content
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

delayed bug: Missing value for constant, but no error reported? #128512

Open
SparkyPotato opened this issue Aug 1, 2024 · 1 comment
Open

delayed bug: Missing value for constant, but no error reported? #128512

SparkyPotato opened this issue Aug 1, 2024 · 1 comment
Labels
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) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@SparkyPotato
Copy link
Contributor

Code

#![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.

Meta

rustc --version --verbose:

rustc 1.82.0-nightly (28a58f2fa 2024-07-31)
binary: rustc
commit-hash: 28a58f2fa7f0c46b8fab8237c02471a915924fe5
commit-date: 2024-07-31
host: x86_64-pc-windows-msvc
release: 1.82.0-nightly
LLVM version: 19.1.0

Error output

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: <rustc_errors::DiagCtxtHandle>::steal_fulfilled_expectation_ids
   5: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
   6: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   7: <rustc_const_eval::errors::WriteThroughImmutablePointer as rustc_errors::diagnostic::LintDiagnostic<()>>::decorate_lint
   8: rustc_trait_selection::traits::const_evaluatable::is_const_evaluatable
   9: <rustc_trait_selection::traits::select::SelectionContext>::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: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation_no_overflow
  15: <rustc_infer::infer::InferCtxt as rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt>::predicate_may_hold
  16: <rustc_codegen_llvm::builder::Builder as rustc_codegen_ssa::traits::builder::BuilderMethods>::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: <<rustc_hir_typeck::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  21: <<rustc_hir_typeck::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  22: <<rustc_hir_typeck::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  23: <<rustc_hir_typeck::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  24: <<rustc_hir_typeck::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  25: <<rustc_hir_typeck::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  26: <<rustc_hir_typeck::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  27: <<rustc_hir_typeck::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  28: rustc_hir_typeck::typeck
  29: <<rustc_hir_typeck::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  30: <<rustc_hir_typeck::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  31: <<rustc_hir_typeck::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  32: rustc_hir_typeck::typeck
  33: <<rustc_hir_typeck::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  34: <<rustc_hir_typeck::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  35: <<rustc_hir_typeck::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  36: <<rustc_hir_typeck::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  37: <<rustc_hir_typeck::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  38: <<rustc_hir_typeck::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  39: <<rustc_hir_typeck::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  40: <<rustc_hir_typeck::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  41: <<rustc_hir_typeck::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::visit_ty
  42: <<rustc_hir_typeck::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir::visit::TypeVisitor<rustc_middle::ty::context::TyCtxt>>::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: <rustc_hir_typeck::upvar::InferBorrowKind as rustc_hir_typeck::expr_use_visitor::Delegate>::borrow
  49: rustc_hir_analysis::check_crate
  50: rustc_interface::passes::analysis
  51: <dyn std::io::Write as nu_ansi_term::write::AnyWrite>::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

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

probably a duplicate of #110378

@jieyouxu jieyouxu added the F-generic_const_exprs `#![feature(generic_const_exprs)]` label Aug 2, 2024
@Noratrieb Noratrieb removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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) ❄️ 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

5 participants