Open
Description
auto-reduced (treereduce-rust):
fn main() {
{
if let Some(elem) = _opt && [1, 2, 3][let _ = &&let Some(x) = Some(42)] = 1 {
true
}
}
}
original:
fn main() {
{
if let Some(elem) = _opt && [1, 2, 3][let _ = &&let Some(x) = Some(42)] = 1 {
//~^ ERROR expected expression, found `let` statement
//~| ERROR expected expression, found `let` statement
//~| ERROR expected expression, found `let` statement
true
}
}
}
Version information
rustc 1.88.0-nightly (891b85254 2025-05-07)
binary: rustc
commit-hash: 891b8525477f5c41a9e56d7b70d64b41e7c344e3
commit-date: 2025-05-07
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.4
Possibly related line of code:
rust/compiler/rustc_hir_typeck/src/gather_locals.rs
Lines 106 to 118 in 891b852
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
error: expected expression, found `let` statement
--> /tmp/icemaker_global_tempdir.mwMt6Xnoa9hc/rustc_testrunner_tmpdir_reporting.TbTrAB9xgptL/mvce.rs:3:47
|
3 | if let Some(elem) = _opt && [1, 2, 3][let _ = &&let Some(x) = Some(42)] = 1 {
| ^^^
|
= note: only supported directly in conditions of `if` and `while` expressions
error: expected expression, found `let` statement
--> /tmp/icemaker_global_tempdir.mwMt6Xnoa9hc/rustc_testrunner_tmpdir_reporting.TbTrAB9xgptL/mvce.rs:3:57
|
3 | if let Some(elem) = _opt && [1, 2, 3][let _ = &&let Some(x) = Some(42)] = 1 {
| ^^^
|
= note: only supported directly in conditions of `if` and `while` expressions
error: expected expression, found `let` statement
--> /tmp/icemaker_global_tempdir.mwMt6Xnoa9hc/rustc_testrunner_tmpdir_reporting.TbTrAB9xgptL/mvce.rs:3:12
|
3 | if let Some(elem) = _opt && [1, 2, 3][let _ = &&let Some(x) = Some(42)] = 1 {
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: only supported directly in conditions of `if` and `while` expressions
help: you might have meant to compare for equality
|
3 | if let Some(elem) = _opt && [1, 2, 3][let _ = &&let Some(x) = Some(42)] == 1 {
| +
error[E0425]: cannot find value `_opt` in this scope
--> /tmp/icemaker_global_tempdir.mwMt6Xnoa9hc/rustc_testrunner_tmpdir_reporting.TbTrAB9xgptL/mvce.rs:3:29
|
3 | if let Some(elem) = _opt && [1, 2, 3][let _ = &&let Some(x) = Some(42)] = 1 {
| ^^^^ not found in this scope
thread 'rustc' panicked at compiler/rustc_hir_typeck/src/gather_locals.rs:112:17:
assertion `left == right` failed
left: Some({type error})
right: None
stack backtrace:
0: 0x77de8b533193 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h1f5bd77e8994842a
1: 0x77de8bc05987 - core::fmt::write::h54a1365dc0c19120
2: 0x77de8cc931d1 - std::io::Write::write_fmt::hec65d58ad1b3e08d
3: 0x77de8b532ff2 - std::sys::backtrace::BacktraceLock::print::h88705ee6c0898d85
4: 0x77de8b536bea - std::panicking::default_hook::{{closure}}::hc7e4c70f00a3aad0
5: 0x77de8b53676f - std::panicking::default_hook::h5ae504b9e418a4ac
6: 0x77de8a573293 - std[81a80513e1f7641d]::panicking::update_hook::<alloc[83ab744ea63d5782]::boxed::Box<rustc_driver_impl[14512bce0d979cbb]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x77de8b537463 - std::panicking::rust_panic_with_hook::h4e169fb6ea407d80
8: 0x77de8b53715a - std::panicking::begin_panic_handler::{{closure}}::h7448704f30829c4f
9: 0x77de8b533659 - std::sys::backtrace::__rust_end_short_backtrace::hd4ac55b4cbb862ed
10: 0x77de8b536e1d - __rustc[4cefb7dd2f9576a0]::rust_begin_unwind
11: 0x77de87e806e0 - core::panicking::panic_fmt::h7ed3fb9d2eb1ebd4
12: 0x77de89ef7c2a - core::panicking::assert_failed_inner::h3a9e763d75052691
13: 0x77de8b26afb9 - core[3405403e8444849b]::panicking::assert_failed::<core[3405403e8444849b]::option::Option<rustc_middle[cb4d41ad3e6068de]::ty::Ty>, core[3405403e8444849b]::option::Option<rustc_middle[cb4d41ad3e6068de]::ty::Ty>>
14: 0x77de8c9e91d9 - <rustc_hir_typeck[1229b2d558f1a4a6]::gather_locals::GatherLocalsVisitor>::declare
15: 0x77de8c905de1 - <rustc_hir_typeck[1229b2d558f1a4a6]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
16: 0x77de8c904b27 - <rustc_hir_typeck[1229b2d558f1a4a6]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
17: 0x77de8c916ad9 - <rustc_hir_typeck[1229b2d558f1a4a6]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
18: 0x77de8c902ce7 - <rustc_hir_typeck[1229b2d558f1a4a6]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
19: 0x77de8c8fa723 - <rustc_hir_typeck[1229b2d558f1a4a6]::fn_ctxt::FnCtxt>::check_expr_if
20: 0x77de8c902cba - <rustc_hir_typeck[1229b2d558f1a4a6]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
21: 0x77de88334e80 - <rustc_hir_typeck[1229b2d558f1a4a6]::fn_ctxt::FnCtxt>::check_expr_block
22: 0x77de8c900b37 - <rustc_hir_typeck[1229b2d558f1a4a6]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
23: 0x77de88334e80 - <rustc_hir_typeck[1229b2d558f1a4a6]::fn_ctxt::FnCtxt>::check_expr_block
24: 0x77de8c900b37 - <rustc_hir_typeck[1229b2d558f1a4a6]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
25: 0x77de8bf5ede5 - rustc_hir_typeck[1229b2d558f1a4a6]::check::check_fn
26: 0x77de8bf4a61c - rustc_hir_typeck[1229b2d558f1a4a6]::typeck_with_inspect::{closure#0}
27: 0x77de8bf492f6 - rustc_query_impl[6d88979acc822765]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6d88979acc822765]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cb4d41ad3e6068de]::query::erase::Erased<[u8; 8usize]>>
28: 0x77de8be61426 - rustc_query_system[52977e3efba6b25c]::query::plumbing::try_execute_query::<rustc_query_impl[6d88979acc822765]::DynamicConfig<rustc_data_structures[c6bb50e2f541850f]::vec_cache::VecCache<rustc_span[839c9191707af2b6]::def_id::LocalDefId, rustc_middle[cb4d41ad3e6068de]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[52977e3efba6b25c]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[6d88979acc822765]::plumbing::QueryCtxt, false>
29: 0x77de8be60e92 - rustc_query_impl[6d88979acc822765]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
30: 0x77de8be5f8cc - rustc_hir_analysis[97b2e84666df7cb9]::check_crate
31: 0x77de8c11ce37 - rustc_interface[ce8d3fcf0ace95b6]::passes::run_required_analyses
32: 0x77de8cb9655e - rustc_interface[ce8d3fcf0ace95b6]::passes::analysis
33: 0x77de8cb96535 - rustc_query_impl[6d88979acc822765]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[6d88979acc822765]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[cb4d41ad3e6068de]::query::erase::Erased<[u8; 0usize]>>
34: 0x77de8cb4bbfa - rustc_query_system[52977e3efba6b25c]::query::plumbing::try_execute_query::<rustc_query_impl[6d88979acc822765]::DynamicConfig<rustc_query_system[52977e3efba6b25c]::query::caches::SingleCache<rustc_middle[cb4d41ad3e6068de]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[6d88979acc822765]::plumbing::QueryCtxt, false>
35: 0x77de8cb4b8cf - rustc_query_impl[6d88979acc822765]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
36: 0x77de8ceba087 - rustc_interface[ce8d3fcf0ace95b6]::passes::create_and_enter_global_ctxt::<core[3405403e8444849b]::option::Option<rustc_interface[ce8d3fcf0ace95b6]::queries::Linker>, rustc_driver_impl[14512bce0d979cbb]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
37: 0x77de8ccd2f26 - rustc_interface[ce8d3fcf0ace95b6]::interface::run_compiler::<(), rustc_driver_impl[14512bce0d979cbb]::run_compiler::{closure#0}>::{closure#1}
38: 0x77de8cc8a5fe - std[81a80513e1f7641d]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[ce8d3fcf0ace95b6]::util::run_in_thread_with_globals<rustc_interface[ce8d3fcf0ace95b6]::util::run_in_thread_pool_with_globals<rustc_interface[ce8d3fcf0ace95b6]::interface::run_compiler<(), rustc_driver_impl[14512bce0d979cbb]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
39: 0x77de8cc8aa74 - <<std[81a80513e1f7641d]::thread::Builder>::spawn_unchecked_<rustc_interface[ce8d3fcf0ace95b6]::util::run_in_thread_with_globals<rustc_interface[ce8d3fcf0ace95b6]::util::run_in_thread_pool_with_globals<rustc_interface[ce8d3fcf0ace95b6]::interface::run_compiler<(), rustc_driver_impl[14512bce0d979cbb]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[3405403e8444849b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
40: 0x77de8cc8be6b - std::sys::pal::unix::thread::Thread::new::thread_start::h8118e848ae38800b
41: 0x77de86aa370a - <unknown>
42: 0x77de86b27aac - <unknown>
43: 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.88.0-nightly (891b85254 2025-05-07) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0425`.