Skip to content

ICE: typeof called on const argument's anon const before the const argument was lowered #141951

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

Open
matthiaskrgr opened this issue Jun 3, 2025 · 2 comments
Labels
A-parallel-compiler Area: parallel compiler C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

//@compile-flags: -Zthreads=20  --crate-type=lib
use std::arch::global_asm;

global_asm! {
    "{}",
    sym foo::<{
        || {};
        0
    }>,
}

fn foo<const N: usize>() {}

Meta

rustc --version --verbose:

rustc 1.89.0-nightly (5d707b07e 2025-06-02)
binary: rustc
commit-hash: 5d707b07e42766c080c5012869c9988a18dcbb83
commit-date: 2025-06-02
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.5

Error output

<output>
Backtrace

warning: unused closure that must be used
 --> /home/matthias/vcs/github/glacier2_fuzz/fixed/137179.rs:6:9
  |
6 |         || {};
  |         ^^^^^
  |
  = note: closures are lazy and do nothing unless called
  = note: `#[warn(unused_must_use)]` on by default

warning: 1 warning emitted

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: `type_of` called on const argument's anon const before the const argument was lowered
 --> /home/matthias/vcs/github/glacier2_fuzz/fixed/137179.rs:5:15
  |
5 |       sym foo::<{
  |  _______________^
6 | |         || {};
7 | |         0
8 | |     }>,
  | |_____^
  |
note: delayed at compiler/rustc_hir_analysis/src/collect/type_of.rs:108:14
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         3: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, &str>
         4: rustc_hir_analysis::collect::type_of::type_of
         5: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
         6: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 8]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
         7: rustc_query_impl::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
         8: rustc_hir_typeck::typeck_with_inspect::{closure#0}
         9: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        10: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        11: rustc_query_impl::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
        12: rustc_hir_typeck::typeck_with_inspect::{closure#0}
        13: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
        14: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
        15: rustc_query_impl::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
        16: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis::check_crate::{closure#1}>::{closure#0}
        17: rustc_data_structures::sync::parallel::par_slice::par_rec::<&rustc_span::def_id::LocalDefId, rustc_data_structures::sync::parallel::par_for_each_in<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners<rustc_hir_analysis::check_crate::{closure#1}>::{closure#0}>::{closure#0}::{closure#0}>
        18: rayon_core::join::join_context::<rayon_core::join::join::call<(), rustc_data_structures::sync::parallel::par_slice::par_rec<&rustc_span::def_id::LocalDefId, rustc_data_structures::sync::parallel::par_for_each_in<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners<rustc_hir_analysis::check_crate::{closure#1}>::{closure#0}>::{closure#0}::{closure#0}>::{closure#1}>::{closure#0}, rayon_core::join::join::call<(), rustc_data_structures::sync::parallel::par_slice::par_rec<&rustc_span::def_id::LocalDefId, rustc_data_structures::sync::parallel::par_for_each_in<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners<rustc_hir_analysis::check_crate::{closure#1}>::{closure#0}>::{closure#0}::{closure#0}>::{closure#2}>::{closure#0}, (), ()>::{closure#0}
        19: rustc_data_structures::sync::parallel::par_slice::par_rec::<&rustc_span::def_id::LocalDefId, rustc_data_structures::sync::parallel::par_for_each_in<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners<rustc_hir_analysis::check_crate::{closure#1}>::{closure#0}>::{closure#0}::{closure#0}>
        20: <rayon_core::job::StackJob<rayon_core::latch::SpinLatch, rayon_core::join::join_context::call_b<(), rayon_core::join::join::call<(), rustc_data_structures::sync::parallel::par_slice::par_rec<&rustc_span::def_id::LocalDefId, rustc_data_structures::sync::parallel::par_for_each_in<&rustc_span::def_id::LocalDefId, &[rustc_span::def_id::LocalDefId], <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners<rustc_hir_analysis::check_crate::{closure#1}>::{closure#0}>::{closure#0}::{closure#0}>::{closure#2}>::{closure#0}>::{closure#0}, ()> as rayon_core::job::Job>::execute
        21: <rayon_core::registry::WorkerThread>::wait_until_cold
        22: <rayon_core::registry::ThreadBuilder>::run
        23: std::sys::backtrace::__rust_begin_short_backtrace::<<rayon_core::ThreadPoolBuilder>::build_scoped<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#0}, rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#1}, ()>::{closure#0}::{closure#0}::{closure#0}, ()>
        24: <<std::thread::Builder>::spawn_unchecked_<<rayon_core::ThreadPoolBuilder>::build_scoped<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#0}, rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#1}, ()>::{closure#0}::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        25: std::sys::pal::unix::thread::Thread::new::thread_start
        26: <unknown>
        27: <unknown>
 --> /home/matthias/vcs/github/glacier2_fuzz/fixed/137179.rs:5:15
  |
5 |       sym foo::<{
  |  _______________^
6 | |         || {};
7 | |         0
8 | |     }>,
  | |_____^

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 `/home/matthias/vcs/github/glacier2_fuzz/fixed/rustc-ice-2025-06-03T08_23_38-137028.txt` to your bug report

note: compiler flags: -Z threads=20 --crate-type lib

query stack during panic:
end of query stack

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Jun 3, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 3, 2025
@matthiaskrgr matthiaskrgr added the A-parallel-compiler Area: parallel compiler label Jun 3, 2025
@matthiaskrgr
Copy link
Member Author

bisects to #135186 🤔

@matthiaskrgr matthiaskrgr changed the title ICE: called on const argument's anon const before the const argument was lowered ICE: typeof called on const argument's anon const before the const argument was lowered Jun 3, 2025
@cyrgani
Copy link
Contributor

cyrgani commented Jun 3, 2025

//@compile-flags: -Zthreads=2
fn foo<const N: usize>() {}

fn main() {
    foo::<{
        || {};
        0
    }>();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parallel-compiler Area: parallel compiler C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. 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

3 participants