Skip to content

[ICE]: could not resolve DefId #156760

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

fn fun<U>() {
    core::arch::global_asm!("{}", sym<U>::pure);
}

original:

fn fun<U>() {
    core::arch::global_asm!("{}", sym<U>::pure);
}

fn main() {}

Version information

rustc 1.97.0-nightly (60592ad7c 2026-05-19)
binary: rustc
commit-hash: 60592ad7c63cdb7cfe092f785bb224b655512926
commit-date: 2026-05-19
host: x86_64-unknown-linux-gnu
release: 1.97.0-nightly
LLVM version: 22.1.4

Possibly related line of code:

}
}
}
self.tcx
.dcx()
.span_bug(self.tcx.hir_span(hir_id), format!("could not resolve {param_def_id:?}"));
}
#[instrument(level = "debug", skip(self))]
fn visit_segment_args(
&mut self,
res: Res,

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

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

error: internal compiler error: could not resolve DefId(0:4 ~ mvce[9936]::fun::U)
 --> /tmp/icemaker_global_tempdir.eELG3YDCWLcR/rustc_testrunner_tmpdir_reporting.JsbSoBDkXgfp/mvce.rs:2:39
  |
2 |     core::arch::global_asm!("{}", sym<U>::pure);
  |                                       ^


thread 'rustc' (2508534) panicked at /rustc-dev/60592ad7c63cdb7cfe092f785bb224b655512926/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs:1671:14:
Box<dyn Any>
stack backtrace:
   0:     0x7f5c40e8f769 - <<std[ad415756b38c0d3b]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[3c43f6ff08284740]::fmt::Display>::fmt
   1:     0x7f5c4161fc48 - core[3c43f6ff08284740]::fmt::write
   2:     0x7f5c40ea6456 - <std[ad415756b38c0d3b]::sys::stdio::unix::Stderr as std[ad415756b38c0d3b]::io::Write>::write_fmt
   3:     0x7f5c40e6598e - std[ad415756b38c0d3b]::panicking::default_hook::{closure#0}
   4:     0x7f5c40e830a3 - std[ad415756b38c0d3b]::panicking::default_hook
   5:     0x7f5c3fc817b1 - std[ad415756b38c0d3b]::panicking::update_hook::<alloc[d177848e48595987]::boxed::Box<rustc_driver_impl[4164e2e4872c99f5]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f5c40e83382 - std[ad415756b38c0d3b]::panicking::panic_with_hook
   7:     0x7f5c3fcaf081 - std[ad415756b38c0d3b]::panicking::begin_panic::<rustc_errors[7308b8b6801eff0]::ExplicitBug>::{closure#0}
   8:     0x7f5c3fca7f66 - std[ad415756b38c0d3b]::sys::backtrace::__rust_end_short_backtrace::<std[ad415756b38c0d3b]::panicking::begin_panic<rustc_errors[7308b8b6801eff0]::ExplicitBug>::{closure#0}, !>
   9:     0x7f5c3fca7ddb - std[ad415756b38c0d3b]::panicking::begin_panic::<rustc_errors[7308b8b6801eff0]::ExplicitBug>
  10:     0x7f5c3fcba561 - <rustc_errors[7308b8b6801eff0]::diagnostic::BugAbort as rustc_errors[7308b8b6801eff0]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7f5c3fd710cc - <rustc_errors[7308b8b6801eff0]::DiagCtxtHandle>::span_bug::<rustc_span[1d2b36215d4b3a94]::span_encoding::Span, alloc[d177848e48595987]::string::String>
  12:     0x7f5c3e290ea7 - rustc_hir[a98e5f59d1d70dd8]::intravisit::walk_qpath::<rustc_hir_analysis[920e2b21ee3cb3b1]::collect::resolve_bound_vars::BoundVarContext>
  13:     0x7f5c3e28ce92 - rustc_hir[a98e5f59d1d70dd8]::intravisit::walk_qpath::<rustc_hir_analysis[920e2b21ee3cb3b1]::collect::resolve_bound_vars::BoundVarContext>
  14:     0x7f5c4231ad56 - rustc_hir[a98e5f59d1d70dd8]::intravisit::walk_expr::<rustc_hir_analysis[920e2b21ee3cb3b1]::collect::resolve_bound_vars::BoundVarContext>
  15:     0x7f5c42319aee - <rustc_hir_analysis[920e2b21ee3cb3b1]::collect::resolve_bound_vars::BoundVarContext>::with::<<rustc_hir_analysis[920e2b21ee3cb3b1]::collect::resolve_bound_vars::BoundVarContext as rustc_hir[a98e5f59d1d70dd8]::intravisit::Visitor>::visit_nested_body::{closure#0}>
  16:     0x7f5c42316727 - rustc_hir[a98e5f59d1d70dd8]::intravisit::walk_item::<rustc_hir_analysis[920e2b21ee3cb3b1]::collect::resolve_bound_vars::BoundVarContext>
  17:     0x7f5c417a906a - rustc_query_impl[f6c0eecf6401915]::query_impl::resolve_bound_vars::invoke_provider_fn::__rust_begin_short_backtrace
  18:     0x7f5c417a8026 - rustc_query_impl[f6c0eecf6401915]::execution::try_execute_query::<rustc_data_structures[56fc8927348ab394]::vec_cache::VecCache<rustc_hir_id[9a89635926ddfe31]::OwnerId, rustc_middle[35b507296d99f42b]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[35b507296d99f42b]::dep_graph::graph::DepNodeIndex>, false>
  19:     0x7f5c417a7c17 - rustc_query_impl[f6c0eecf6401915]::query_impl::resolve_bound_vars::execute_query_non_incr::__rust_end_short_backtrace
  20:     0x7f5c417a8c12 - rustc_query_impl[f6c0eecf6401915]::query_impl::named_variable_map::invoke_provider_fn::__rust_begin_short_backtrace
  21:     0x7f5c417a8026 - rustc_query_impl[f6c0eecf6401915]::execution::try_execute_query::<rustc_data_structures[56fc8927348ab394]::vec_cache::VecCache<rustc_hir_id[9a89635926ddfe31]::OwnerId, rustc_middle[35b507296d99f42b]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[35b507296d99f42b]::dep_graph::graph::DepNodeIndex>, false>
  22:     0x7f5c417a7983 - rustc_query_impl[f6c0eecf6401915]::query_impl::named_variable_map::execute_query_non_incr::__rust_end_short_backtrace
  23:     0x7f5c41cbef3e - <dyn rustc_hir_analysis[920e2b21ee3cb3b1]::hir_ty_lowering::HirTyLowerer>::lower_ty
  24:     0x7f5c4193192d - <rustc_hir_typeck[253df1399b213f63]::fn_ctxt::FnCtxt>::resolve_ty_and_res_fully_qualified_call
  25:     0x7f5c41933eea - <rustc_hir_typeck[253df1399b213f63]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  26:     0x7f5c42d0ef99 - <rustc_hir_typeck[253df1399b213f63]::fn_ctxt::FnCtxt>::check_expr_asm
  27:     0x7f5c419383a3 - <rustc_hir_typeck[253df1399b213f63]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  28:     0x7f5c41c95838 - rustc_hir_typeck[253df1399b213f63]::typeck_with_inspect::{closure#0}
  29:     0x7f5c41c8c54c - rustc_query_impl[f6c0eecf6401915]::query_impl::typeck_root::invoke_provider_fn::__rust_begin_short_backtrace
  30:     0x7f5c418d2d66 - rustc_query_impl[f6c0eecf6401915]::execution::try_execute_query::<rustc_data_structures[56fc8927348ab394]::vec_cache::VecCache<rustc_span[1d2b36215d4b3a94]::def_id::LocalDefId, rustc_middle[35b507296d99f42b]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[35b507296d99f42b]::dep_graph::graph::DepNodeIndex>, false>
  31:     0x7f5c418d2643 - rustc_query_impl[f6c0eecf6401915]::query_impl::typeck_root::execute_query_non_incr::__rust_end_short_backtrace
  32:     0x7f5c418d9354 - <rustc_middle[35b507296d99f42b]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[920e2b21ee3cb3b1]::check_crate::{closure#1}>::{closure#0}
  33:     0x7f5c418d8d2a - rustc_hir_analysis[920e2b21ee3cb3b1]::check_crate
  34:     0x7f5c418d44a1 - rustc_interface[13b9c333f0edbd65]::passes::analysis
  35:     0x7f5c42774f89 - rustc_query_impl[f6c0eecf6401915]::execution::try_execute_query::<rustc_middle[35b507296d99f42b]::query::caches::SingleCache<rustc_middle[35b507296d99f42b]::query::erase::ErasedData<[u8; 0usize]>>, false>
  36:     0x7f5c42774c69 - rustc_query_impl[f6c0eecf6401915]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  37:     0x7f5c4279035b - rustc_interface[13b9c333f0edbd65]::interface::run_compiler::<(), rustc_driver_impl[4164e2e4872c99f5]::run_compiler::{closure#0}>::{closure#1}
  38:     0x7f5c42754cc0 - std[ad415756b38c0d3b]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[13b9c333f0edbd65]::util::run_in_thread_with_globals<rustc_interface[13b9c333f0edbd65]::util::run_in_thread_pool_with_globals<rustc_interface[13b9c333f0edbd65]::interface::run_compiler<(), rustc_driver_impl[4164e2e4872c99f5]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  39:     0x7f5c427553ad - <std[ad415756b38c0d3b]::thread::lifecycle::spawn_unchecked<rustc_interface[13b9c333f0edbd65]::util::run_in_thread_with_globals<rustc_interface[13b9c333f0edbd65]::util::run_in_thread_pool_with_globals<rustc_interface[13b9c333f0edbd65]::interface::run_compiler<(), rustc_driver_impl[4164e2e4872c99f5]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[3c43f6ff08284740]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  40:     0x7f5c427561ac - <std[ad415756b38c0d3b]::sys::thread::unix::Thread>::new::thread_start
  41:     0x7f5c3bc981b9 - <unknown>
  42:     0x7f5c3bd1d21c - <unknown>
  43:                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.97.0-nightly (60592ad7c 2026-05-19) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [resolve_bound_vars] resolving lifetimes for `fun::{global_asm#0}`
#1 [named_variable_map] looking up a named region inside `fun::{global_asm#0}`
#2 [typeck_root] type-checking `fun::{global_asm#0}`
#3 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0601`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-global-asmArea: `global_asm!`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.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions