Skip to content

ICE Unexpected unnameable type in variance computation #148488

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: -Zincremental-verify-ich=yes -Cincremental=<dir> -Cdebuginfo=2 -Clink-dead-code=true -Zvalidate-mir -Zquery-dep-graph -Zthreads=4 --edition=2024
pub struct T<'g>()



pub fn ord<a>() -> _ {
    async || {
        
        
        
    }
}

original:

pub struct T<'g>()

pub fn g(val T) {}

pub fn ord<a>() -> _ {
    async || {
        use std::ptr::null;
        use std::task::{RawWaker, RawWakerVTable};
        RawWaker::new(
            null(),
            &RawWakerVTable::new(|_| todo!(), |_| (), |_| (), |_| ()),
        );
    }
}

Version information

rustc 1.93.0-nightly (e5efc3367 2025-11-04)
binary: rustc
commit-hash: e5efc336720901420a8891dcdb67ca0a475dc03c
commit-date: 2025-11-04
host: x86_64-unknown-linux-gnu
release: 1.93.0-nightly
LLVM version: 21.1.3

Possibly related line of code:

| ty::Never
| ty::Foreign(..) => {
// leaf type -- noop
}
ty::FnDef(..) | ty::Coroutine(..) | ty::Closure(..) | ty::CoroutineClosure(..) => {
bug!("Unexpected unnameable type in variance computation: {ty}");
}
ty::Ref(region, ty, mutbl) => {
self.add_constraints_from_region(current, region, variance);
self.add_constraints_from_mt(current, &ty::TypeAndMut { ty, mutbl }, variance);
}

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zincremental-verify-ich=yes -Cincremental=<dir> -Cdebuginfo=2 -Clink-dead-code=true -Zvalidate-mir -Zquery-dep-graph -Zthreads=4 --edition=2024

Program output

error: expected `;`, found keyword `pub`
 --> /tmp/icemaker_global_tempdir.gzW1Q91qvivC/rustc_testrunner_tmpdir_reporting.nmuBTsFqUqAM/mvce.rs:1:19
  |
1 | pub struct T<'g>()
  |                   ^ help: add `;` here
...
5 | pub fn ord<a>() -> _ {
  | --- unexpected token

warning: type parameter `a` should have an upper camel case name
 --> /tmp/icemaker_global_tempdir.gzW1Q91qvivC/rustc_testrunner_tmpdir_reporting.nmuBTsFqUqAM/mvce.rs:5:12
  |
5 | pub fn ord<a>() -> _ {
  |            ^ help: convert the identifier to upper camel case: `A`
  |
  = note: `#[warn(non_camel_case_types)]` (part of `#[warn(nonstandard_style)]`) on by default

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

error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types
 --> /tmp/icemaker_global_tempdir.gzW1Q91qvivC/rustc_testrunner_tmpdir_reporting.nmuBTsFqUqAM/mvce.rs:5:20
  |
5 | pub fn ord<a>() -> _ {
  |                    ^ not allowed in type signatures
  |
help: replace with the correct return type
  |
5 - pub fn ord<a>() -> _ {
5 + pub fn ord<a>() -> {async closure@/tmp/icemaker_global_tempdir.gzW1Q91qvivC/rustc_testrunner_tmpdir_reporting.nmuBTsFqUqAM/mvce.rs:6:5: 6:13} {
  |

error: internal compiler error: compiler/rustc_hir_analysis/src/variance/constraints.rs:240:17: Unexpected unnameable type in variance computation: {async closure@/tmp/icemaker_global_tempdir.gzW1Q91qvivC/rustc_testrunner_tmpdir_reporting.nmuBTsFqUqAM/mvce.rs:6:5: 6:13}


thread 'rustc' (1942480) panicked at compiler/rustc_hir_analysis/src/variance/constraints.rs:240:17:
Box<dyn Any>
stack backtrace:
   0:     0x7f5641054dc3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::ha3843b722cb6c079
   1:     0x7f5641801afc - core::fmt::write::h4cf6c21e30d6fd2c
   2:     0x7f5641009903 - std::io::Write::write_fmt::h4fff68ee9517b956
   3:     0x7f564101af42 - std::sys::backtrace::BacktraceLock::print::he78023a1ddfd64ff
   4:     0x7f5641020f99 - std::panicking::default_hook::{{closure}}::h687012e2f8493e05
   5:     0x7f5641020ac3 - std::panicking::default_hook::h49a3243e28fcd9d0
   6:     0x7f5640028c61 - std[e5386f4e1d083f30]::panicking::update_hook::<alloc[73bcea237dbcc3ca]::boxed::Box<rustc_driver_impl[738a289c0901248e]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7f56410213bf - std::panicking::panic_with_hook::hd8e4eb00c63c2672
   8:     0x7f5640065081 - std[e5386f4e1d083f30]::panicking::begin_panic::<rustc_errors[637030874c9f4630]::ExplicitBug>::{closure#0}
   9:     0x7f56400573f6 - std[e5386f4e1d083f30]::sys::backtrace::__rust_end_short_backtrace::<std[e5386f4e1d083f30]::panicking::begin_panic<rustc_errors[637030874c9f4630]::ExplicitBug>::{closure#0}, !>
  10:     0x7f5640057035 - std[e5386f4e1d083f30]::panicking::begin_panic::<rustc_errors[637030874c9f4630]::ExplicitBug>
  11:     0x7f5640076401 - <rustc_errors[637030874c9f4630]::diagnostic::BugAbort as rustc_errors[637030874c9f4630]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x7f56405fcb1a - rustc_middle[75169061f14a0aad]::util::bug::opt_span_bug_fmt::<rustc_span[7dee8b18e8817fc5]::span_encoding::Span>::{closure#0}
  13:     0x7f56405fcdfa - rustc_middle[75169061f14a0aad]::ty::context::tls::with_opt::<rustc_middle[75169061f14a0aad]::util::bug::opt_span_bug_fmt<rustc_span[7dee8b18e8817fc5]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7f56405edbfb - rustc_middle[75169061f14a0aad]::ty::context::tls::with_context_opt::<rustc_middle[75169061f14a0aad]::ty::context::tls::with_opt<rustc_middle[75169061f14a0aad]::util::bug::opt_span_bug_fmt<rustc_span[7dee8b18e8817fc5]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7f563e3425f0 - rustc_middle[75169061f14a0aad]::util::bug::bug_fmt
  16:     0x7f564225b950 - <rustc_hir_analysis[630917c900e5f64f]::variance::constraints::ConstraintContext>::add_constraints_from_ty
  17:     0x7f564225a579 - <rustc_hir_analysis[630917c900e5f64f]::variance::constraints::ConstraintContext>::build_constraints_for_item
  18:     0x7f563e813aed - rustc_hir_analysis[630917c900e5f64f]::variance::crate_variances
  19:     0x7f56427f9ce0 - rustc_query_impl[65b9d326d94058ea]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[65b9d326d94058ea]::query_impl::crate_variances::dynamic_query::{closure#2}::{closure#0}, rustc_middle[75169061f14a0aad]::query::erase::Erased<[u8; 8usize]>>
  20:     0x7f5642c17e2b - rustc_query_system[90325ef1b104597f]::query::plumbing::try_execute_query::<rustc_query_impl[65b9d326d94058ea]::DynamicConfig<rustc_query_system[90325ef1b104597f]::query::caches::SingleCache<rustc_middle[75169061f14a0aad]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[65b9d326d94058ea]::plumbing::QueryCtxt, true>
  21:     0x7f5642c18e85 - rustc_query_impl[65b9d326d94058ea]::query_impl::crate_variances::get_query_incr::__rust_end_short_backtrace
  22:     0x7f564193b10d - rustc_query_impl[65b9d326d94058ea]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[65b9d326d94058ea]::query_impl::variances_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[75169061f14a0aad]::query::erase::Erased<[u8; 16usize]>>
  23:     0x7f56422a2c96 - rustc_query_system[90325ef1b104597f]::query::plumbing::try_execute_query::<rustc_query_impl[65b9d326d94058ea]::DynamicConfig<rustc_query_system[90325ef1b104597f]::query::caches::DefIdCache<rustc_middle[75169061f14a0aad]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[65b9d326d94058ea]::plumbing::QueryCtxt, true>
  24:     0x7f56422a1988 - rustc_query_impl[65b9d326d94058ea]::query_impl::variances_of::get_query_incr::__rust_end_short_backtrace
  25:     0x7f5642220672 - rustc_hir_analysis[630917c900e5f64f]::check::wfcheck::check_variances_for_type_defn
  26:     0x7f5642089fae - rustc_hir_analysis[630917c900e5f64f]::check::check::check_item_type
  27:     0x7f564208469c - rustc_hir_analysis[630917c900e5f64f]::check::wfcheck::check_well_formed
  28:     0x7f5642084675 - rustc_query_impl[65b9d326d94058ea]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[65b9d326d94058ea]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[75169061f14a0aad]::query::erase::Erased<[u8; 1usize]>>
  29:     0x7f5641bc7aa1 - rustc_query_system[90325ef1b104597f]::query::plumbing::try_execute_query::<rustc_query_impl[65b9d326d94058ea]::DynamicConfig<rustc_data_structures[716369fb9beee067]::vec_cache::VecCache<rustc_span[7dee8b18e8817fc5]::def_id::LocalDefId, rustc_middle[75169061f14a0aad]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[90325ef1b104597f]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[65b9d326d94058ea]::plumbing::QueryCtxt, true>
  30:     0x7f5641bca26d - rustc_query_impl[65b9d326d94058ea]::query_impl::check_well_formed::get_query_incr::__rust_end_short_backtrace
  31:     0x7f56401490fb - rustc_middle[75169061f14a0aad]::query::inner::query_ensure_error_guaranteed::<rustc_data_structures[716369fb9beee067]::vec_cache::VecCache<rustc_span[7dee8b18e8817fc5]::def_id::LocalDefId, rustc_middle[75169061f14a0aad]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[90325ef1b104597f]::dep_graph::graph::DepNodeIndex>, ()>
  32:     0x7f564015645e - rustc_data_structures[716369fb9beee067]::sync::parallel::par_slice::par_rec::<&rustc_hir[71709be17c67fcbd]::hir::ItemId, rustc_data_structures[716369fb9beee067]::sync::parallel::try_par_for_each_in<&[rustc_hir[71709be17c67fcbd]::hir::ItemId], rustc_span[7dee8b18e8817fc5]::ErrorGuaranteed, <rustc_middle[75169061f14a0aad]::hir::ModuleItems>::par_items<rustc_hir_analysis[630917c900e5f64f]::check::wfcheck::check_type_wf::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}>
  33:     0x7f564018f617 - rustc_thread_pool[67e4e2991aa033df]::join::join_context::<rustc_thread_pool[67e4e2991aa033df]::join::join::call<(), rustc_data_structures[716369fb9beee067]::sync::parallel::par_slice::par_rec<&rustc_hir[71709be17c67fcbd]::hir::ItemId, rustc_data_structures[716369fb9beee067]::sync::parallel::try_par_for_each_in<&[rustc_hir[71709be17c67fcbd]::hir::ItemId], rustc_span[7dee8b18e8817fc5]::ErrorGuaranteed, <rustc_middle[75169061f14a0aad]::hir::ModuleItems>::par_items<rustc_hir_analysis[630917c900e5f64f]::check::wfcheck::check_type_wf::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}>::{closure#1}>::{closure#0}, rustc_thread_pool[67e4e2991aa033df]::join::join::call<(), rustc_data_structures[716369fb9beee067]::sync::parallel::par_slice::par_rec<&rustc_hir[71709be17c67fcbd]::hir::ItemId, rustc_data_structures[716369fb9beee067]::sync::parallel::try_par_for_each_in<&[rustc_hir[71709be17c67fcbd]::hir::ItemId], rustc_span[7dee8b18e8817fc5]::ErrorGuaranteed, <rustc_middle[75169061f14a0aad]::hir::ModuleItems>::par_items<rustc_hir_analysis[630917c900e5f64f]::check::wfcheck::check_type_wf::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}>::{closure#2}>::{closure#0}, (), ()>::{closure#0}
  34:     0x7f5640156505 - rustc_data_structures[716369fb9beee067]::sync::parallel::par_slice::par_rec::<&rustc_hir[71709be17c67fcbd]::hir::ItemId, rustc_data_structures[716369fb9beee067]::sync::parallel::try_par_for_each_in<&[rustc_hir[71709be17c67fcbd]::hir::ItemId], rustc_span[7dee8b18e8817fc5]::ErrorGuaranteed, <rustc_middle[75169061f14a0aad]::hir::ModuleItems>::par_items<rustc_hir_analysis[630917c900e5f64f]::check::wfcheck::check_type_wf::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}>
  35:     0x7f5640218757 - <rustc_thread_pool[67e4e2991aa033df]::job::StackJob<rustc_thread_pool[67e4e2991aa033df]::latch::SpinLatch, rustc_thread_pool[67e4e2991aa033df]::join::join_context<rustc_thread_pool[67e4e2991aa033df]::join::join::call<(), rustc_data_structures[716369fb9beee067]::sync::parallel::par_slice::par_rec<&rustc_hir[71709be17c67fcbd]::hir::ItemId, rustc_data_structures[716369fb9beee067]::sync::parallel::try_par_for_each_in<&[rustc_hir[71709be17c67fcbd]::hir::ItemId], rustc_span[7dee8b18e8817fc5]::ErrorGuaranteed, <rustc_middle[75169061f14a0aad]::hir::ModuleItems>::par_items<rustc_hir_analysis[630917c900e5f64f]::check::wfcheck::check_type_wf::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}>::{closure#1}>::{closure#0}, rustc_thread_pool[67e4e2991aa033df]::join::join::call<(), rustc_data_structures[716369fb9beee067]::sync::parallel::par_slice::par_rec<&rustc_hir[71709be17c67fcbd]::hir::ItemId, rustc_data_structures[716369fb9beee067]::sync::parallel::try_par_for_each_in<&[rustc_hir[71709be17c67fcbd]::hir::ItemId], rustc_span[7dee8b18e8817fc5]::ErrorGuaranteed, <rustc_middle[75169061f14a0aad]::hir::ModuleItems>::par_items<rustc_hir_analysis[630917c900e5f64f]::check::wfcheck::check_type_wf::{closure#0}>::{closure#0}>::{closure#0}::{closure#0}>::{closure#2}>::{closure#0}, (), ()>::{closure#0}::{closure#0}, ()> as rustc_thread_pool[67e4e2991aa033df]::job::Job>::execute
  36:     0x7f5640d2b53f - <rustc_thread_pool[67e4e2991aa033df]::registry::WorkerThread>::wait_or_steal_until_cold
  37:     0x7f5640d29e81 - <rustc_thread_pool[67e4e2991aa033df]::registry::ThreadBuilder>::run
  38:     0x7f5640020c8d - std[e5386f4e1d083f30]::sys::backtrace::__rust_begin_short_backtrace::<<rustc_thread_pool[67e4e2991aa033df]::ThreadPoolBuilder>::build_scoped<rustc_interface[bd0f1886b04bcc2f]::util::run_in_thread_pool_with_globals<rustc_interface[bd0f1886b04bcc2f]::interface::run_compiler<(), rustc_driver_impl[738a289c0901248e]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#0}, rustc_interface[bd0f1886b04bcc2f]::util::run_in_thread_pool_with_globals<rustc_interface[bd0f1886b04bcc2f]::interface::run_compiler<(), rustc_driver_impl[738a289c0901248e]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#1}, ()>::{closure#0}::{closure#0}::{closure#0}, ()>
  39:     0x7f564002bc52 - <<std[e5386f4e1d083f30]::thread::Builder>::spawn_unchecked_<<rustc_thread_pool[67e4e2991aa033df]::ThreadPoolBuilder>::build_scoped<rustc_interface[bd0f1886b04bcc2f]::util::run_in_thread_pool_with_globals<rustc_interface[bd0f1886b04bcc2f]::interface::run_compiler<(), rustc_driver_impl[738a289c0901248e]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#0}, rustc_interface[bd0f1886b04bcc2f]::util::run_in_thread_pool_with_globals<rustc_interface[bd0f1886b04bcc2f]::interface::run_compiler<(), rustc_driver_impl[738a289c0901248e]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#1}, ()>::{closure#0}::{closure#0}::{closure#0}, ()>::{closure#1} as core[74e9d517ffeea944]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  40:     0x7f564269fc6f - std::sys::thread::unix::Thread::new::thread_start::h7bfb9de84f244c7c
  41:     0x7f563c0969cb - <unknown>
  42:     0x7f563c11aa0c - <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.93.0-nightly (e5efc3367 2025-11-04) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z incremental-verify-ich=yes -C incremental=[REDACTED] -C debuginfo=2 -C link-dead-code=true -Z validate-mir -Z query-dep-graph -Z threads=4

query stack during panic:
#0 [crate_variances] computing the variances for items in this crate
#1 [variances_of] computing the variances of `T`
#2 [check_well_formed] checking that `T` is well-formed
#3 [check_type_wf] checking that types are well-formed
#4 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 4 previous errors; 1 warning emitted

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

Metadata

Metadata

Assignees

No one assigned

    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.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions