Skip to content

thread 'Worker' panicked: called Option::unwrap() on a None value #16732

Open

Description

thread 'Worker' panicked at crates/hir-ty/src/diagnostics/match_check.rs:147:50:
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: hir_ty::diagnostics::match_check::PatCtxt::lower_pattern
   4: hir_ty::diagnostics::expr::ExprValidator::lower_pattern
   5: hir_ty::diagnostics::expr::BodyValidationDiagnostic::collect
   6: hir::DefWithBody::diagnostics
   7: hir::Module::diagnostics
   8: ide_diagnostics::diagnostics
   9: std::panicking::try
  10: ide::Analysis::assists_with_fixes
  11: rust_analyzer::handlers::request::handle_code_action
  12: std::panicking::try
  13: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Repeatedly occurs when I first save a file.
That is, open the project in VS Code, make any small change, save the file, then I see this error repeat several times until I get a popup message from VS Code that the Rust Analyzer Language Server has been shutdown.

rust-analyzer version: v0.3.1860

rustc version: 1.67.0

relevant settings: Using VS Code 1.87.0, running on Windows 11 and using a project via WSL Ubuntu 22.04.

repository link (if public, optional): super-speedy-syslog-searcher

code snippet to reproduce:

I could not find a small code snippet to reproduce this problem. It happens whenever I edit any code.

I rolled back to version v0.3.1850 and this bug does not occur.

Unfortunately it's probably related the specifics of the code I'm editing and I'd prefer not to upload all that.

Similar to #15936

Full text of VS Code _OUTPUT_ tab

Full text of the VS Code OUTPUT tab, from opening the project, making some change in code, then saving the file. Then I see this output in OUTPUT tab for Rust Analyzer Language Server

Panic context:
> fetch_native_diagnostics

thread 'Worker' panicked at crates/hir-ty/src/diagnostics/match_check.rs:147:50:
called `Option::unwrap()` on a `None` value
stack backtrace:
Panic context:
> 
version: 0.3.1860-standalone
request: textDocument/codeAction CodeActionParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/user/Projects/super-speedy-syslog-searcher/src/readers/fixedstructreader.rs",
            query: None,
            fragment: None,
        },
    },
    range: Range {
        start: Position {
            line: 1322,
            character: 51,
        },
        end: Position {
            line: 1322,
            character: 51,
        },
    },
    context: CodeActionContext {
        diagnostics: [],
        only: None,
        trigger_kind: Some(
            Automatic,
        ),
    },
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
    partial_result_params: PartialResultParams {
        partial_result_token: None,
    },
}

thread 'Worker' panicked at crates/hir-ty/src/diagnostics/match_check.rs:147:50:
called `Option::unwrap()` on a `None` value
   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: hir_ty::diagnostics::match_check::PatCtxt::lower_pattern
   4: hir_ty::diagnostics::expr::ExprValidator::lower_pattern
   5: hir_ty::diagnostics::expr::BodyValidationDiagnostic::collect
   6: hir::DefWithBody::diagnostics
   7: hir::Module::diagnostics
   8: ide_diagnostics::diagnostics
   9: salsa::Cancelled::catch
  10: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  11: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  12: rust_analyzer::diagnostics::fetch_native_diagnostics
  13: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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: hir_ty::diagnostics::match_check::PatCtxt::lower_pattern
   4: hir_ty::diagnostics::expr::ExprValidator::lower_pattern
   5: hir_ty::diagnostics::expr::BodyValidationDiagnostic::collect
   6: hir::DefWithBody::diagnostics
   7: hir::Module::diagnostics
   8: ide_diagnostics::diagnostics
   9: std::panicking::try
  10: ide::Analysis::assists_with_fixes
  11: rust_analyzer::handlers::request::handle_code_action
  12: std::panicking::try
  13: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Panic context:
> 
version: 0.3.1860-standalone
request: textDocument/codeAction CodeActionParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/user/Projects/super-speedy-syslog-searcher/src/readers/fixedstructreader.rs",
            query: None,
            fragment: None,
        },
    },
    range: Range {
        start: Position {
            line: 1322,
            character: 51,
        },
        end: Position {
            line: 1322,
            character: 51,
        },
    },
    context: CodeActionContext {
        diagnostics: [],
        only: None,
        trigger_kind: Some(
            Automatic,
        ),
    },
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
    partial_result_params: PartialResultParams {
        partial_result_token: None,
    },
}

thread 'Worker' panicked at crates/hir-ty/src/diagnostics/match_check.rs:147:50:
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: hir_ty::diagnostics::match_check::PatCtxt::lower_pattern
   4: hir_ty::diagnostics::expr::ExprValidator::lower_pattern
   5: hir_ty::diagnostics::expr::BodyValidationDiagnostic::collect
   6: hir::DefWithBody::diagnostics
   7: hir::Module::diagnostics
   8: ide_diagnostics::diagnostics
   9: std::panicking::try
  10: ide::Analysis::assists_with_fixes
  11: rust_analyzer::handlers::request::handle_code_action
  12: std::panicking::try
  13: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Panic context:
> 
version: 0.3.1860-standalone
request: textDocument/codeAction CodeActionParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/user/Projects/super-speedy-syslog-searcher/src/readers/fixedstructreader.rs",
            query: None,
            fragment: None,
        },
    },
    range: Range {
        start: Position {
            line: 1322,
            character: 51,
        },
        end: Position {
            line: 1322,
            character: 51,
        },
    },
    context: CodeActionContext {
        diagnostics: [],
        only: None,
        trigger_kind: Some(
            Automatic,
        ),
    },
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
    partial_result_params: PartialResultParams {
        partial_result_token: None,
    },
}

thread 'Worker' panicked at crates/hir-ty/src/diagnostics/match_check.rs:147:50:
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: hir_ty::diagnostics::match_check::PatCtxt::lower_pattern
   4: hir_ty::diagnostics::expr::ExprValidator::lower_pattern
   5: hir_ty::diagnostics::expr::BodyValidationDiagnostic::collect
   6: hir::DefWithBody::diagnostics
   7: hir::Module::diagnostics
   8: ide_diagnostics::diagnostics
   9: std::panicking::try
  10: ide::Analysis::assists_with_fixes
  11: rust_analyzer::handlers::request::handle_code_action
  12: std::panicking::try
  13: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsdiagnostics / error reportingA-patternpattern handling related thingsC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions