Skip to content

ICE: gather_locals #140730

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
matthiaskrgr opened this issue May 7, 2025 · 4 comments · Fixed by #140827
Closed

ICE: gather_locals #140730

matthiaskrgr opened this issue May 7, 2025 · 4 comments · Fixed by #140827
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

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:

fn assign(&mut self, span: Span, nid: HirId, ty_opt: Option<Ty<'tcx>>) -> Ty<'tcx> {
match ty_opt {
None => {
// Infer the variable's type.
let var_ty = self.fcx.next_ty_var(span);
assert_eq!(self.fcx.locals.borrow_mut().insert(nid, var_ty), None);
var_ty
}
Some(typ) => {
// Take type that the user specified.
assert_eq!(self.fcx.locals.borrow_mut().insert(nid, typ), None);
typ

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`.

@matthiaskrgr matthiaskrgr added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels May 7, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 7, 2025
@matthiaskrgr
Copy link
Member Author

smaller

fn main {
  if true && let c = c = 1 {}
}

@matthiaskrgr
Copy link
Member Author

#140561 cc @compiler-errors

@matthiaskrgr
Copy link
Member Author

fn f() {
    let mut x: Vec<()> = Vec::new() | x | {
        || {
            let x: MakeFooFn = make_foo as MakeFooFn;
        }
    };
}
fn main() {
  Vec:new | {
    let b :   c
  }
}

For the other assert

@compiler-errors compiler-errors self-assigned this May 7, 2025
@matthiaskrgr
Copy link
Member Author

another fun one

fn main() {
    let x = Box::new(Some(Some(Some(Some("")))));
    assert_eq!(0, *x + { drop(x); let _ = Box::new(main); 0 });
}

thread 'rustc' panicked at compiler/rustc_hir_typeck/src/gather_locals.rs:112:17:
assertion `left == right` failed
  left: Some(?13t)
 right: None
stack backtrace:
   0:     0x799c1292adb3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h49add6602009883c
   1:     0x799c13005987 - core::fmt::write::h2b8bafb760aedb33
   2:     0x799c1405ed51 - std::io::Write::write_fmt::ha8b80ee893d079cf
   3:     0x799c1292ac12 - std::sys::backtrace::BacktraceLock::print::hadbbabeac5dd5672
   4:     0x799c1292e80a - std::panicking::default_hook::{{closure}}::ha7627b2e1192d33c
   5:     0x799c1292e38f - std::panicking::default_hook::h2f275c3e1f15d3b8
   6:     0x799c1196c9f3 - std[ce8ccf77ffb023bf]::panicking::update_hook::<alloc[b6746bf1a130dcae]::boxed::Box<rustc_driver_impl[56fd1ef501a43154]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x799c1292f083 - std::panicking::rust_panic_with_hook::h7a5ac864f0ff33c8
   8:     0x799c1292ed7a - std::panicking::begin_panic_handler::{{closure}}::h0dc8b96251fd771a
   9:     0x799c1292b279 - std::sys::backtrace::__rust_end_short_backtrace::h57fb7450f73ac317
  10:     0x799c1292ea3d - __rustc[f04850fc019d6c8f]::rust_begin_unwind
  11:     0x799c0f27f560 - core::panicking::panic_fmt::h87fef3678568c0b5
  12:     0x799c112f0aaa - core::panicking::assert_failed_inner::h3639427f49d7a068
  13:     0x799c12665149 - core[380bbaee9f56bd6b]::panicking::assert_failed::<core[380bbaee9f56bd6b]::option::Option<rustc_middle[3c56263abe6b39ea]::ty::Ty>, core[380bbaee9f56bd6b]::option::Option<rustc_middle[3c56263abe6b39ea]::ty::Ty>>
  14:     0x799c13940083 - <rustc_hir_typeck[58f004e5b06cbd80]::gather_locals::GatherLocalsVisitor>::declare
  15:     0x799c0f734342 - <rustc_hir_typeck[58f004e5b06cbd80]::fn_ctxt::FnCtxt>::check_expr_block
  16:     0x799c13e40f0e - <rustc_hir_typeck[58f004e5b06cbd80]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  17:     0x799c13286f04 - <rustc_hir_typeck[58f004e5b06cbd80]::fn_ctxt::FnCtxt>::check_overloaded_binop
  18:     0x799c13e428f4 - <rustc_hir_typeck[58f004e5b06cbd80]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  19:     0x799c13e416d5 - <rustc_hir_typeck[58f004e5b06cbd80]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  20:     0x799c13e46385 - <rustc_hir_typeck[58f004e5b06cbd80]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  21:     0x799c13e42443 - <rustc_hir_typeck[58f004e5b06cbd80]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  22:     0x799c0f7341e3 - <rustc_hir_typeck[58f004e5b06cbd80]::fn_ctxt::FnCtxt>::check_expr_block
  23:     0x799c13e40f0e - <rustc_hir_typeck[58f004e5b06cbd80]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  24:     0x799c136583e5 - rustc_hir_typeck[58f004e5b06cbd80]::check::check_fn
  25:     0x799c13643e4b - rustc_hir_typeck[58f004e5b06cbd80]::typeck_with_inspect::{closure#0}
  26:     0x799c13642b36 - rustc_query_impl[831cfaf2ee55e692]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[831cfaf2ee55e692]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3c56263abe6b39ea]::query::erase::Erased<[u8; 8usize]>>
  27:     0x799c132de866 - rustc_query_system[fd4cfdcfbd5ee71f]::query::plumbing::try_execute_query::<rustc_query_impl[831cfaf2ee55e692]::DynamicConfig<rustc_data_structures[6dfce788614e05b9]::vec_cache::VecCache<rustc_span[39b72d7c522ce93c]::def_id::LocalDefId, rustc_middle[3c56263abe6b39ea]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[fd4cfdcfbd5ee71f]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[831cfaf2ee55e692]::plumbing::QueryCtxt, false>
  28:     0x799c132de2d2 - rustc_query_impl[831cfaf2ee55e692]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  29:     0x799c132dcd1e - rustc_hir_analysis[a1f9f0d5967b6f8b]::check_crate
  30:     0x799c134753f7 - rustc_interface[8bf1101b7dd5e9b7]::passes::run_required_analyses
  31:     0x799c13fe99de - rustc_interface[8bf1101b7dd5e9b7]::passes::analysis
  32:     0x799c13fe99b5 - rustc_query_impl[831cfaf2ee55e692]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[831cfaf2ee55e692]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3c56263abe6b39ea]::query::erase::Erased<[u8; 0usize]>>
  33:     0x799c13f74f3a - rustc_query_system[fd4cfdcfbd5ee71f]::query::plumbing::try_execute_query::<rustc_query_impl[831cfaf2ee55e692]::DynamicConfig<rustc_query_system[fd4cfdcfbd5ee71f]::query::caches::SingleCache<rustc_middle[3c56263abe6b39ea]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[831cfaf2ee55e692]::plumbing::QueryCtxt, false>
  34:     0x799c13f74c0f - rustc_query_impl[831cfaf2ee55e692]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  35:     0x799c141a5987 - rustc_interface[8bf1101b7dd5e9b7]::passes::create_and_enter_global_ctxt::<core[380bbaee9f56bd6b]::option::Option<rustc_interface[8bf1101b7dd5e9b7]::queries::Linker>, rustc_driver_impl[56fd1ef501a43154]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  36:     0x799c14094766 - rustc_interface[8bf1101b7dd5e9b7]::interface::run_compiler::<(), rustc_driver_impl[56fd1ef501a43154]::run_compiler::{closure#0}>::{closure#1}
  37:     0x799c140588fe - std[ce8ccf77ffb023bf]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[8bf1101b7dd5e9b7]::util::run_in_thread_with_globals<rustc_interface[8bf1101b7dd5e9b7]::util::run_in_thread_pool_with_globals<rustc_interface[8bf1101b7dd5e9b7]::interface::run_compiler<(), rustc_driver_impl[56fd1ef501a43154]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  38:     0x799c14058d74 - <<std[ce8ccf77ffb023bf]::thread::Builder>::spawn_unchecked_<rustc_interface[8bf1101b7dd5e9b7]::util::run_in_thread_with_globals<rustc_interface[8bf1101b7dd5e9b7]::util::run_in_thread_pool_with_globals<rustc_interface[8bf1101b7dd5e9b7]::interface::run_compiler<(), rustc_driver_impl[56fd1ef501a43154]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[380bbaee9f56bd6b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  39:     0x799c1405a16b - std::sys::pal::unix::thread::Thread::new::thread_start::h4984952b7bb83f95
  40:     0x799c0dea370a - <unknown>
  41:     0x799c0df27aac - <unknown>
  42:                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: please attach the file at `/tmp/im/rustc-ice-2025-05-07T15_09_29-561781.txt` to your bug report

query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: this path really should be doomed...
 --> a.rs:3:22
  |
3 |     assert_eq!(0, *x + { drop(x); let _ = Box::new(main); 0 });
  |                      ^
  |
note: delayed at compiler/rustc_hir_typeck/src/op.rs:1003:28 - disabled backtrace
 --> a.rs:3:22
  |
3 |     assert_eq!(0, *x + { drop(x); let _ = Box::new(main); 0 });
  |                      ^

error: internal compiler error: `fn(_) {std::mem::drop::<_>}` overridden by `fn(_) {std::mem::drop::<_>}` for HirId(DefId(0:3 ~ a[90cb]::main).35) in DefId(0:3 ~ a[90cb]::main)
 --> a.rs:3:26
  |
3 |     assert_eq!(0, *x + { drop(x); let _ = Box::new(main); 0 });
  |                          ^^^^
  |
note: delayed at compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs:159:28 - disabled backtrace
 --> a.rs:3:26
  |
3 |     assert_eq!(0, *x + { drop(x); let _ = Box::new(main); 0 });
  |                          ^^^^

error: internal compiler error: `Box<Option<Option<Option<Option<&str>>>>>` overridden by `Box<Option<Option<Option<Option<&str>>>>>` for HirId(DefId(0:3 ~ a[90cb]::main).37) in DefId(0:3 ~ a[90cb]::main)
 --> a.rs:3:31
  |
3 |     assert_eq!(0, *x + { drop(x); let _ = Box::new(main); 0 });
  |                               ^
  |
note: delayed at compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs:159:28 - disabled backtrace
 --> a.rs:3:31
  |
3 |     assert_eq!(0, *x + { drop(x); let _ = Box::new(main); 0 });
  |                               ^

error: internal compiler error: `()` overridden by `()` for HirId(DefId(0:3 ~ a[90cb]::main).34) in DefId(0:3 ~ a[90cb]::main)
 --> a.rs:3:26
  |
3 |     assert_eq!(0, *x + { drop(x); let _ = Box::new(main); 0 });
  |                          ^^^^^^^
  |
note: delayed at compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs:159:28 - disabled backtrace
 --> a.rs:3:26
  |
3 |     assert_eq!(0, *x + { drop(x); let _ = Box::new(main); 0 });
  |                          ^^^^^^^

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/im/rustc-ice-2025-05-07T15_09_29-561781.txt` to your bug report

query stack during panic:
end of query stack

@matthiaskrgr matthiaskrgr marked this as a duplicate of #140785 May 8, 2025
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue May 9, 2025
…e, r=oli-obk

Do not ICE when reassigning in GatherLocalsVisitor on the bad path

Fixes rust-lang#140785
Fixes rust-lang#140730

See comment in code.

r? oli-obk
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue May 9, 2025
…e, r=oli-obk

Do not ICE when reassigning in GatherLocalsVisitor on the bad path

Fixes rust-lang#140785
Fixes rust-lang#140730

See comment in code.

r? oli-obk
@jieyouxu jieyouxu removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 14, 2025
@bors bors closed this as completed in dcb808e May 15, 2025
@bors bors marked this as not a duplicate of #140785 May 15, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue May 15, 2025
Rollup merge of rust-lang#140827 - compiler-errors:gather-locals-twice, r=oli-obk

Do not ICE when reassigning in GatherLocalsVisitor on the bad path

Fixes rust-lang#140785
Fixes rust-lang#140730

See comment in code.

r? oli-obk
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this issue May 19, 2025
Do not ICE when reassigning in GatherLocalsVisitor on the bad path

Fixes rust-lang/rust#140785
Fixes rust-lang/rust#140730

See comment in code.

r? oli-obk
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants