Skip to content

Panic in match checking #9095

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
iDawer opened this issue Jun 1, 2021 · 0 comments · Fixed by #9105
Closed

Panic in match checking #9095

iDawer opened this issue Jun 1, 2021 · 0 comments · Fixed by #9105
Labels
Broken Window Bugs / technical debt to be addressed immediately

Comments

@iDawer
Copy link
Contributor

iDawer commented Jun 1, 2021

Version 71117e6 2021-06-01 nightly

Found this in my minimal reproducible examples repo:

enum Foo<T> { A(T) }
match &Foo::A(true) {
    _ => {}
    Foo::A(_) => {}
}
log
Panic context:
> 
version: 71117e681 2021-06-01 nightly
request: textDocument/codeAction CodeActionParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/tmp/match-panic/src/extracted.rs",
            query: None,
            fragment: None,
        },
    },
    range: Range {
        start: Position {
            line: 132,
            character: 9,
        },
        end: Position {
            line: 132,
            character: 9,
        },
    },
    context: CodeActionContext {
        diagnostics: [],
        only: None,
    },
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
    partial_result_params: PartialResultParams {
        partial_result_token: None,
    },
}

thread '<unnamed>' panicked at 'Forgot to remove debug-print?', crates/hir_ty/src/diagnostics/expr.rs:365:25
stack backtrace:
   0: std::panicking::begin_panic
   1: hir_ty::diagnostics::expr::ExprValidator::validate_match::{{closure}}
   2: hir_ty::diagnostics::match_check::usefulness::MatchCheckCtx::bug
   3: hir_ty::diagnostics::match_check::usefulness::is_useful
   4: hir_ty::diagnostics::match_check::usefulness::compute_match_usefulness
   5: hir_ty::diagnostics::expr::ExprValidator::validate_body
   6: hir_ty::diagnostics::validate_body
   7: hir::Function::diagnostics
   8: hir::Module::diagnostics
   9: hir::Module::diagnostics
  10: ide::diagnostics::diagnostics
  11: ide::Analysis::assists_with_fixes::{{closure}}
  12: std::panicking::try
  13: rust_analyzer::handlers::handle_code_action
  14: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

The example may appear while expanding nested or-patterns.

(Also seems like I shouldn't use debug-print when panicking)

@matklad matklad added the Broken Window Bugs / technical debt to be addressed immediately label Jun 2, 2021
@bors bors bot closed this as completed in 5093639 Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Broken Window Bugs / technical debt to be addressed immediately
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants