rust-lang / rust-lang/rust

[ICE]: `no ValTree should have been created for type Binder { value: extern "C...`

Open
#162,681 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-generic_const_args I-ICE needs-triage T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

auto-reduced (treereduce-rust):

#![feature(macroless_const_item_generic_const_args)]
#![feature(generic_const_args)]
pub mod bar {
    pub struct Foo {
        pub bar: Bar,
    }
    pub struct Bar(extern "C" fn([u8]));
}

pub mod x {
    use crate::bar;
    pub const Foo: bar::Bar = bar::Bar('a');
}

pub fn warning() -> bar::Foo {
    use bar::*;
    use x::Foo;
    Foo { bar: Foo }
}

original:

//@ check-pass
#![allow(nonstandard_style)]

pub mod bar {
    pub struct Foo { pub bar: Bar }
    pub struct Bar(extern "C" fn([u8]));
}

pub mod x {
    use crate::bar;
    pub const Foo: bar::Bar = bar::Bar('a');
}

pub fn warning() -> bar::Foo {
    #![deny(unused_imports)] // no error
    use bar::*;
    use x::Foo;
    Foo { bar: Foo }
}

fn main() {}

Version information

rustc 1.100.0-nightly (74b3f086e 2026-09-12)
binary: rustc
commit-hash: 74b3f086e27d20f04611a52addc3781576f3c749
commit-date: 2026-09-12
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.1

Possibly related line of code:
https://github.com/rust-lang/rust/blob/74b3f086e27d20f04611a52addc3781576f3c749/compiler/rustc_const_eval/src/const_eval/valtrees.rs#L377-L389

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(macroless_const_item_generic_const_args) -Zcrate-attr=feature(generic_const_args)

Program output

error[E0603]: tuple struct constructor `Bar` is private
  --> /tmp/icemaker_global_tempdir.iGXpHuTPsdq6/rustc_testrunner_tmpdir_reporting.Ea8W4Yn7FqUS/mvce.rs:10:36
   |
 5 |     pub struct Bar(extern "C" fn([u8]));
   |                    ------------------- a constructor is private if any of the fields is private
...
10 |     pub const Foo: bar::Bar = bar::Bar('a');
   |                                    ^^^ private tuple struct constructor
   |
note: the tuple struct constructor `Bar` is defined here
  --> /tmp/icemaker_global_tempdir.iGXpHuTPsdq6/rustc_testrunner_tmpdir_reporting.Ea8W4Yn7FqUS/mvce.rs:5:5
   |
 5 |     pub struct Bar(extern "C" fn([u8]));
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider making the field publicly accessible
   |
 5 |     pub struct Bar(pub extern "C" fn([u8]));
   |                    +++

error: `generic_const_args` requires `min_generic_const_args` to be enabled
 --> <crate attribute>:1:12
  |
1 | #![feature(generic_const_args)]
  |            ^^^^^^^^^^^^^^^^^^
  |
  = help: enable all of these features

error: `macroless_const_item_generic_const_args` requires `min_generic_const_args` to be enabled
 --> <crate attribute>:1:12
  |
1 | #![feature(macroless_const_item_generic_const_args)]
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: enable all of these features

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

warning: the feature `generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
 --> <crate attribute>:1:12
  |
1 | #![feature(generic_const_args)]
  |            ^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #151972 <https://github.com/rust-lang/rust/issues/151972> for more information

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.iGXpHuTPsdq6/rustc_testrunner_tmpdir_reporting.Ea8W4Yn7FqUS/mvce.rs:17:2
   |
17 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.iGXpHuTPsdq6/rustc_testrunner_tmpdir_reporting.Ea8W4Yn7FqUS/mvce.rs`

error[E0741]: `Bar` must implement `ConstParamTy` to be used as the type of a const generic parameter
  --> /tmp/icemaker_global_tempdir.iGXpHuTPsdq6/rustc_testrunner_tmpdir_reporting.Ea8W4Yn7FqUS/mvce.rs:10:20
   |
10 |     pub const Foo: bar::Bar = bar::Bar('a');
   |                    ^^^^^^^^
   |
help: add `#[derive(ConstParamTy, PartialEq, Eq)]` to the struct
   |
 5 +     #[derive(ConstParamTy, PartialEq, Eq)]
 6 |     pub struct Bar(extern "C" fn([u8]));
   |

error: internal compiler error: /rustc-dev/74b3f086e27d20f04611a52addc3781576f3c749/compiler/rustc_const_eval/src/const_eval/valtrees.rs:383:13: no ValTree should have been created for type Binder { value: extern "C { unwind: false }" fn([u8]), bound_vars: [] }


thread 'rustc' (755170) panicked at /rustc-dev/74b3f086e27d20f04611a52addc3781576f3c749/compiler/rustc_const_eval/src/const_eval/valtrees.rs:383:13:
Box<dyn Any>
stack backtrace:
   0:     0x7f7efd23d6f6 - <<std[3528600ba3f9fe66]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[9253e626ef1be868]::fmt::Display>::fmt
   1:     0x7f7efd80988f - core[9253e626ef1be868]::fmt::write
   2:     0x7f7efd2526bc - <std[3528600ba3f9fe66]::sys::stdio::unix::Stderr as core[9253e626ef1be868]::io::write::Write>::write_fmt
   3:     0x7f7efd2103da - std[3528600ba3f9fe66]::panicking::default_hook::{closure#0}
   4:     0x7f7efd231e53 - std[3528600ba3f9fe66]::panicking::default_hook
   5:     0x7f7efbf6269f - std[3528600ba3f9fe66]::panicking::update_hook::<alloc[19f73542e5485bc1]::boxed::Box<rustc_driver_impl[4014d772c3bdc445]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f7efd2322f2 - std[3528600ba3f9fe66]::panicking::panic_with_hook
   7:     0x7f7efbf91624 - std[3528600ba3f9fe66]::panicking::begin_panic::<rustc_errors[ece56505557c1b0d]::ExplicitBug>::{closure#0}
   8:     0x7f7efbf8a216 - std[3528600ba3f9fe66]::sys::backtrace::__rust_end_short_backtrace::<std[3528600ba3f9fe66]::panicking::begin_panic<rustc_errors[ece56505557c1b0d]::ExplicitBug>::{closure#0}, !>
   9:     0x7f7efbf8819e - std[3528600ba3f9fe66]::panicking::begin_panic::<rustc_errors[ece56505557c1b0d]::ExplicitBug>
  10:     0x7f7efbf9cda1 - <rustc_errors[ece56505557c1b0d]::diagnostic::BugAbort as rustc_errors[ece56505557c1b0d]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7f7efc618879 - rustc_middle[5a5f5798a8f38072]::util::bug::opt_span_bug_fmt::<rustc_span[2d93c3ee6901fd4d]::span_encoding::Span>::{closure#0}
  12:     0x7f7efc618cb2 - rustc_middle[5a5f5798a8f38072]::ty::context::tls::with_opt::<rustc_middle[5a5f5798a8f38072]::util::bug::opt_span_bug_fmt<rustc_span[2d93c3ee6901fd4d]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7f7efc603a40 - rustc_middle[5a5f5798a8f38072]::ty::context::tls::with_context_opt::<rustc_middle[5a5f5798a8f38072]::ty::context::tls::with_opt<rustc_middle[5a5f5798a8f38072]::util::bug::opt_span_bug_fmt<rustc_span[2d93c3ee6901fd4d]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7f7ef90ab0c4 - rustc_middle[5a5f5798a8f38072]::util::bug::bug_fmt
  15:     0x7f7efa8920dc - rustc_const_eval[e139fb126cf1b029]::const_eval::valtrees::valtree_to_const_value
  16:     0x7f7efa892562 - rustc_const_eval[e139fb126cf1b029]::const_eval::valtrees::valtree_to_const_value
  17:     0x7f7efeb2786b - <rustc_const_eval[e139fb126cf1b029]::provide::{closure#1} as core[9253e626ef1be868]::ops::function::FnOnce<(rustc_middle[5a5f5798a8f38072]::ty::context::TyCtxt, rustc_middle[5a5f5798a8f38072]::ty::consts::valtree::Value)>>::call_once
  18:     0x7f7efeb2781c - rustc_query_impl[d5422e89ac02de23]::query_vtables::valtree_to_const_val::invoke_provider_fn::__rust_begin_short_backtrace
  19:     0x7f7efeb27094 - rustc_query_impl[d5422e89ac02de23]::execution::try_execute_query::<rustc_middle[5a5f5798a8f38072]::query::caches::DefaultCache<rustc_middle[5a5f5798a8f38072]::ty::consts::valtree::Value, rustc_middle[5a5f5798a8f38072]::query::erase::ErasedData<[u8; 24usize]>>, false>
  20:     0x7f7efeb26dbe - rustc_query_impl[d5422e89ac02de23]::query_vtables::valtree_to_const_val::execute_query_non_incr::__rust_end_short_backtrace
  21:     0x7f7efe3f9925 - <rustc_mir_transform[6d95706d29a7dfb2]::known_panics_lint::ConstPropagator as rustc_middle[5a5f5798a8f38072]::mir::visit::Visitor>::visit_operand
  22:     0x7f7efe3ff579 - <rustc_mir_transform[6d95706d29a7dfb2]::known_panics_lint::ConstPropagator as rustc_middle[5a5f5798a8f38072]::mir::visit::Visitor>::visit_assign
  23:     0x7f7efe3fc1ce - <rustc_mir_transform[6d95706d29a7dfb2]::known_panics_lint::ConstPropagator as rustc_middle[5a5f5798a8f38072]::mir::visit::Visitor>::visit_body
  24:     0x7f7efe3f74a7 - <rustc_mir_transform[6d95706d29a7dfb2]::known_panics_lint::KnownPanicsLint as rustc_mir_transform[6d95706d29a7dfb2]::pass_manager::MirLint>::run_lint
  25:     0x7f7efd81757f - rustc_mir_transform[6d95706d29a7dfb2]::run_analysis_to_runtime_passes
  26:     0x7f7efdf71589 - rustc_mir_transform[6d95706d29a7dfb2]::mir_drops_elaborated_and_const_checked
  27:     0x7f7efdecdc75 - rustc_query_impl[d5422e89ac02de23]::execution::try_execute_query::<rustc_data_structures[1609676847358c32]::vec_cache::VecCache<rustc_span[2d93c3ee6901fd4d]::def_id::LocalDefId, rustc_middle[5a5f5798a8f38072]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[5a5f5798a8f38072]::dep_graph::graph::DepNodeIndex>, false>
  28:     0x7f7efdecd7a7 - rustc_query_impl[d5422e89ac02de23]::query_vtables::mir_drops_elaborated_and_const_checked::execute_query_non_incr::__rust_end_short_backtrace
  29:     0x7f7efded0656 - <rustc_middle[5a5f5798a8f38072]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[a9b0b26ac5f97aef]::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
  30:     0x7f7efdecf78e - rustc_interface[a9b0b26ac5f97aef]::passes::analysis
  31:     0x7f7efe875dca - rustc_query_impl[d5422e89ac02de23]::execution::try_execute_query::<rustc_middle[5a5f5798a8f38072]::query::caches::SingleCache<rustc_middle[5a5f5798a8f38072]::query::erase::ErasedData<[u8; 0usize]>>, false>
  32:     0x7f7efe875b6b - rustc_query_impl[d5422e89ac02de23]::query_vtables::analysis::execute_query_non_incr::__rust_end_short_backtrace
  33:     0x7f7efeae7fad - rustc_interface[a9b0b26ac5f97aef]::interface::run_compiler::<(), rustc_driver_impl[4014d772c3bdc445]::run_compiler::{closure#0}>::{closure#2}
  34:     0x7f7efebae664 - std[3528600ba3f9fe66]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[a9b0b26ac5f97aef]::util::run_in_thread_with_globals<rustc_interface[a9b0b26ac5f97aef]::util::run_in_thread_pool_with_globals<rustc_interface[a9b0b26ac5f97aef]::interface::run_compiler<(), rustc_driver_impl[4014d772c3bdc445]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  35:     0x7f7efebae40b - <std[3528600ba3f9fe66]::thread::lifecycle::spawn_unchecked<rustc_interface[a9b0b26ac5f97aef]::util::run_in_thread_with_globals<rustc_interface[a9b0b26ac5f97aef]::util::run_in_thread_pool_with_globals<rustc_interface[a9b0b26ac5f97aef]::interface::run_compiler<(), rustc_driver_impl[4014d772c3bdc445]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[9253e626ef1be868]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  36:     0x7f7efebb77db - <std[3528600ba3f9fe66]::sys::thread::unix::Thread>::new::thread_start
  37:     0x7f7ef7a980a2 - <unknown>
  38:     0x7f7ef7b2080c - <unknown>
  39:                0x0 - <unknown>

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: rustc 1.100.0-nightly (74b3f086e 2026-09-12) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z crate-attr=feature(macroless_const_item_generic_const_args) -Z crate-attr=feature(generic_const_args) -Z dump-mir-dir=dir

query stack during panic:
#0 [valtree_to_const_val] converting type-level constant value to MIR constant value
#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `warning`
#2 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 6 previous errors; 2 warnings emitted

Some errors have detailed explanations: E0601, E0603, E0741.
For more information about an error, try `rustc --explain E0601`.

@rustbot label +F-macroless_const_item_generic_const_args +F-generic_const_args

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the ICE with the reduced example in a.rs and the rustc command shown in the report. Start at compiler/rustc_const_eval/src/const_eval/valtrees.rs:377-389 and trace the valtree conversion that reaches the reported panic; done means the example no longer produces an internal compiler error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.