ICE upvar_tys called before capture types are inferred
Open
Nobody has claimed this yet.
A-diagnostics
C-bug
I-ICE
needs-triage
P-medium
regression-untriaged
T-compiler
WG-trait-system-refactor
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
snippet:
fn main() {
Some([0]).map(|s| s[..]);
}
Version information
rustc 1.100.0-nightly (752b9bf87 2026-09-07)
binary: rustc
commit-hash: 752b9bf8798c2ffc1d3fe2b804c04454366fc6d6
commit-date: 2026-09-07
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.1
Possibly related line of code:
https://github.com/rust-lang/rust/blob/752b9bf8798c2ffc1d3fe2b804c04454366fc6d6/compiler/rustc_middle/src/ty/sty.rs#L194-L206
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
error[E0277]: the size for values of type `[{integer}]` cannot be known at compilation time
--> /tmp/icemaker_global_tempdir.y4oxhmSBkaRU/rustc_testrunner_tmpdir_reporting.4aRXUhCYUxEe/mvce.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
--> /tmp/icemaker_global_tempdir.y4oxhmSBkaRU/rustc_testrunner_tmpdir_reporting.4aRXUhCYUxEe/mvce.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' (2995014) panicked at /rustc-dev/752b9bf8798c2ffc1d3fe2b804c04454366fc6d6/compiler/rustc_middle/src/ty/sty.rs:200:33:
Box<dyn Any>
stack backtrace:
0: 0x7f6b7ead5b46 - <<std[7799338267317a1]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[feb819e0aab98535]::fmt::Display>::fmt
1: 0x7f6b7f2081cf - core[feb819e0aab98535]::fmt::write
2: 0x7f6b7eaeac0c - <std[7799338267317a1]::sys::stdio::unix::Stderr as core[feb819e0aab98535]::io::write::Write>::write_fmt
3: 0x7f6b7eaa83ea - std[7799338267317a1]::panicking::default_hook::{closure#0}
4: 0x7f6b7eac9e43 - std[7799338267317a1]::panicking::default_hook
5: 0x7f6b7da1338f - std[7799338267317a1]::panicking::update_hook::<alloc[eddc929262330b86]::boxed::Box<rustc_driver_impl[93e22c4ae85d6128]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x7f6b7eaca2e2 - std[7799338267317a1]::panicking::panic_with_hook
7: 0x7f6b7da41c44 - std[7799338267317a1]::panicking::begin_panic::<rustc_errors[ccb98f0a5bff281a]::ExplicitBug>::{closure#0}
8: 0x7f6b7da3a71e - std[7799338267317a1]::sys::backtrace::__rust_end_short_backtrace::<std[7799338267317a1]::panicking::begin_panic<rustc_errors[ccb98f0a5bff281a]::ExplicitBug>::{closure#0}, !>
9: 0x7f6b7da387be - std[7799338267317a1]::panicking::begin_panic::<rustc_errors[ccb98f0a5bff281a]::ExplicitBug>
10: 0x7f6b7da4d511 - <rustc_errors[ccb98f0a5bff281a]::diagnostic::BugAbort as rustc_errors[ccb98f0a5bff281a]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
11: 0x7f6b7dff4cb9 - rustc_middle[95f7c36db503aa5c]::util::bug::opt_span_bug_fmt::<rustc_span[aab65db9cf037f3]::span_encoding::Span>::{closure#0}
12: 0x7f6b7dff50f2 - 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: 0x7f6b7dfdfeb0 - 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: 0x7f6b7aca83d4 - rustc_middle[95f7c36db503aa5c]::util::bug::bug_fmt
15: 0x7f6b7e7e4b70 - <rustc_trait_selection[b2c49a93e168dccb]::error_reporting::TypeErrCtxt>::note_closure_capture::<rustc_span[aab65db9cf037f3]::ErrorGuaranteed>
16: 0x7f6b7e7f9e1f - <rustc_trait_selection[b2c49a93e168dccb]::error_reporting::TypeErrCtxt>::note_obligation_cause_code_inner::<rustc_span[aab65db9cf037f3]::ErrorGuaranteed, rustc_middle[95f7c36db503aa5c]::ty::predicate::Predicate>
17: 0x7f6b7e7e4c36 - <rustc_trait_selection[b2c49a93e168dccb]::error_reporting::TypeErrCtxt>::note_obligation_cause_code::<rustc_span[aab65db9cf037f3]::ErrorGuaranteed, rustc_middle[95f7c36db503aa5c]::ty::predicate::Predicate>
18: 0x7f6b7e8f1d1c - <rustc_trait_selection[b2c49a93e168dccb]::error_reporting::TypeErrCtxt>::note_obligation_cause
19: 0x7f6b7e8de797 - <rustc_trait_selection[b2c49a93e168dccb]::error_reporting::TypeErrCtxt>::report_selection_error
20: 0x7f6b7e905fc9 - <rustc_trait_selection[b2c49a93e168dccb]::error_reporting::TypeErrCtxt>::report_fulfillment_error
21: 0x7f6b7d298d3c - <rustc_trait_selection[b2c49a93e168dccb]::error_reporting::TypeErrCtxt>::report_fulfillment_errors
22: 0x7f6b7f2f3426 - <rustc_hir_typeck[74465e21f53f1374]::fn_ctxt::FnCtxt>::resolve_vars_with_obligations::<rustc_middle[95f7c36db503aa5c]::ty::Ty>
23: 0x7f6b7fd33cde - <rustc_hir_typeck[74465e21f53f1374]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
24: 0x7f6b7fd28105 - <rustc_hir_typeck[74465e21f53f1374]::fn_ctxt::FnCtxt>::check_expr_block
25: 0x7f6b7fd2f155 - <rustc_hir_typeck[74465e21f53f1374]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
26: 0x7f6b7fd13258 - rustc_hir_typeck[74465e21f53f1374]::check::check_fn
27: 0x7f6b8067a55b - rustc_hir_typeck[74465e21f53f1374]::typeck_with_inspect::{closure#0}
28: 0x7f6b80678b7a - rustc_query_impl[bdd1a1285068393]::query_vtables::typeck_root::invoke_provider_fn::__rust_begin_short_backtrace
29: 0x7f6b7f879535 - 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: 0x7f6b7f879167 - rustc_query_impl[bdd1a1285068393]::query_vtables::typeck_root::execute_query_non_incr::__rust_end_short_backtrace
31: 0x7f6b7f93566f - <rustc_middle[95f7c36db503aa5c]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis[3f6e10ab2280337c]::check_crate::{closure#1}>::{closure#0}
32: 0x7f6b7f93492e - rustc_hir_analysis[3f6e10ab2280337c]::check_crate
33: 0x7f6b7f87aaf3 - rustc_interface[1845d939591a8dca]::passes::analysis
34: 0x7f6b8049d7ca - rustc_query_impl[bdd1a1285068393]::execution::try_execute_query::<rustc_middle[95f7c36db503aa5c]::query::caches::SingleCache<rustc_middle[95f7c36db503aa5c]::query::erase::ErasedData<[u8; 0usize]>>, false>
35: 0x7f6b8049d56b - rustc_query_impl[bdd1a1285068393]::query_vtables::analysis::execute_query_non_incr::__rust_end_short_backtrace
36: 0x7f6b8054bb4c - rustc_interface[1845d939591a8dca]::interface::run_compiler::<(), rustc_driver_impl[93e22c4ae85d6128]::run_compiler::{closure#0}>::{closure#2}
37: 0x7f6b80628f42 - 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: 0x7f6b80628ced - <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: 0x7f6b80631607 - <std[7799338267317a1]::sys::thread::unix::Thread>::new::thread_start
40: 0x7f6b796980a2 - <unknown>
41: 0x7f6b7972080c - <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: 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 `mvce`
end of query stack
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0277`.
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
Run the supplied a.rs reproducer with the reported nightly and inspect compiler/rustc_middle/src/ty/sty.rs around upvar_tys. Trace the typeck_root path and rustc_trait_selection error-reporting path shown in the backtrace. Done means the example reports its type errors without triggering the internal compiler error.
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
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100