Skip to content

Panic on computing code actions on incorrect code #10176

@fenuks

Description

@fenuks

I'm using Arch Linux, nvim LSP, and rust-analyzer d15f646 2021-08-31 dev.

fn main() {
    let v = vec![];
    v.map(::to_rfc3339());
}

Bug occurs when I put cursor on ::to_rfc3339(). Brackets are important, crash doesn't occur with code like v.map(::to_rfc3339);.

Crash log captured by LSP client:

[ ERROR ] 2021-09-07T16:18:41+0200 ] /usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:462 ]  "rpc"   "/usr/local/bin/rust-analyzer"  "stderr"        "Panic context:
> 
version: d15f646ff 2021-08-31 dev
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/test.rs",
            query: None,
            fragment: None,
        },
    },
    range: Range {
        start: Position {
            line: 2,
            character: 22,
        },
        end: Position {
            line: 2,
            character: 22,
        },
    },
    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 'Failed to make ast node `syntax::ast::generated::nodes::Name` from text mod ::to_rfc3339;', crates/syntax/src/ast/make.rs:675:13
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Unfortunately, I don't know how to capture full backtrace.

In /usr/local/bin/rust-analyzer I put:

#!/usr/bin/env sh
export RUST_BACKTRACE=full
/usr/bin/rust-analyzer "$@"

but nonetheless I still get information that I need to set RUST_BACKTRACE… Also tried to set it in /etc/profile and /etc/environment, to no avail. Hopefully it is enough to replicate the issue, it triggers for me 100% of the time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-assistsS-actionableSomeone could pick this issue up and work on it right now

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions