ICE: `type_of called on const argument's anon const before the const argument was lowered`
Open
Nobody has claimed this yet.
C-bug
I-ICE
S-bug-has-test
S-has-mcve
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
Code
use std::arch::global_asm;
static X: isize = 3;
global_asm! {
"{}",
sym X::<{}>,
}
fn main() {}
A mutant of glacier2's fixed/137179.rs
Meta
rustc --version --verbose:
rustc 1.93.0-nightly (c90bcb957 2025-11-06)
binary: rustc
commit-hash: c90bcb9571b7aab0d8beaa2ce8a998ffaf079d38
commit-date: 2025-11-06
host: x86_64-apple-darwin
release: 1.93.0-nightly
LLVM version: 21.1.3
Error output
Command: rustc
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
--> 01.rs:10:16
|
10 | sym a::X::<{}>,
| ^^
|
note: delayed at compiler/rustc_hir_analysis/src/collect/type_of.rs:109:14
--> 01.rs:10:16
|
10 | sym a::X::<{}>,
| ^^
error: internal compiler error: mir_const_qualif: MIR had errors
--> 01.rs:10:16
|
10 | sym a::X::<{}>,
| ^^
|
note: delayed at compiler/rustc_mir_transform/src/lib.rs:369:19
Backtrace
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
--> 01.rs:10:16
|
10 | sym a::X::<{}>,
| ^^
|
note: delayed at compiler/rustc_hir_analysis/src/collect/type_of.rs:109:14
0: std::backtrace::Backtrace::create
1: std::backtrace::Backtrace::capture
2: <rustc_errors::DiagCtxtInner>::emit_diagnostic
3: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
4: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
5: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, &str>
6: rustc_hir_analysis::collect::type_of::type_of
7: 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]>>
8: 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>
9: rustc_query_impl::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
10: rustc_hir_typeck::typeck_with_inspect::{closure#0}
11: rustc_hir_typeck::typeck
12: 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]>>
13: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::CrateNum, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
14: rustc_query_impl::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
15: rustc_hir_typeck::used_trait_imports
16: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::used_trait_imports::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
17: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::CrateNum, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
18: rustc_query_impl::query_impl::used_trait_imports::get_query_non_incr::__rust_end_short_backtrace
19: rustc_hir_analysis::check_unused::check_unused_traits
20: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::check_unused_traits::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
21: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
22: rustc_query_impl::query_impl::check_unused_traits::get_query_non_incr::__rust_end_short_backtrace
23: rustc_hir_analysis::check_crate
24: rustc_interface::passes::analysis
25: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
26: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
27: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
28: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
29: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
30: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
31: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
32: std::sys::thread::unix::Thread::new::thread_start
33: __pthread_start
--> 01.rs:10:16
|
10 | sym a::X::<{}>,
| ^^
error: internal compiler error: mir_const_qualif: MIR had errors
--> 01.rs:10:16
|
10 | sym a::X::<{}>,
| ^^
|
note: delayed at compiler/rustc_mir_transform/src/lib.rs:369:19
0: std::backtrace::Backtrace::create
1: std::backtrace::Backtrace::capture
2: <rustc_errors::DiagCtxtInner>::emit_diagnostic
3: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
4: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
5: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, &str>
6: rustc_mir_transform::mir_const_qualif
7: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_const_qualif::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 4]>>
8: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 4]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
9: rustc_query_impl::query_impl::mir_const_qualif::get_query_non_incr::__rust_end_short_backtrace
10: rustc_mir_transform::mir_promoted
11: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_promoted::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 16]>>
12: <rustc_query_impl::query_impl::mir_promoted::dynamic_query::{closure#2} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId)>>::call_once
13: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::CrateNum, rustc_middle::query::erase::Erased<[u8; 16]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
14: rustc_query_impl::query_impl::mir_promoted::get_query_non_incr::__rust_end_short_backtrace
15: rustc_borrowck::mir_borrowck
16: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 8]>>
17: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::CrateNum, rustc_middle::query::erase::Erased<[u8; 8]>, rustc_query_system::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
18: rustc_query_impl::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
19: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface::passes::run_required_analyses::{closure#1}::{closure#0}>::{closure#0}
20: rustc_interface::passes::analysis
21: rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 0]>>
22: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::Erased<[u8; 0]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
23: rustc_query_impl::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
24: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
25: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
26: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
27: <<std::thread::Builder>::spawn_unchecked_<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
28: std::sys::thread::unix::Thread::new::thread_start
29: __pthread_start
--> 01.rs:10:16
|
10 | sym a::X::<{}>,
| ^^
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/jb/Library/CloudStorage/Dropbox/Desk/2503_rustc_ice/20251106 ice 보고용/rustc-ice-2025-11-07T01_50_01-47253.txt` to your bug report
query stack during panic:
end of query stack
Notes
-
ICE locations
- delayed at
compiler/rustc_hir_analysis/src/collect/type_of.rs Line-109 - delayed at
compiler/rustc_mir_transform/src/lib.rs Line-369
https://github.com/rust-lang/rust/blob/c90bcb9571b7aab0d8beaa2ce8a998ffaf079d38/compiler/rustc_hir_analysis/src/collect/type_of.rs#L107-L113
https://github.com/rust-lang/rust/blob/c90bcb9571b7aab0d8beaa2ce8a998ffaf079d38/compiler/rustc_mir_transform/src/lib.rs#L367-L371
- delayed at
-
Duplication check
- I searched for ICE issues with "called on const arguments", and "mir_const_qualif: MIR had errors", but all those issues are closed.
- https://github.com/rust-lang/rust/issues?q=is%3Aissue%20state%3Aclosed%20label%3AI-ICE%20%22called%20on%20const%20arguments%22
- https://github.com/rust-lang/rust/issues?q=is%3Aissue%20state%3Aclosed%20label%3AI-ICE%20%22mir_const_qualif%3A%20MIR%20had%20errors%22
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided global_asm! example with rustc, then read compiler/rustc_hir_analysis/src/collect/type_of.rs at the reported location and compiler/rustc_mir_transform/src/lib.rs at its delayed-bug location. Trace why the anonymous const is queried before lowering; 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
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100