question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

coc-rust-analyzer doesn't display "related information" diagnostics ("value moved here" etc)

See original GitHub issue

coc-rust-analyzer doesn’t display the “related information” part of diagnostic messages, even though it is reported by the rust-analyzer language server:

Example program: (playground)

fn main() {
    let x = "hello world!\n".to_string();
    //  - move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait
    // (this diagnostic is missing)

    take(x);
    //   - value moved here
    // (this diagnostic is missing)

    println!("{}", x);
    //             ^ value borrowed here after move
    // (this diagnostic is displayed)
}

fn take(s: String) {
    println!("{}", s);
}

Diagnostic information from trace:

[Trace - 18:21:52] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "diagnostics": [
        {
            "code": "E0382",
            "message": "borrow of moved value: `x`\nvalue borrowed here after move",
            "range": {
                "end": {
                    "character": 20,
                    "line": 5
                },
                "start": {
                    "character": 19,
                    "line": 5
                }
            },
            "relatedInformation": [
                {
                    "location": {
                        "range": {
                            "end": {
                                "character": 10,
                                "line": 3
                            },
                            "start": {
                                "character": 9,
                                "line": 3
                            }
                        },
                        "uri": "file:///home/yrlf/Programming/rs/misc/foo/src/main.rs"
                    },
                    "message": "value moved here"
                },
                {
                    "location": {
                        "range": {
                            "end": {
                                "character": 9,
                                "line": 1
                            },
                            "start": {
                                "character": 8,
                                "line": 1
                            }
                        },
                        "uri": "file:///home/yrlf/Programming/rs/misc/foo/src/main.rs"
                    },
                    "message": "move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait"
                }
            ],
            "severity": 1,
            "source": "rustc"
        }
    ],
    "uri": "file:///home/yrlf/Programming/rs/misc/foo/src/main.rs"
}

Current display in CoC with coc-rust-analyzer: view in editor

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
fannheywardcommented, Mar 26, 2020

diagnostic.separateRelatedInformationAsDiagnostics has added into coc.nvim.

1reaction
fannheywardcommented, Mar 26, 2020

Agreed, showing related informations will do grep help for user. We should not be limited to how VSCode does.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What do I have to do to solve a "use of moved value" error?
If it doesn't, then the value is moved to the given function, and the caller cannot use it afterwards. That is the meaning...
Read more >
User Manual - rust-analyzer
At its core, rust-analyzer is a library for semantic analysis of Rust code as it changes over time. This manual focuses on a...
Read more >
src/tools/rust-analyzer/docs/user/manual.adoc - Fossies
At its core, rust-analyzer is a library for semantic analysis of Rust code as it changes over time. This manual focuses on a...
Read more >
Untitled
r\nYou can move to the selected line from the displayed list. ... of the plugin for further information on how to use and...
Read more >
What do you use for writing rust code? - Reddit
171 votes, 258 comments. Additional information like plugins would be useful. I can only add six options to the poll and presenter what...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found