Skip to content
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

thread 'Worker' panicked at ra-ap-rustc_pattern_analysis-0.37.0/src/constructor.rs:947:63 #16656

Closed
edg-l opened this issue Feb 24, 2024 · 6 comments · Fixed by rust-lang/rust#121735 or #16738
Assignees
Labels
C-bug Category: bug I-panic

Comments

@edg-l
Copy link

edg-l commented Feb 24, 2024

rust-analyzer version: Tried show RA version but doesnt work, on vscode extension manager it shows v0.4.1857

rustc version: rustc 1.76.0 (07dca489a 2024-02-04)

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)

rust-analzer constantly crashes

thread 'Worker' panicked at /github/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ra-ap-rustc_pattern_analysis-0.37.0/src/constructor.rs:947:63:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: rust_begin_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
   2: core::panicking::panic
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:144:5
   3: ra_ap_rustc_pattern_analysis::constructor::ConstructorSet<Cx>::split
   4: ra_ap_rustc_pattern_analysis::usefulness::compute_exhaustiveness_and_usefulness
   5: ra_ap_rustc_pattern_analysis::usefulness::compute_match_usefulness
   6: hir_ty::diagnostics::expr::BodyValidationDiagnostic::collect
   7: hir::DefWithBody::diagnostics
   8: hir::ModuleDef::diagnostics
   9: hir::Module::diagnostics
  10: ide_diagnostics::diagnostics
  11: std::panicking::try
  12: ide::Analysis::assists_with_fixes
  13: rust_analyzer::handlers::request::handle_code_action
  14: std::panicking::try
  15: core::ops::function::FnOnce::call_once{{vtable.shim}}
@edg-l edg-l added the C-bug Category: bug label Feb 24, 2024
@Wilfred
Copy link
Contributor

Wilfred commented Feb 27, 2024

FWIW we're seeing this too, and it's our most common crash in the latest rust-analyzer release. I think it's the unwrap here: https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_pattern_analysis/constructor.rs.html#943

            ConstructorSet::Variants { variants, non_exhaustive } => {
                let mut seen_set = index::IdxSet::new_empty(variants.len());
                for idx in seen.iter().map(|c| c.as_variant().unwrap()) {
                    seen_set.insert(idx);
                }

@Veykril
Copy link
Member

Veykril commented Feb 28, 2024

cc @Nadrieril

@Nadrieril
Copy link
Member

I see. Does either of you have a code example that triggers the crash? It's likely a pattern-match expression with a type error

@Nadrieril
Copy link
Member

A fix is in motion: rust-lang/rust#121735

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Feb 28, 2024
…r=compiler-errors

pattern analysis: Don't panic when encountering unexpected constructor

Tiny PR to fix rust-lang/rust-analyzer#16656

r? `@compiler-errors`
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 29, 2024
Rollup merge of rust-lang#121735 - Nadrieril:no-panic-on-type-error, r=compiler-errors

pattern analysis: Don't panic when encountering unexpected constructor

Tiny PR to fix rust-lang/rust-analyzer#16656

r? ``@compiler-errors``
@lnicola
Copy link
Member

lnicola commented Feb 29, 2024

For anyone running into this, note that it will only be fixed after ra-ap_rustc_pattern_analysis gets published on Subday, and we upgrade bump our dependency on it.

@Nadrieril
Copy link
Member

Oops yeah, I didn't intend for bors to close this

bors added a commit that referenced this issue Mar 3, 2024
Update rustc_pattern_analysis

This should fix #16656 but I can't check because we don't have a reproducer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug I-panic
Projects
None yet
5 participants