rust-lang / rust-lang/rust

[ICE]: `can't be put into typeck results`

Open
#159,704 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-non_lifetime_binders I-ICE needs-triage T-compiler WG-trait-system-refactor
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

auto-reduced (treereduce-rust):

//@compile-flags: -Znext-solver=globally
#![feature(non_lifetime_binders)]
fn trivial<A: ?Sized>()
where
    for<B> Fn(A, B): Fn(A, A) + 'static,
{
}

fn main() {
    trivial();
}

original:

#![feature(non_lifetime_binders)]
fn trivial<A: ?Sized>()
where
    for<B> Fn(A, B): Fn(A, A) +'static {}

fn main() {  trivial() ; }

Version information

rustc 1.99.0-nightly (b9ee8d8bc 2026-07-21)
binary: rustc
commit-hash: b9ee8d8bcb1e4c7905a183a37e6d984c4b9a8468
commit-date: 2026-07-21
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 22.1.8

Possibly related line of code:
https://github.com/rust-lang/rust/blob/b9ee8d8bcb1e4c7905a183a37e6d984c4b9a8468/compiler/rustc_hir_typeck/src/writeback.rs#L133-L145

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Znext-solver=globally

Program output

warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.Wpxb176pTay3/rustc_testrunner_tmpdir_reporting.K4nBQlqFjWXB/mvce.rs:1:12
  |
1 | #![feature(non_lifetime_binders)]
  |            ^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
  = note: `#[warn(incomplete_features)]` on by default

warning: trait objects without an explicit `dyn` are deprecated
 --> /tmp/icemaker_global_tempdir.Wpxb176pTay3/rustc_testrunner_tmpdir_reporting.K4nBQlqFjWXB/mvce.rs:4:12
  |
4 |     for<B> Fn(A, B): Fn(A, A) + 'static,
  |            ^^^^^^^^
  |
  = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
  = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/warnings-promoted-to-error.html>
  = note: `#[warn(bare_trait_objects)]` (part of `#[warn(rust_2021_compatibility)]`) on by default
help: if this is a dyn-compatible trait, use `dyn`
  |
4 |     for<B> dyn Fn(A, B): Fn(A, A) + 'static,
  |            +++

error[E0277]: the size for values of type `A` cannot be known at compilation time
  --> /tmp/icemaker_global_tempdir.Wpxb176pTay3/rustc_testrunner_tmpdir_reporting.K4nBQlqFjWXB/mvce.rs:4:22
   |
 2 | fn trivial<A: ?Sized>()
   |            - this type parameter needs to be `Sized`
 3 | where
 4 |     for<B> Fn(A, B): Fn(A, A) + 'static,
   |                      ^^^^^^^^ doesn't have a size known at compile-time
   |
   = note: required because it appears within the type `(A, A)`
note: required by an implicit `Sized` bound in `Fn`
  --> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/ops/function.rs:76:20
   |
76 | pub const trait Fn<Args: Tuple>: [const] FnMut<Args> {
   |                    ^^^^ required by the implicit `Sized` requirement on this type parameter in `Fn`
help: consider removing the `?Sized` bound to make the type parameter `Sized`
   |
 2 - fn trivial<A: ?Sized>()
 2 + fn trivial<A>()
   |

error[E0277]: the size for values of type `A` cannot be known at compilation time
 --> /tmp/icemaker_global_tempdir.Wpxb176pTay3/rustc_testrunner_tmpdir_reporting.K4nBQlqFjWXB/mvce.rs:4:33
  |
2 | fn trivial<A: ?Sized>()
  |            - this type parameter needs to be `Sized`
3 | where
4 |     for<B> Fn(A, B): Fn(A, A) + 'static,
  |                                 ^^^^^^^ doesn't have a size known at compile-time
  |
  = note: only the last element of a tuple may have a dynamically sized type
help: consider removing the `?Sized` bound to make the type parameter `Sized`
  |
2 - fn trivial<A: ?Sized>()
2 + fn trivial<A>()
  |

error[E0277]: expected an `Fn(B, B)` closure, found `(dyn Fn(B, B) + 'static)`
 --> /tmp/icemaker_global_tempdir.Wpxb176pTay3/rustc_testrunner_tmpdir_reporting.K4nBQlqFjWXB/mvce.rs:9:5
  |
9 |     trivial();
  |     ^^^^^^^^^ expected an `Fn(B, B)` closure, found `(dyn Fn(B, B) + 'static)`
  |
  = help: the trait `Fn(B, B)` is not implemented for `(dyn Fn(B, B) + 'static)`
note: required by a bound in `trivial`
 --> /tmp/icemaker_global_tempdir.Wpxb176pTay3/rustc_testrunner_tmpdir_reporting.K4nBQlqFjWXB/mvce.rs:4:22
  |
2 | fn trivial<A: ?Sized>()
  |    ------- required by a bound in this function
3 | where
4 |     for<B> Fn(A, B): Fn(A, A) + 'static,
  |                      ^^^^^^^^ required by this bound in `trivial`

error[E0277]: the size for values of type `B` cannot be known
 --> /tmp/icemaker_global_tempdir.Wpxb176pTay3/rustc_testrunner_tmpdir_reporting.K4nBQlqFjWXB/mvce.rs:9:5
  |
9 |     trivial();
  |     ^^^^^^^^^ doesn't have a known size
  |
  = help: the nightly-only, unstable trait `MetaSized` is not implemented for `B`
note: required by a bound in `trivial`
 --> /tmp/icemaker_global_tempdir.Wpxb176pTay3/rustc_testrunner_tmpdir_reporting.K4nBQlqFjWXB/mvce.rs:2:15
  |
2 | fn trivial<A: ?Sized>()
  |               ^^^^^^ required by this bound in `trivial`


thread 'rustc' (1132679) panicked at /rustc-dev/b9ee8d8bcb1e4c7905a183a37e6d984c4b9a8468/compiler/rustc_hir_typeck/src/writeback.rs:139:9:
fn() {trivial::<B>} can't be put into typeck results
stack backtrace:
   0:     0x7f6c80a29516 - <<std[e7e31dd881df98bb]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[c88a0a802f7ea8d1]::fmt::Display>::fmt
   1:     0x7f6c8100d912 - core[c88a0a802f7ea8d1]::fmt::write
   2:     0x7f6c80a3e66c - <std[e7e31dd881df98bb]::sys::stdio::unix::Stderr as core[c88a0a802f7ea8d1]::io::write::Write>::write_fmt
   3:     0x7f6c809fb14a - std[e7e31dd881df98bb]::panicking::default_hook::{closure#0}
   4:     0x7f6c80a1bbb3 - std[e7e31dd881df98bb]::panicking::default_hook
   5:     0x7f6c7f9a090b - std[e7e31dd881df98bb]::panicking::update_hook::<alloc[ec3dd5f39d329b4e]::boxed::Box<rustc_driver_impl[383cde084ff42635]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f6c80a1c052 - std[e7e31dd881df98bb]::panicking::panic_with_hook
   7:     0x7f6c809fb202 - std[e7e31dd881df98bb]::panicking::panic_handler::{closure#0}
   8:     0x7f6c809f2df9 - std[e7e31dd881df98bb]::sys::backtrace::__rust_end_short_backtrace::<std[e7e31dd881df98bb]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f6c809fcb5d - __rustc[db4185f8d0a68659]::rust_begin_unwind
  10:     0x7f6c7d58dd0c - core[c88a0a802f7ea8d1]::panicking::panic_fmt
  11:     0x7f6c81935a79 - <rustc_hir_typeck[f17462d0efe89a72]::writeback::WritebackCx>::visit_node_id
  12:     0x7f6c81922f04 - <rustc_hir_typeck[f17462d0efe89a72]::writeback::WritebackCx as rustc_hir[d1845a14e12e6fd2]::intravisit::Visitor>::visit_expr
  13:     0x7f6c81922fca - <rustc_hir_typeck[f17462d0efe89a72]::writeback::WritebackCx as rustc_hir[d1845a14e12e6fd2]::intravisit::Visitor>::visit_expr
  14:     0x7f6c81923033 - <rustc_hir_typeck[f17462d0efe89a72]::writeback::WritebackCx as rustc_hir[d1845a14e12e6fd2]::intravisit::Visitor>::visit_expr
  15:     0x7f6c819428bf - <rustc_hir_typeck[f17462d0efe89a72]::fn_ctxt::FnCtxt>::resolve_type_vars_in_body
  16:     0x7f6c822e13bc - rustc_hir_typeck[f17462d0efe89a72]::typeck_with_inspect::{closure#0}
  17:     0x7f6c822dd8b0 - rustc_query_impl[9a9b2dbab4aa42cf]::query_impl::typeck_root::invoke_provider_fn::__rust_begin_short_backtrace
  18:     0x7f6c816b4629 - rustc_query_impl[9a9b2dbab4aa42cf]::execution::try_execute_query::<rustc_data_structures[b573e1ebd6629dca]::vec_cache::VecCache<rustc_span[5e0315be33f6440b]::def_id::LocalDefId, rustc_middle[c436af0429e6724f]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[c436af0429e6724f]::dep_graph::graph::DepNodeIndex>, false>
  19:     0x7f6c816b4083 - rustc_query_impl[9a9b2dbab4aa42cf]::query_impl::typeck_root::execute_query_non_incr::__rust_end_short_backtrace
  20:     0x7f6c816b6f7e - rustc_hir_analysis[18680bb4726cf8e]::check_crate
  21:     0x7f6c816b0a4b - rustc_interface[1cdecb41dc13d5b0]::passes::analysis
  22:     0x7f6c8222c9c7 - rustc_query_impl[9a9b2dbab4aa42cf]::execution::try_execute_query::<rustc_middle[c436af0429e6724f]::query::caches::SingleCache<rustc_middle[c436af0429e6724f]::query::erase::ErasedData<[u8; 0usize]>>, false>
  23:     0x7f6c8222c6a9 - rustc_query_impl[9a9b2dbab4aa42cf]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  24:     0x7f6c82202ecd - rustc_interface[1cdecb41dc13d5b0]::interface::run_compiler::<(), rustc_driver_impl[383cde084ff42635]::run_compiler::{closure#0}>::{closure#2}
  25:     0x7f6c8223a8a4 - std[e7e31dd881df98bb]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[1cdecb41dc13d5b0]::util::run_in_thread_with_globals<rustc_interface[1cdecb41dc13d5b0]::util::run_in_thread_pool_with_globals<rustc_interface[1cdecb41dc13d5b0]::interface::run_compiler<(), rustc_driver_impl[383cde084ff42635]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  26:     0x7f6c8223a673 - <std[e7e31dd881df98bb]::thread::lifecycle::spawn_unchecked<rustc_interface[1cdecb41dc13d5b0]::util::run_in_thread_with_globals<rustc_interface[1cdecb41dc13d5b0]::util::run_in_thread_pool_with_globals<rustc_interface[1cdecb41dc13d5b0]::interface::run_compiler<(), rustc_driver_impl[383cde084ff42635]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[c88a0a802f7ea8d1]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  27:     0x7f6c8224547a - <std[e7e31dd881df98bb]::sys::thread::unix::Thread>::new::thread_start
  28:     0x7f6c7b897739 - <unknown>
  29:     0x7f6c7b91bedc - <unknown>
  30:                0x0 - <unknown>

error: the compiler unexpectedly panicked. This is a bug

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.99.0-nightly (b9ee8d8bc 2026-07-21) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z next-solver=globally -Z dump-mir-dir=dir

query stack during panic:
#0 [typeck_root] type-checking `main`
#1 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 4 previous errors; 2 warnings emitted

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

@rustbot label +F-non_lifetime_binders +WG-trait-system-refactor

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the reduced a.rs case with -Znext-solver=globally, then inspect compiler/rustc_hir_typeck/src/writeback.rs around lines 133-145. Trace how the failing type-check result reaches writeback and add coverage for this case. Done means rustc reports the existing type errors without panicking.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.