rust-lang / rust-lang/rust-analyzer
Unexpected type for `Struct` constructor: `AssocTypeId`
Open
Nobody has claimed this yet.
A-pattern
C-bug
I-panic
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
for ()<|>
let x = 4;
thread 'Worker' panicked at crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs:403:21:
internal error: entered unreachable code: Unexpected type for `Struct` constructor: AssocTypeId(3435)<[?0 := Bool]>
stack backtrace:
0: rust_begin_unwind
1: core::panicking::panic_fmt
2: <hir_ty::diagnostics::match_check::pat_analysis::MatchCheckCtx as ra_ap_rustc_pattern_analysis::PatCx>::ctor_sub_tys
3: ra_ap_rustc_pattern_analysis::usefulness::compute_exhaustiveness_and_usefulness
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::match_check::pat_analysis::MatchCheckCtx::compute_match_usefulness
7: hir_ty::diagnostics::expr::BodyValidationDiagnostic::collect
8: hir::DefWithBody::diagnostics
9: hir::ModuleDef::diagnostics
10: hir::Module::diagnostics
11: ide_diagnostics::semantic_diagnostics
12: ide_diagnostics::full_diagnostics
13: std::panic::catch_unwind
14: ra_salsa::Cancelled::catch
15: ide::Analysis::assists_with_fixes
16: rust_analyzer::handlers::request::handle_code_action
17: std::panic::catch_unwind
18: core::ops::function::FnOnce::call_once{{vtable.shim}}
This is the same panic that was reported in #17031.
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
Start with the reproducer and the panic at crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs:403, especially MatchCheckCtx::ctor_sub_tys in the stack trace. Compare this failure with the same panic reported in issue #17031, then run the reproducer through diagnostics. Done means the snippet no longer causes the unexpected Struct constructor panic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100