Skip to content

expected ConstKind::Value ICE when putting (fn(),) in a const generic parameter (requires adt_const_params) #99641

Description

Code

#![feature(adt_const_params)]

fn main() {
    pub struct Color<const WHITE: (fn(),)>;

    impl<const WHITE: (fn(),)> Color<WHITE> {
        /// Construct a new color
        pub fn new() -> Self {
            Color::<WHITE>
        }
    }

    pub const D65: (fn(),) = (|| {},);

    Color::<D65>::new();
}

Meta

rustc --version --verbose:

rustc 1.64.0-nightly (848090dcd 2022-07-22)
binary: rustc
commit-hash: 848090dcd18553b790461132ca9d2a020aeea9a2
commit-date: 2022-07-22
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.6

Error output

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

warning: crate `scratchBegcRI6XF` should have a snake case name
  |
  = note: `#[warn(non_snake_case)]` on by default
  = help: convert the identifier to snake case: `scratch_begc_ri6_xf`

error: internal compiler error: compiler/rustc_middle/src/ty/consts.rs:206:18: expected ConstKind::Value

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/compiler/rustc_errors/src/lib.rs:1392:9
stack backtrace:
   0:     0x7f9d31aa28a0 - std::backtrace_rs::backtrace::libunwind::trace::h9ae2a0a86525a721
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7f9d31aa28a0 - std::backtrace_rs::backtrace::trace_unsynchronized::h2db65d70ea604a8b
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f9d31aa28a0 - std::sys_common::backtrace::_print_fmt::ha87108be4ced4d7b
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f9d31aa28a0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h8289c789e2444f52
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f9d31afbe7c - core::fmt::write::h4bc61850e148256a
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/core/src/fmt/mod.rs:1198:17
   5:     0x7f9d31a93ea5 - std::io::Write::write_fmt::h39fafbe9deae7dce
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/io/mod.rs:1672:15
   6:     0x7f9d31aa5531 - std::sys_common::backtrace::_print::h48b22fe50876db47
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f9d31aa5531 - std::sys_common::backtrace::print::h4deb0c8c0ba6e812
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f9d31aa5531 - std::panicking::default_hook::{{closure}}::hec18832ee0d2183c
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/panicking.rs:295:22
   9:     0x7f9d31aa5203 - std::panicking::default_hook::h6fd5dc4e9c4f675e
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/panicking.rs:314:9
  10:     0x7f9d32351af1 - rustc_driver[c212bfd01fb1bd4e]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f9d31aa5d06 - std::panicking::rust_panic_with_hook::hb4a45181e5abcce3
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/panicking.rs:702:17
  12:     0x7f9d333b4ff1 - std[c85d7afaac2a6227]::panicking::begin_panic::<rustc_errors[4d7b9c19931775fa]::ExplicitBug>::{closure#0}
  13:     0x7f9d333b4326 - std[c85d7afaac2a6227]::sys_common::backtrace::__rust_end_short_backtrace::<std[c85d7afaac2a6227]::panicking::begin_panic<rustc_errors[4d7b9c19931775fa]::ExplicitBug>::{closure#0}, !>
  14:     0x7f9d33391ef6 - std[c85d7afaac2a6227]::panicking::begin_panic::<rustc_errors[4d7b9c19931775fa]::ExplicitBug>
  15:     0x7f9d3334fa16 - std[c85d7afaac2a6227]::panic::panic_any::<rustc_errors[4d7b9c19931775fa]::ExplicitBug>
  16:     0x7f9d3334b375 - <rustc_errors[4d7b9c19931775fa]::HandlerInner>::bug::<&alloc[2307dd647311a06c]::string::String>
  17:     0x7f9d3334b0d0 - <rustc_errors[4d7b9c19931775fa]::Handler>::bug::<&alloc[2307dd647311a06c]::string::String>
  18:     0x7f9d334091cd - rustc_middle[339c612205d209e0]::ty::context::tls::with_context_opt::<rustc_middle[339c612205d209e0]::ty::context::tls::with_opt<rustc_middle[339c612205d209e0]::util::bug::opt_span_bug_fmt<rustc_span[bd4aa58f7c6f9add]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
  19:     0x7f9d3340f176 - rustc_middle[339c612205d209e0]::util::bug::opt_span_bug_fmt::<rustc_span[bd4aa58f7c6f9add]::span_encoding::Span>
  20:     0x7f9d3340f0f3 - rustc_middle[339c612205d209e0]::util::bug::bug_fmt
  21:     0x7f9d33444d1f - <rustc_middle[339c612205d209e0]::ty::consts::Const>::to_valtree
  22:     0x7f9d33f9c93f - rustc_codegen_ssa[4eadd18c013d620f]::debuginfo::type_names::push_generic_params_internal
  23:     0x7f9d33f971ec - rustc_codegen_ssa[4eadd18c013d620f]::debuginfo::type_names::push_debuginfo_type_name
  24:     0x7f9d33f96e70 - rustc_codegen_ssa[4eadd18c013d620f]::debuginfo::type_names::compute_debuginfo_type_name
  25:     0x7f9d336cbf1c - rustc_codegen_llvm[1092e7de2567b279]::debuginfo::metadata::type_di_node
  26:     0x7f9d336b4e88 - <rustc_codegen_llvm[1092e7de2567b279]::context::CodegenCx as rustc_codegen_ssa[4eadd18c013d620f]::traits::debuginfo::DebugInfoMethods>::dbg_scope_fn
  27:     0x7f9d336fa970 - rustc_codegen_ssa[4eadd18c013d620f]::mir::codegen_mir::<rustc_codegen_llvm[1092e7de2567b279]::builder::Builder>
  28:     0x7f9d336d3382 - rustc_codegen_llvm[1092e7de2567b279]::base::compile_codegen_unit::module_codegen
  29:     0x7f9d34577266 - <rustc_query_system[606dbbc21d5be994]::dep_graph::graph::DepGraph<rustc_middle[339c612205d209e0]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[339c612205d209e0]::ty::context::TyCtxt, rustc_span[bd4aa58f7c6f9add]::symbol::Symbol, rustc_codegen_ssa[4eadd18c013d620f]::ModuleCodegen<rustc_codegen_llvm[1092e7de2567b279]::ModuleLlvm>>
  30:     0x7f9d345a6229 - rustc_codegen_llvm[1092e7de2567b279]::base::compile_codegen_unit
  31:     0x7f9d3457a3b9 - rustc_codegen_ssa[4eadd18c013d620f]::base::codegen_crate::<rustc_codegen_llvm[1092e7de2567b279]::LlvmCodegenBackend>
  32:     0x7f9d345bd291 - <rustc_codegen_llvm[1092e7de2567b279]::LlvmCodegenBackend as rustc_codegen_ssa[4eadd18c013d620f]::traits::backend::CodegenBackend>::codegen_crate
  33:     0x7f9d3453ede7 - <rustc_session[7be89286315efa93]::session::Session>::time::<alloc[2307dd647311a06c]::boxed::Box<dyn core[c7b8860b6e72b2f6]::any::Any>, rustc_interface[e455626695b2bf4c]::passes::start_codegen::{closure#0}>
  34:     0x7f9d3453b773 - <rustc_interface[e455626695b2bf4c]::passes::QueryContext>::enter::<<rustc_interface[e455626695b2bf4c]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[c7b8860b6e72b2f6]::result::Result<alloc[2307dd647311a06c]::boxed::Box<dyn core[c7b8860b6e72b2f6]::any::Any>, rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>>
  35:     0x7f9d34531c83 - <rustc_interface[e455626695b2bf4c]::queries::Queries>::ongoing_codegen
  36:     0x7f9d344f9611 - <rustc_interface[e455626695b2bf4c]::interface::Compiler>::enter::<rustc_driver[c212bfd01fb1bd4e]::run_compiler::{closure#1}::{closure#2}, core[c7b8860b6e72b2f6]::result::Result<core[c7b8860b6e72b2f6]::option::Option<rustc_interface[e455626695b2bf4c]::queries::Linker>, rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>>
  37:     0x7f9d344f579f - rustc_span[bd4aa58f7c6f9add]::with_source_map::<core[c7b8860b6e72b2f6]::result::Result<(), rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>, rustc_interface[e455626695b2bf4c]::interface::create_compiler_and_run<core[c7b8860b6e72b2f6]::result::Result<(), rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>, rustc_driver[c212bfd01fb1bd4e]::run_compiler::{closure#1}>::{closure#1}>
  38:     0x7f9d34511e50 - rustc_interface[e455626695b2bf4c]::interface::create_compiler_and_run::<core[c7b8860b6e72b2f6]::result::Result<(), rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>, rustc_driver[c212bfd01fb1bd4e]::run_compiler::{closure#1}>
  39:     0x7f9d34525e22 - <scoped_tls[ae38fa8e7a890916]::ScopedKey<rustc_span[bd4aa58f7c6f9add]::SessionGlobals>>::set::<rustc_interface[e455626695b2bf4c]::interface::run_compiler<core[c7b8860b6e72b2f6]::result::Result<(), rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>, rustc_driver[c212bfd01fb1bd4e]::run_compiler::{closure#1}>::{closure#0}, core[c7b8860b6e72b2f6]::result::Result<(), rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>>
  40:     0x7f9d344f7cef - std[c85d7afaac2a6227]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[e455626695b2bf4c]::util::run_in_thread_pool_with_globals<rustc_interface[e455626695b2bf4c]::interface::run_compiler<core[c7b8860b6e72b2f6]::result::Result<(), rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>, rustc_driver[c212bfd01fb1bd4e]::run_compiler::{closure#1}>::{closure#0}, core[c7b8860b6e72b2f6]::result::Result<(), rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>>::{closure#0}, core[c7b8860b6e72b2f6]::result::Result<(), rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>>
  41:     0x7f9d345122a9 - <<std[c85d7afaac2a6227]::thread::Builder>::spawn_unchecked_<rustc_interface[e455626695b2bf4c]::util::run_in_thread_pool_with_globals<rustc_interface[e455626695b2bf4c]::interface::run_compiler<core[c7b8860b6e72b2f6]::result::Result<(), rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>, rustc_driver[c212bfd01fb1bd4e]::run_compiler::{closure#1}>::{closure#0}, core[c7b8860b6e72b2f6]::result::Result<(), rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>>::{closure#0}, core[c7b8860b6e72b2f6]::result::Result<(), rustc_errors[4d7b9c19931775fa]::ErrorGuaranteed>>::{closure#1} as core[c7b8860b6e72b2f6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  42:     0x7f9d31aaf753 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h713f45ba125dd07b
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/alloc/src/boxed.rs:1935:9
  43:     0x7f9d31aaf753 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5469f4a0b2b35b34
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/alloc/src/boxed.rs:1935:9
  44:     0x7f9d31aaf753 - std::sys::unix::thread::Thread::new::thread_start::h81d52548323558fa
                               at /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/library/std/src/sys/unix/thread.rs:108:17
  45:     0x7f9d3168c54d - <unknown>
  46:     0x7f9d31711874 - clone
  47:                0x0 - <unknown>

note: the compiler unexpectedly panicked. this is a bug.

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: rustc 1.64.0-nightly (848090dcd 2022-07-22) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental

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

query stack during panic:
end of query stack
error: could not compile `scratchBegcRI6XF`; 2 warnings emitted
Backtrace

# RUST_BACKTRACE=1 cargo build
   Compiling scratchBegcRI6XF v0.1.0 (/tmp/scratchBegcRI6XF)
warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes
 --> src/main.rs:1:12
  |
1 | #![feature(adt_const_params)]
  |            ^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(incomplete_features)]` on by default
  = note: see issue #95174 <https://github.com/rust-lang/rust/issues/95174> for more information

warning: crate `scratchBegcRI6XF` should have a snake case name
  |
  = note: `#[warn(non_snake_case)]` on by default
  = help: convert the identifier to snake case: `scratch_begc_ri6_xf`

error: internal compiler error: compiler/rustc_middle/src/ty/consts.rs:206:18: expected ConstKind::Value

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/848090dcd18553b790461132ca9d2a020aeea9a2/compiler/rustc_errors/src/lib.rs:1392:9
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: std::panic::panic_any::<rustc_errors::ExplicitBug>
   2: <rustc_errors::HandlerInner>::bug::<&alloc::string::String>
   3: <rustc_errors::Handler>::bug::<&alloc::string::String>
   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::opt_span_bug_fmt::<rustc_span::span_encoding::Span>
   6: rustc_middle::util::bug::bug_fmt
   7: <rustc_middle::ty::consts::Const>::to_valtree
   8: rustc_codegen_ssa::debuginfo::type_names::push_generic_params_internal
   9: rustc_codegen_ssa::debuginfo::type_names::push_debuginfo_type_name
  10: rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_type_name
  11: rustc_codegen_llvm::debuginfo::metadata::type_di_node
  12: <rustc_codegen_llvm::context::CodegenCx as rustc_codegen_ssa::traits::debuginfo::DebugInfoMethods>::dbg_scope_fn
  13: rustc_codegen_ssa::mir::codegen_mir::<rustc_codegen_llvm::builder::Builder>
  14: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
  15: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, rustc_span::symbol::Symbol, rustc_codegen_ssa::ModuleCodegen<rustc_codegen_llvm::ModuleLlvm>>
  16: rustc_codegen_llvm::base::compile_codegen_unit
  17: rustc_codegen_ssa::base::codegen_crate::<rustc_codegen_llvm::LlvmCodegenBackend>
  18: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  19: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
  20: <rustc_interface::passes::QueryContext>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_errors::ErrorGuaranteed>>
  21: <rustc_interface::queries::Queries>::ongoing_codegen
  22: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorGuaranteed>>
  23: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
  24: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>
  25: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorGuaranteed>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorGuaranteed>>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: the compiler unexpectedly panicked. this is a bug.

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: rustc 1.64.0-nightly (848090dcd 2022-07-22) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental

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

query stack during panic:
end of query stack
warning: `scratchBegcRI6XF` (bin "scratchBegcRI6XF") generated 2 warnings
error: could not compile `scratchBegcRI6XF`; 2 warnings emitted

Activity

  1. ghost added
    C-bugCategory: This is a bug.
    on Jul 23, 2022
  2. ghost added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    on Jul 23, 2022
  3. ghost added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Jul 23, 2022
  4. matthiaskrgr commented on Jul 23, 2022

    @matthiaskrgr
    Member

    note: this does not crash without -Cdebuginfo=1 (or 2)

  5. added
    requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.
    on Jul 23, 2022
  6. added a commit that references this issue on Jul 24, 2022
  7. added a commit that references this issue on Jul 26, 2022
    18f0e7d
  8. added a commit that references this issue on Jul 27, 2022
    9e7b7d5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

C-bugCategory: This is a bug.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.glacierICE tracked in rust-lang/glacier.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions