[ICE]: Unexpected type {type error} for `Field` projection
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
auto-reduced (treereduce-rust):
//@compile-flags: --edition=2021 -Zprint-type-sizes
fn bop() {
fold(run(), |foo: Foo<_>| async { foo.bar })
}
fn fold<Fut, F, U>(_: Foo<U>, f: F) {}
struct Foo<F> {
bar: (), // Vec<F>
}
fn run() -> Foo<()> {
todo!()
}
original:
fn bop() {
fold(run(), |foo: Foo<_>| async { foo.bar })
}
fn fold<Fut, F, U>(_: Foo<U>, f: F)
where
F: FnMut(Foo<U>) -> Fut,
{
}
struct Foo<F> {
bar: (), // Vec<F>
}
fn run() -> Foo<()> {
todo!()
}
fn main() {}
Version information
rustc 1.96.0-nightly (c3bd6289f 2026-04-07)
binary: rustc
commit-hash: c3bd6289f65fa7210c50bdeeb0ed4541caa33d2d
commit-date: 2026-04-07
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.2
Possibly related line of code:
https://github.com/rust-lang/rust/blob/c3bd6289f65fa7210c50bdeeb0ed4541caa33d2d/compiler/rustc_middle/src/ty/closure.rs#L110-L122
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc --edition=2021 -Zprint-type-sizes
Program output
error[E0601]: `main` function not found in crate `mvce`
--> /tmp/icemaker_global_tempdir.pogdqn6QOkB7/rustc_testrunner_tmpdir_reporting.Lry8SoRR7rGu/mvce.rs:10:2
|
10 | }
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.pogdqn6QOkB7/rustc_testrunner_tmpdir_reporting.Lry8SoRR7rGu/mvce.rs`
error[E0392]: type parameter `F` is never used
--> /tmp/icemaker_global_tempdir.pogdqn6QOkB7/rustc_testrunner_tmpdir_reporting.Lry8SoRR7rGu/mvce.rs:5:12
|
5 | struct Foo<F> {
| ^ unused type parameter
|
= help: consider removing `F`, referring to it in a field, or using a marker such as `PhantomData`
= help: if you intended `F` to be a const parameter, use `const F: /* Type */` instead
error[E0282]: type annotations needed
--> /tmp/icemaker_global_tempdir.pogdqn6QOkB7/rustc_testrunner_tmpdir_reporting.Lry8SoRR7rGu/mvce.rs:2:5
|
2 | fold(run(), |foo: Foo<_>| async { foo.bar })
| ^^^^ cannot infer type of the type parameter `Fut` declared on the function `fold`
|
help: consider specifying the generic arguments
|
2 | fold::<Fut, _, U>(run(), |foo: Foo<_>| async { foo.bar })
| +++++++++++++
error: internal compiler error: /rustc-dev/c3bd6289f65fa7210c50bdeeb0ed4541caa33d2d/compiler/rustc_middle/src/ty/closure.rs:116:25: Unexpected type {type error} for `Field` projection
thread 'rustc' (2407364) panicked at /rustc-dev/c3bd6289f65fa7210c50bdeeb0ed4541caa33d2d/compiler/rustc_middle/src/ty/closure.rs:116:25:
Box<dyn Any>
stack backtrace:
0: 0x7efec4bde69b - <<std[12a3dcb3f67af163]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[84cabc7109d7a8ea]::fmt::Display>::fmt
1: 0x7efec521e548 - core[84cabc7109d7a8ea]::fmt::write
2: 0x7efec4bf5966 - <std[12a3dcb3f67af163]::sys::stdio::unix::Stderr as std[12a3dcb3f67af163]::io::Write>::write_fmt
3: 0x7efec4bb4998 - std[12a3dcb3f67af163]::panicking::default_hook::{closure#0}
4: 0x7efec4bd1d03 - std[12a3dcb3f67af163]::panicking::default_hook
5: 0x7efec3bd7a8c - std[12a3dcb3f67af163]::panicking::update_hook::<alloc[d34ce8513ce20d35]::boxed::Box<rustc_driver_impl[68e4f83b29a5fde8]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x7efec4bd1fe2 - std[12a3dcb3f67af163]::panicking::panic_with_hook
7: 0x7efec3c07aa1 - std[12a3dcb3f67af163]::panicking::begin_panic::<rustc_errors[426e3927eadecb44]::ExplicitBug>::{closure#0}
8: 0x7efec3c00506 - std[12a3dcb3f67af163]::sys::backtrace::__rust_end_short_backtrace::<std[12a3dcb3f67af163]::panicking::begin_panic<rustc_errors[426e3927eadecb44]::ExplicitBug>::{closure#0}, !>
9: 0x7efec3bfe308 - std[12a3dcb3f67af163]::panicking::begin_panic::<rustc_errors[426e3927eadecb44]::ExplicitBug>
10: 0x7efec3c130e1 - <rustc_errors[426e3927eadecb44]::diagnostic::BugAbort as rustc_errors[426e3927eadecb44]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
11: 0x7efec41ef919 - rustc_middle[be228d222be6ee40]::util::bug::opt_span_bug_fmt::<rustc_span[2f98085627d930bd]::span_encoding::Span>::{closure#0}
12: 0x7efec41efaa2 - rustc_middle[be228d222be6ee40]::ty::context::tls::with_opt::<rustc_middle[be228d222be6ee40]::util::bug::opt_span_bug_fmt<rustc_span[2f98085627d930bd]::span_encoding::Span>::{closure#0}, !>::{closure#0}
13: 0x7efec41e053b - rustc_middle[be228d222be6ee40]::ty::context::tls::with_context_opt::<rustc_middle[be228d222be6ee40]::ty::context::tls::with_opt<rustc_middle[be228d222be6ee40]::util::bug::opt_span_bug_fmt<rustc_span[2f98085627d930bd]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
14: 0x7efec1310634 - rustc_middle[be228d222be6ee40]::util::bug::bug_fmt
15: 0x7efec5aab1c9 - <rustc_middle[be228d222be6ee40]::ty::closure::CapturedPlace>::to_symbol
16: 0x7efec61c6430 - rustc_query_impl[fd3cc5250c15dd02]::query_impl::closure_saved_names_of_captured_variables::invoke_provider_fn::__rust_begin_short_backtrace
17: 0x7efec525fdca - rustc_query_impl[fd3cc5250c15dd02]::execution::try_execute_query::<rustc_middle[be228d222be6ee40]::query::caches::DefIdCache<rustc_middle[be228d222be6ee40]::query::erase::ErasedData<[u8; 8usize]>>, false>
18: 0x7efec5b3338e - rustc_query_impl[fd3cc5250c15dd02]::query_impl::closure_saved_names_of_captured_variables::execute_query_non_incr::__rust_end_short_backtrace
19: 0x7efec5bcbd63 - rustc_ty_utils[ffead04fb038f19b]::layout::layout_of
20: 0x7efec5bcb8d1 - rustc_query_impl[fd3cc5250c15dd02]::query_impl::layout_of::invoke_provider_fn::__rust_begin_short_backtrace
21: 0x7efec5bca7c7 - rustc_query_impl[fd3cc5250c15dd02]::execution::try_execute_query::<rustc_middle[be228d222be6ee40]::query::caches::DefaultCache<rustc_middle[be228d222be6ee40]::ty::PseudoCanonicalInput<rustc_middle[be228d222be6ee40]::ty::Ty>, rustc_middle[be228d222be6ee40]::query::erase::ErasedData<[u8; 16usize]>>, false>
22: 0x7efec5bca41e - rustc_query_impl[fd3cc5250c15dd02]::query_impl::layout_of::execute_query_non_incr::__rust_end_short_backtrace
23: 0x7efec52bb8fb - <rustc_middle[be228d222be6ee40]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[8f905f4a8999be7]::passes::run_required_analyses::{closure#2}::{closure#0}>::{closure#0}
24: 0x7efec52ba1fc - rustc_interface[8f905f4a8999be7]::passes::analysis
25: 0x7efec6447a49 - rustc_query_impl[fd3cc5250c15dd02]::execution::try_execute_query::<rustc_middle[be228d222be6ee40]::query::caches::SingleCache<rustc_middle[be228d222be6ee40]::query::erase::ErasedData<[u8; 0usize]>>, false>
26: 0x7efec6447729 - rustc_query_impl[fd3cc5250c15dd02]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
27: 0x7efec645e41e - rustc_interface[8f905f4a8999be7]::interface::run_compiler::<(), rustc_driver_impl[68e4f83b29a5fde8]::run_compiler::{closure#0}>::{closure#1}
28: 0x7efec6415dfe - std[12a3dcb3f67af163]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[8f905f4a8999be7]::util::run_in_thread_with_globals<rustc_interface[8f905f4a8999be7]::util::run_in_thread_pool_with_globals<rustc_interface[8f905f4a8999be7]::interface::run_compiler<(), rustc_driver_impl[68e4f83b29a5fde8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
29: 0x7efec64166a0 - <std[12a3dcb3f67af163]::thread::lifecycle::spawn_unchecked<rustc_interface[8f905f4a8999be7]::util::run_in_thread_with_globals<rustc_interface[8f905f4a8999be7]::util::run_in_thread_pool_with_globals<rustc_interface[8f905f4a8999be7]::interface::run_compiler<(), rustc_driver_impl[68e4f83b29a5fde8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[84cabc7109d7a8ea]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
30: 0x7efec64175ac - <std[12a3dcb3f67af163]::sys::thread::unix::Thread>::new::thread_start
31: 0x7efebfea097a - <unknown>
32: 0x7efebff242bc - <unknown>
33: 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.96.0-nightly (c3bd6289f 2026-04-07) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z print-type-sizes -Z dump-mir-dir=dir
query stack during panic:
#0 [closure_saved_names_of_captured_variables] computing debuginfo for closure `bop::{closure#0}::{closure#0}`
#1 [layout_of] computing layout of `{async block@/tmp/icemaker_global_tempdir.pogdqn6QOkB7/rustc_testrunner_tmpdir_reporting.Lry8SoRR7rGu/mvce.rs:2:31: 2:36}`
#2 [analysis] running analysis passes on crate `mvce`
end of query stack
warning: unused variable: `f`
--> /tmp/icemaker_global_tempdir.pogdqn6QOkB7/rustc_testrunner_tmpdir_reporting.Lry8SoRR7rGu/mvce.rs:4:31
|
4 | fn fold<Fut, F, U>(_: Foo<U>, f: F) {}
| ^ help: if this is intentional, prefix it with an underscore: `_f`
|
= note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default
error: aborting due to 4 previous errors; 1 warning emitted
Some errors have detailed explanations: E0282, E0392, E0601.
For more information about an error, try `rustc --explain E0282`.
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 with compiler/rustc_middle/src/ty/closure.rs around lines 110-122 and reproduce the ICE using the reduced Rust program with -Zprint-type-sizes. Trace how the closure_saved_names_of_captured_variables query handles the Field projection, then verify the reduced case no longer panics and is covered by an appropriate compiler regression test.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100