Repository navigation
ICE upvar_tys called before capture types are inferred #162440
Description
Activity
yesterday:
error[E0277]: the size for values of type `[{integer}]` cannot be known at compilation time
--> a.rs:2:15
|
2 | Some([0]).map(|s| s[..]);
| ^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[{integer}]`
note: required by an implicit `Sized` bound in `Option::<T>::map`
--> /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs:1160:22
|
1160 | pub const fn map<U, F>(self, f: F) -> Option<U>
| ^ required by the implicit `Sized` requirement on this type parameter in `Option::<T>::map`
error[E0277]: the size for values of type `[{integer}]` cannot be known at compilation time
--> a.rs:2:23
|
2 | Some([0]).map(|s| s[..]);
| ^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[{integer}]`
= note: the return type of a function must have a statically known size
error[E0277]: the size for values of type `[{integer}]` cannot be known at compilation time
--> a.rs:2:19
|
2 | Some([0]).map(|s| s[..]);
| --- ---^^^^^^
| | |
| | doesn't have a size known at compile-time
| | within this `{closure@a.rs:2:19: 2:22}`
| required by a bound introduced by this call
|
= help: within `{closure@a.rs:2:19: 2:22}`, the trait `Sized` is not implemented for `[{integer}]`
note: required because it's used within this closure
--> a.rs:2:19
|
2 | Some([0]).map(|s| s[..]);
| ^^^
note: required by a bound in `Option::<T>::map`
--> /home/matthias/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs:1162:12
|
1160 | pub const fn map<U, F>(self, f: F) -> Option<U>
| --- required by a bound in this associated function
1161 | where
1162 | F: [const] FnOnce(T) -> U + [const] Destruct,
| ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Option::<T>::map`
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0277`.
today:
error[E0277]: the size for values of type `[{integer}]` cannot be known at compilation time
--> a.rs:2:15
|
2 | Some([0]).map(|s| s[..]);
| ^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[{integer}]`
note: required by an implicit `Sized` bound in `Option::<T>::map`
--> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/option.rs:1160:22
|
1160 | pub const fn map<U, F>(self, f: F) -> Option<U>
| ^ required by the implicit `Sized` requirement on this type parameter in `Option::<T>::map`
error[E0277]: the size for values of type `[{integer}]` cannot be known at compilation time
--> a.rs:2:23
|
2 | Some([0]).map(|s| s[..]);
| ^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[{integer}]`
= note: the return type of a function must have a statically known size
error: internal compiler error: /rustc-dev/752b9bf8798c2ffc1d3fe2b804c04454366fc6d6/compiler/rustc_middle/src/ty/sty.rs:200:33: upvar_tys called before capture types are inferred
thread 'rustc' (2995917) panicked at /rustc-dev/752b9bf8798c2ffc1d3fe2b804c04454366fc6d6/compiler/rustc_middle/src/ty/sty.rs:200:33:
Box<dyn Any>
stack backtrace:
0: 0x7fd8440d5b46 - <<std[7799338267317a1]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[feb819e0aab98535]::fmt::Display>::fmt
1: 0x7fd8448081cf - core[feb819e0aab98535]::fmt::write
2: 0x7fd8440eac0c - <std[7799338267317a1]::sys::stdio::unix::Stderr as core[feb819e0aab98535]::io::write::Write>::write_fmt
3: 0x7fd8440a83ea - std[7799338267317a1]::panicking::default_hook::{closure#0}
4: 0x7fd8440c9e43 - std[7799338267317a1]::panicking::default_hook
5: 0x7fd84301338f - std[7799338267317a1]::panicking::update_hook::<alloc[eddc929262330b86]::boxed::Box<rustc_driver_impl[93e22c4ae85d6128]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x7fd8440ca2e2 - std[7799338267317a1]::panicking::panic_with_hook
7: 0x7fd843041c44 - std[7799338267317a1]::panicking::begin_panic::<rustc_errors[ccb98f0a5bff281a]::ExplicitBug>::{closure#0}
8: 0x7fd84303a71e - std[7799338267317a1]::sys::backtrace::__rust_end_short_backtrace::<std[7799338267317a1]::panicking::begin_panic<rustc_errors[ccb98f0a5bff281a]::ExplicitBug>::{closure#0}, !>
9: 0x7fd8430387be - std[7799338267317a1]::panicking::begin_panic::<rustc_errors[ccb98f0a5bff281a]::ExplicitBug>
10: 0x7fd84304d511 - <rustc_errors[ccb98f0a5bff281a]::diagnostic::BugAbort as rustc_errors[ccb98f0a5bff281a]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
11: 0x7fd8435f4cb9 - rustc_middle[95f7c36db503aa5c]::util::bug::opt_span_bug_fmt::<rustc_span[aab65db9cf037f3]::span_encoding::Span>::{closure#0}
12: 0x7fd8435f50f2 - rustc_middle[95f7c36db503aa5c]::ty::context::tls::with_opt::<rustc_middle[95f7c36db503aa5c]::util::bug::opt_span_bug_fmt<rustc_span[aab65db9cf037f3]::span_encoding::Span>::{closure#0}, !>::{closure#0}
13: 0x7fd8435dfeb0 - rustc_middle[95f7c36db503aa5c]::ty::context::tls::with_context_opt::<rustc_middle[95f7c36db503aa5c]::ty::context::tls::with_opt<rustc_middle[95f7c36db503aa5c]::util::bug::opt_span_bug_fmt<rustc_span[aab65db9cf037f3]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
14: 0x7fd8402a83d4 - rustc_middle[95f7c36db503aa5c]::util::bug::bug_fmt
15: 0x7fd843de4b70 - <rustc_trait_selection[b2c49a93e168dccb]::error_reporting::TypeErrCtxt>::note_closure_capture::<rustc_span[aab65db9cf037f3]::ErrorGuaranteed>
16: 0x7fd843df9e1f - <rustc_trait_selection[b2c49a93e168dccb]::error_reporting::TypeErrCtxt>::note_obligation_cause_code_inner::<rustc_span[aab65db9cf037f3]::ErrorGuaranteed, rustc_middle[95f7c36db503aa5c]::ty::predicate::Predicate>
17: 0x7fd843de4c36 - <rustc_trait_selection[b2c49a93e168dccb]::error_reporting::TypeErrCtxt>::note_obligation_cause_code::<rustc_span[aab65db9cf037f3]::ErrorGuaranteed, rustc_middle[95f7c36db503aa5c]::ty::predicate::Predicate>
18: 0x7fd843ef1d1c - <rustc_trait_selection[b2c49a93e168dccb]::error_reporting::TypeErrCtxt>::note_obligation_cause
19: 0x7fd843ede797 - <rustc_trait_selection[b2c49a93e168dccb]::error_reporting::TypeErrCtxt>::report_selection_error
20: 0x7fd843f05fc9 - <rustc_trait_selection[b2c49a93e168dccb]::error_reporting::TypeErrCtxt>::report_fulfillment_error
21: 0x7fd842898d3c - <rustc_trait_selection[b2c49a93e168dccb]::error_reporting::TypeErrCtxt>::report_fulfillment_errors
22: 0x7fd8448f3426 - <rustc_hir_typeck[74465e21f53f1374]::fn_ctxt::FnCtxt>::resolve_vars_with_obligations::<rustc_middle[95f7c36db503aa5c]::ty::Ty>
23: 0x7fd845333cde - <rustc_hir_typeck[74465e21f53f1374]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
24: 0x7fd845328105 - <rustc_hir_typeck[74465e21f53f1374]::fn_ctxt::FnCtxt>::check_expr_block
25: 0x7fd84532f155 - <rustc_hir_typeck[74465e21f53f1374]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
26: 0x7fd845313258 - rustc_hir_typeck[74465e21f53f1374]::check::check_fn
27: 0x7fd845c7a55b - rustc_hir_typeck[74465e21f53f1374]::typeck_with_inspect::{closure#0}
28: 0x7fd845c78b7a - rustc_query_impl[bdd1a1285068393]::query_vtables::typeck_root::invoke_provider_fn::__rust_begin_short_backtrace
29: 0x7fd844e79535 - rustc_query_impl[bdd1a1285068393]::execution::try_execute_query::<rustc_data_structures[b3e0016b95cb4620]::vec_cache::VecCache<rustc_span[aab65db9cf037f3]::def_id::LocalDefId, rustc_middle[95f7c36db503aa5c]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[95f7c36db503aa5c]::dep_graph::graph::DepNodeIndex>, false>
30: 0x7fd844e79167 - rustc_query_impl[bdd1a1285068393]::query_vtables::typeck_root::execute_query_non_incr::__rust_end_short_backtrace
31: 0x7fd844f3566f - <rustc_middle[95f7c36db503aa5c]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[3f6e10ab2280337c]::check_crate::{closure#1}>::{closure#0}
32: 0x7fd844f3492e - rustc_hir_analysis[3f6e10ab2280337c]::check_crate
33: 0x7fd844e7aaf3 - rustc_interface[1845d939591a8dca]::passes::analysis
34: 0x7fd845a9d7ca - rustc_query_impl[bdd1a1285068393]::execution::try_execute_query::<rustc_middle[95f7c36db503aa5c]::query::caches::SingleCache<rustc_middle[95f7c36db503aa5c]::query::erase::ErasedData<[u8; 0usize]>>, false>
35: 0x7fd845a9d56b - rustc_query_impl[bdd1a1285068393]::query_vtables::analysis::execute_query_non_incr::__rust_end_short_backtrace
36: 0x7fd845b4bb4c - rustc_interface[1845d939591a8dca]::interface::run_compiler::<(), rustc_driver_impl[93e22c4ae85d6128]::run_compiler::{closure#0}>::{closure#2}
37: 0x7fd845c28f42 - std[7799338267317a1]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[1845d939591a8dca]::util::run_in_thread_with_globals<rustc_interface[1845d939591a8dca]::util::run_in_thread_pool_with_globals<rustc_interface[1845d939591a8dca]::interface::run_compiler<(), rustc_driver_impl[93e22c4ae85d6128]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
38: 0x7fd845c28ced - <std[7799338267317a1]::thread::lifecycle::spawn_unchecked<rustc_interface[1845d939591a8dca]::util::run_in_thread_with_globals<rustc_interface[1845d939591a8dca]::util::run_in_thread_pool_with_globals<rustc_interface[1845d939591a8dca]::interface::run_compiler<(), rustc_driver_impl[93e22c4ae85d6128]::run_compiler::{closure#0}>::{closure#2}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[feb819e0aab98535]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
39: 0x7fd845c31607 - <std[7799338267317a1]::sys::thread::unix::Thread>::new::thread_start
40: 0x7fd83ec980a2 - <unknown>
41: 0x7fd83ed2080c - <unknown>
42: 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: please attach the file at `/tmp/upvar/rustc-ice-2026-09-07T17_23_13-2995915.txt` to your bug report
note: rustc 1.100.0-nightly (752b9bf87 2026-09-07) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [typeck_root] type-checking `main`
#1 [analysis] running analysis passes on crate `a`
end of query stack
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0277`.
my guess would be its related to #161624
Ooh its a next-solver thing! >.<
I was wondering how this could have passed in our testsuite without ICEing but we use coherence there :/
Another reproducer for this ICE, found by an automated compiler-testing
campaign; sharing in case it is a useful extra test case for #162595.
pub trait Sieve {
fn strain(&self, xs: &[u64], f: &dyn Fn(&u64) -> u64) -> &u64;
def_sieve!();
}
macro_rules! def_sieve {
() => {
fn sift(&self, xs: &[u64]) -> u64 {
let a = self.strain(xs, &|v: u64| v.wrapping_mul(127));
0
}
};
}
use def_sieve;
pub struct Pan(pub Vec<u64>);
impl Sieve for Pan {
fn strain(&self, xs: &[u64], f: &dyn Fn(&u64) -> u64) -> &u64 {
&self.0[0]
}
}
pub fn temper_fold(t: (u64, Option<u16>, Result<u32, u16>, &[u64])) -> u64 {
match t {
(a, None, Err(_), [x, ..]) => x,
(a, None | Some(_), Ok(_) | Err(_), rest @ ..) if rest.len() == 0 => 5,
_ => 0,
}
}Expected: the two pattern errors (rest @ is not allowed in a tuple,
.. patterns are not allowed here) and a clean rejection. Actual: additionally
error: internal compiler error: compiler/rustc_middle/src/ty/sty.rs:194:33:
upvar_tys called before capture types are inferred
with the same backtrace path as the original report
(note_closure_capture -> note_obligation_cause_code_inner ->
report_selection_error -> report_fulfillment_errors).
Versions tested:
- nightly-2026-09-07 (5a2be9f): this input is rejected cleanly (E0277
CoerceUnsized errors on the closures, no ICE). I did not test the
issue-body snippet on this toolchain; it is reported against a master
build of the same date (752b9bf) - nightly-2026-09-12 (0fc1413): ICE
- nightly-2026-09-18 (420ed2a): ICE (newest nightly I tested)
The reproducer combines two ingredients: a closure coerced to &dyn Fn
inside a macro-generated trait method, and the invalid tuple pattern
elsewhere in the crate. I did not isolate which ingredient drives error
reporting into note_closure_capture before capture types are inferred
(the issue-body snippet ICEs without any pattern error, so the closure
error path may be the driver here too). Happy to file this as a separate
issue if the trigger turns out to be distinct.
rustc_middle/src/ty/sty.rs:194:33 #163072 as a duplicate of this issue #163072 contains another code snippet triggering this, just in case
snippet:
Version information
Possibly related line of code:
rust/compiler/rustc_middle/src/ty/sty.rs
Lines 194 to 206 in 752b9bf
Command:
/home/matthias/.rustup/toolchains/master/bin/rustcProgram output