Skip to content

ICE:gather_locals #140785

New issue

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

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

Already on GitHub? Sign in to your account

Closed
sososopy opened this issue May 8, 2025 · 1 comment · May be fixed by #140827
Closed

ICE:gather_locals #140785

sososopy opened this issue May 8, 2025 · 1 comment · May be fixed by #140827
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@sososopy
Copy link

sososopy commented May 8, 2025

It is a similar issue to #140730 and might be a repetitive one of its problems

Code

fn main() {
    let mut num: &i16;
    num += ()?;
}

Meta

rustc --version --verbose:

rustc 1.88.0-nightly (e9f8103f9 2025-05-07)
binary: rustc
commit-hash: e9f8103f93f8ce2fa2c15c0c6796ec821f8ae15d
commit-date: 2025-05-07
host: x86_64-pc-windows-msvc
release: 1.88.0-nightly
LLVM version: 20.1.4

Error output

error[E0277]: the `?` operator can only be applied to values that implement `Try`
    |
292 |     num += ()?;
    |            ^^^ the `?` operator cannot be applied to type `()`
    |
    = help: the trait `Try` is not implemented for `()`

error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
    |
290 | fn main() {
    | --------- this function should return `Result` or `Option` to accept `?`
291 |     let mut num: &i16;
292 |     num += ()?;
    |              ^ cannot use the `?` operator in a function that returns `()`
Backtrace

thread 'rustc' panicked at compiler\rustc_hir_typeck\src\gather_locals.rs:112:17:
assertion `left == right` failed
  left: Some(?12t)
 right: None
stack backtrace:
   0:     0x7fffb4efc702 - std::backtrace_rs::backtrace::win64::trace
                               at /rustc/e9f8103f93f8ce2fa2c15c0c6796ec821f8ae15d/library\std\src\..\..\backtrace\src\backtrace\win64.rs:85
   1:     0x7fffb4efc702 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/e9f8103f93f8ce2fa2c15c0c6796ec821f8ae15d/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7fffb4efc702 - std::sys::backtrace::_print_fmt
                               at /rustc/e9f8103f93f8ce2fa2c15c0c6796ec821f8ae15d/library\std\src\sys\backtrace.rs:66
   3:     0x7fffb4efc702 - std::sys::backtrace::impl$0::print::impl$0::fmt
                               at /rustc/e9f8103f93f8ce2fa2c15c0c6796ec821f8ae15d/library\std\src\sys\backtrace.rs:39
   4:     0x7fffb4f2eecb - core::fmt::rt::Argument::fmt
                               at /rustc/e9f8103f93f8ce2fa2c15c0c6796ec821f8ae15d/library\core\src\fmt\rt.rs:181
   5:     0x7fffb4f2eecb - core::fmt::write
                               at /rustc/e9f8103f93f8ce2fa2c15c0c6796ec821f8ae15d/library\core\src\fmt\mod.rs:1446
   6:     0x7fffb4ef26d7 - std::io::default_write_fmt
                               at /rustc/e9f8103f93f8ce2fa2c15c0c6796ec821f8ae15d/library\std\src\io\mod.rs:639
   7:     0x7fffb4ef26d7 - std::io::Write::write_fmt<std::sys::stdio::windows::Stderr>
                               at /rustc/e9f8103f93f8ce2fa2c15c0c6796ec821f8ae15d/library\std\src\io\mod.rs:1914
   8:     0x7fffb4efc545 - std::sys::backtrace::BacktraceLock::print
                               at /rustc/e9f8103f93f8ce2fa2c15c0c6796ec821f8ae15d/library\std\src\sys\backtrace.rs:42
   9:     0x7fffb4f0219a - std::panicking::default_hook::closure$0
                               at /rustc/e9f8103f93f8ce2fa2c15c0c6796ec821f8ae15d/library\std\src\panicking.rs:300
  10:     0x7fffb4f01f30 - std::panicking::default_hook
                               at /rustc/e9f8103f93f8ce2fa2c15c0c6796ec821f8ae15d/library\std\src\panicking.rs:327
  11:     0x7fffb6618b39 - core[12cfcfafe2bb19e]::slice::sort::unstable::heapsort::heapsort::<((rustc_lint_defs[e43e066ad2f79cd0]::Level, &str), usize), <((rustc_lint_defs[e43e066ad2f79cd0]::Level, &str), usize) as 
core[12cfcfafe2bb19e]::cmp::PartialOrd>::lt>
  12:     0x7fffb4f02e2e - std::panicking::rust_panic_with_hook
                               at /rustc/e9f8103f93f8ce2fa2c15c0c6796ec821f8ae15d/library\std\src\panicking.rs:841
  13:     0x7fffb4f02b89 - std::panicking::begin_panic_handler::closure$0
                               at /rustc/e9f8103f93f8ce2fa2c15c0c6796ec821f8ae15d/library\std\src\panicking.rs:706
  14:     0x7fffb4efd4bf - std::sys::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                               at /rustc/e9f8103f93f8ce2fa2c15c0c6796ec821f8ae15d/library\std\src\sys\backtrace.rs:168
  15:     0x7fffb4f0278e - std::panicking::begin_panic_handler
                               at /rustc/e9f8103f93f8ce2fa2c15c0c6796ec821f8ae15d/library\std\src\panicking.rs:697
  16:     0x7fffb808dd61 - core::panicking::panic_fmt
                               at /rustc/e9f8103f93f8ce2fa2c15c0c6796ec821f8ae15d/library\core\src\panicking.rs:75
  17:     0x7fffb808e294 - core::panicking::assert_failed_inner
                               at /rustc/e9f8103f93f8ce2fa2c15c0c6796ec821f8ae15d/library\core\src\panicking.rs:428
  18:     0x7fffb780fe55 - core[12cfcfafe2bb19e]::panicking::assert_failed::<core[12cfcfafe2bb19e]::option::Option<rustc_middle[e0862b95ef2ad2fa]::ty::Ty>, core[12cfcfafe2bb19e]::option::Option<rustc_middle[e0862b95ef2ad2fa]::ty::Ty>>
  19:     0x7fffb510e2c9 - <rustc_hir_typeck[ef0cb4f4b335c91c]::gather_locals::GatherLocalsVisitor as rustc_hir[8ce3318ddae2e78f]::intravisit::Visitor>::visit_pat
  20:     0x7fffb510de24 - <rustc_hir_typeck[ef0cb4f4b335c91c]::gather_locals::GatherLocalsVisitor as rustc_hir[8ce3318ddae2e78f]::intravisit::Visitor>::visit_pat
  21:     0x7fffb50a355e - <<rustc_hir_typeck[ef0cb4f4b335c91c]::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir[77ae8ddb4311a279]::visit::TypeVisitor<rustc_middle[e0862b95ef2ad2fa]::ty::context::TyCtxt>>::visit_ty
  22:     0x7fffb5133959 - rustc_hir_typeck[ef0cb4f4b335c91c]::method::probe::method_autoderef_steps
  23:     0x7fffb50a6f3c - <<rustc_hir_typeck[ef0cb4f4b335c91c]::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir[77ae8ddb4311a279]::visit::TypeVisitor<rustc_middle[e0862b95ef2ad2fa]::ty::context::TyCtxt>>::visit_ty
  24:     0x7fffb5106d22 - <<rustc_hir_typeck[ef0cb4f4b335c91c]::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir[77ae8ddb4311a279]::visit::TypeVisitor<rustc_middle[e0862b95ef2ad2fa]::ty::context::TyCtxt>>::visit_ty
  25:     0x7fffb50a218e - <<rustc_hir_typeck[ef0cb4f4b335c91c]::fn_ctxt::FnCtxt>::deduce_closure_signature_from_predicates::MentionsTy as rustc_type_ir[77ae8ddb4311a279]::visit::TypeVisitor<rustc_middle[e0862b95ef2ad2fa]::ty::context::TyCtxt>>::visit_ty
  26:     0x7fffb516aa75 - rustc_hir_typeck[ef0cb4f4b335c91c]::typeck
  27:     0x7fffb51b6160 - <rustc_hir_typeck[ef0cb4f4b335c91c]::upvar::InferBorrowKind as rustc_hir_typeck[ef0cb4f4b335c91c]::expr_use_visitor::Delegate>::borrow
  28:     0x7fffb516a11f - rustc_hir_typeck[ef0cb4f4b335c91c]::typeck
  29:     0x7fffb5e4d7bb - rustc_query_impl[b1e9fe2ed6241a4e]::plumbing::query_key_hash_verify_all
  30:     0x7fffb5d854f4 - RINvNtNtCsjWn63FlaSeo_18rustc_query_system5query8plumbing17try_execute_queryINtCsfh1ZTS0Cz1O_16rustc_query_impl13DynamicConfigINtNtCs1jU3cWLZBn1_21rustc_data_structures9vec_cache8VecCacheNtNtCs7bhVXFTTBeg_10rustc_span6def_id10LocalDefIdINtNtNtCsjh8sONEosqs
  31:     0x7fffb5e55ce2 - rustc_query_impl[b1e9fe2ed6241a4e]::plumbing::query_key_hash_verify_all
  32:     0x7fffb51f06da - RINvMs6_NtCs3jUekHcl3qQ_9hashbrown3rawINtB6_8RawTablejE14reserve_rehashNCINvNtNtCse1pCQVjQKP6_8indexmap3map4core8get_hashTNtNtNtCsjh8sONEosqs_12rustc_middle2ty9predicate6ClauseNtNtCs7bhVXFTTBeg_10rustc_span13span_encoding4SpanEuE0ECs3Zy3ugrYhTr_18rustc_hir
  33:     0x7fffb528d7a3 - rustc_hir_analysis[2e817c42e1dbd083]::check_crate
  34:     0x7fffb4f66553 - <rustc_interface[ce4bd24abdc0293]::passes::LintStoreExpandImpl as rustc_expand[63f6de8acd528e14]::base::LintStoreExpand>::pre_expansion_lint
  35:     0x7fffb186daa7 - rustc_interface[ce4bd24abdc0293]::passes::analysis
  36:     0x7fffb4a7e91a - <alloc[719322561de28682]::sync::Arc<rustc_session[11d32fa8aeb226a]::config::OutputFilenames>>::drop_slow
  37:     0x7fffb498747a - RINvNtNtCsjWn63FlaSeo_18rustc_query_system5query8plumbing17try_execute_queryINtCsfh1ZTS0Cz1O_16rustc_query_impl13DynamicConfigINtNtB4_6caches11SingleCacheINtNtNtCsjh8sONEosqs_12rustc_middle5query5erase6ErasedAhj0_EEKb0_KB3s_KB3s_ENtNtB1f_8plumbing9QueryCtx
  38:     0x7fffb4a84f43 - rustc_query_impl[b1e9fe2ed6241a4e]::query_system
  39:     0x7fffb182ecb5 - std[fc4f8a3a2a49de45]::sys::backtrace::__rust_begin_short_backtrace::<<std[fc4f8a3a2a49de45]::thread::Builder>::spawn_unchecked_<ctrlc[7a845440e34341ae]::set_handler_inner<rustc_driver_impl[33f0ba469f0779bf]::install_ctrlc_handler::{closure#0}>::{closure#0}, ()>::{closure#1}::{closure#0}::{closure#0}, ()>
  40:     0x7fffb1828f13 - std[fc4f8a3a2a49de45]::sys::backtrace::__rust_begin_short_backtrace::<<std[fc4f8a3a2a49de45]::thread::Builder>::spawn_unchecked_<ctrlc[7a845440e34341ae]::set_handler_inner<rustc_driver_impl[33f0ba469f0779bf]::install_ctrlc_handler::{closure#0}>::{closure#0}, ()>::{closure#1}::{closure#0}::{closure#0}, ()>
  41:     0x7fffb182479f - RINvNtNtCslF2IWO2j5Pd_3std3sys9backtrace28___rust_begin_short_backtraceNCNCINvNtCs16DaRdFtSTv_15rustc_interface4util26run_in_thread_with_globalsNCINvB1e_31run_in_thread_pool_with_globalsNCINvNtB1g_9interface12run_compileruNCNvCs4stArJ2l1h3_17rustc_driver_i
  42:     0x7fffb1833010 - std[fc4f8a3a2a49de45]::sys::backtrace::__rust_begin_short_backtrace::<<std[fc4f8a3a2a49de45]::thread::Builder>::spawn_unchecked_<ctrlc[7a845440e34341ae]::set_handler_inner<rustc_driver_impl[33f0ba469f0779bf]::install_ctrlc_handler::{closure#0}>::{closure#0}, ()>::{closure#1}::{closure#0}::{closure#0}, ()>
  43:     0x7fffb4f0719d - alloc::boxed::impl$28::call_once
                               at /rustc/e9f8103f93f8ce2fa2c15c0c6796ec821f8ae15d/library\alloc\src\boxed.rs:1966
  44:     0x7fffb4f0719d - alloc::boxed::impl$28::call_once
                               at /rustc/e9f8103f93f8ce2fa2c15c0c6796ec821f8ae15d/library\alloc\src\boxed.rs:1966
  45:     0x7fffb4f0719d - std::sys::pal::windows::thread::impl$0::new::thread_start
                               at /rustc/e9f8103f93f8ce2fa2c15c0c6796ec821f8ae15d/library\std\src\sys\pal\windows\thread.rs:56
  46:     0x7ff881247374 - BaseThreadInitThunk
  47:     0x7ff88285cc91 - RtlUserThreadStart

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

query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack

@sososopy sososopy 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 8, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 8, 2025
@sososopy
Copy link
Author

sososopy commented May 8, 2025

(It seems that I just saw a question in the comment section?)I just run the rustc command on the latest rustc Nightly version (nightly-2025-05-07-x86_64-pc-windows-msvc)
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=332b55f3c52ddd31d32fb88f9218f8c6

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. 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.

3 participants