Skip to content

Compiler crash with extensive use of const generics #126078

Closed as not planned
Closed as not planned
@shosti

Description

@shosti

Code

I'm not sure where to start in terms of a minimal example, but the relevant code is https://github.com/shosti/tensrus/tree/compiler-bug (reproducible with cargo test). The code makes extensive use of adt_const_params and generic_const_exprs.

Meta

rustc --version --verbose:

rustc 1.80.0-nightly (72fdf913c 2024-06-05)
binary: rustc
commit-hash: 72fdf913c53dd0e75313ba83e4aa80df3f6e2871
commit-date: 2024-06-05
host: aarch64-apple-darwin
release: 1.80.0-nightly
LLVM version: 18.1.6

Error output

   Compiling tensrus v0.1.0 (/Users/shosti/src/tensrus)
error: internal compiler error: compiler/rustc_middle/src/ty/instance.rs:510:25: failed to resolve instance for <generic_tensor::GenericTensor<f64, 2, [2, 3, 0, 0, 0, 0]> as Add<view::View<'_, generic_tensor::GenericTensor<f64, 2, [2, 3, 0, 0, 0, 0]>>>>::add: Ok(
                                    None,
                                )

Backtrace

   Compiling tensrus v0.1.0 (/Users/shosti/src/tensrus)
error: internal compiler error: compiler/rustc_middle/src/ty/instance.rs:510:25: failed to resolve instance for <generic_tensor::GenericTensor<f64, 2, [2, 3, 0, 0, 0, 0]> as Add<view::View<'_, generic_tensor::GenericTensor<f64, 2, [2, 3, 0, 0, 0, 0]>>>>::add: Ok(
                                    None,
                                )

thread 'rustc' panicked at compiler/rustc_middle/src/ty/instance.rs:510:25:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   2: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   3: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   5: rustc_middle::util::bug::bug_fmt
   6: <rustc_middle::ty::instance::Instance>::expect_resolve
   7: <rustc_monomorphize::collector::MirUsedCollector as rustc_middle::mir::visit::Visitor>::visit_terminator
   8: rustc_monomorphize::collector::collect_items_of_instance
   9: rustc_monomorphize::collector::collect_items_rec
  10: rustc_monomorphize::collector::collect_items_rec
  11: rustc_monomorphize::collector::collect_items_rec
  12: rustc_monomorphize::collector::collect_items_rec
  13: rustc_monomorphize::collector::collect_items_rec
  14: rustc_monomorphize::collector::collect_items_rec
  15: std::panicking::try::<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::enabled::par_for_each_in<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure#0}>::{closure#0}::{closure#0}::{closure#0}>>
  16: <rustc_data_structures::sync::parallel::ParallelGuard>::run::<(), rustc_data_structures::sync::parallel::enabled::par_for_each_in<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure#0}>::{closure#0}::{closure#1}::{closure#0}>
  17: <rustc_session::session::Session>::time::<(), rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}>
  18: rustc_monomorphize::collector::collect_crate_mono_items
  19: rustc_monomorphize::partitioning::collect_and_partition_mono_items
      [... omitted 2 frames ...]
  20: rustc_codegen_ssa::base::codegen_crate::<rustc_codegen_llvm::LlvmCodegenBackend>
  21: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  22: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
  23: rustc_interface::passes::start_codegen
  24: <rustc_middle::ty::context::GlobalCtxt>::enter::<<rustc_interface::queries::Queries>::codegen_and_build_linker::{closure#0}, core::result::Result<rustc_interface::queries::Linker, rustc_span::ErrorGuaranteed>>
  25: <rustc_interface::queries::Queries>::codegen_and_build_linker
  26: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: please attach the file at `/Users/shosti/src/tensrus/rustc-ice-2024-06-06T15_38_19-35349.txt` to your bug report

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: could not compile `tensrus` (lib test)

rustc-ice-2024-06-06T15_38_19-35349.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-monomorphizationArea: MonomorphizationC-bugCategory: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleF-adt_const_params`#![feature(adt_const_params)]`F-generic_const_exprs`#![feature(generic_const_exprs)]`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.requires-incomplete-featuresThis issue requires the use of incomplete features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions