rust-lang / rust-lang/rust-analyzer

textDocument/publishDiagnostics: empty diagnostic messages

Open
#18,174 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-flycheck C-support
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

I have a question regarding some empty diagnostic messages. As can be seen in the picture below, I am getting diagnostics on all enum variant fields in this scenario, however the diagnostics are just a whitespace character for the first two tuple fields (this is the reason there is a line, but no message).

Image

Looking at the rust-analyzer information, this can also be seen with multiple instances of the message key having a value of a whitespace character.

I am wondering if this is the intended behaviour, and the diagnostic "highlights" are just to indicate that there are three fields, with the third containing the message - or if there is supposed to be information on the first two fields, or if they are even supposed to be marked at all?

{
   "jsonrpc":"2.0",
   "method":"textDocument/publishDiagnostics",
   "params":{
      "uri":"file:///home/krath/Documents/kasm/src/instruction/mod.rs",
      "diagnostics":[
         {
            "range":{
               "start":{
                  "line":46,
                  "character":4
               },
               "end":{
                  "line":46,
                  "character":8
               }
            },
            "severity":4,
            "code":"E0061",
            "codeDescription":{
               "href":"https://doc.rust-lang.org/error-index.html#E0061"
            },
            "source":"rustc",
            "message":"tuple variant defined here",
            "relatedInformation":[
               {
                  "location":{
                     "uri":"file:///home/krath/Documents/kasm/src/decode/jump.rs",
                     "range":{
                        "start":{
                           "line":14,
                           "character":11
                        },
                        "end":{
                           "line":14,
                           "character":28
                        }
                     }
                  },
                  "message":"original diagnostic"
               }
            ]
         },
         {
            "range":{
               "start":{
                  "line":46,
                  "character":9
               },
               "end":{
                  "line":46,
                  "character":13
               }
            },
            "severity":4,
            "code":"E0023",
            "codeDescription":{
               "href":"https://doc.rust-lang.org/error-index.html#E0023"
            },
            "source":"rustc",
            "message":" ",
            "relatedInformation":[
               {
                  "location":{
                     "uri":"file:///home/krath/Documents/kasm/src/execute/mod.rs",
                     "range":{
                        "start":{
                           "line":43,
                           "character":40
                        },
                        "end":{
                           "line":43,
                           "character":47
                        }
                     }
                  },
                  "message":"original diagnostic"
               }
            ]
         },
         {
            "range":{
               "start":{
                  "line":46,
                  "character":15
               },
               "end":{
                  "line":46,
                  "character":28
               }
            },
            "severity":4,
            "code":"E0023",
            "codeDescription":{
               "href":"https://doc.rust-lang.org/error-index.html#E0023"
            },
            "source":"rustc",
            "message":" ",
            "relatedInformation":[
               {
                  "location":{
                     "uri":"file:///home/krath/Documents/kasm/src/execute/mod.rs",
                     "range":{
                        "start":{
                           "line":43,
                           "character":40
                        },
                        "end":{
                           "line":43,
                           "character":47
                        }
                     }
                  },
                  "message":"original diagnostic"
               }
            ]
         },
         {
            "range":{
               "start":{
                  "line":46,
                  "character":30
               },
               "end":{
                  "line":46,
                  "character":46
               }
            },
            "severity":4,
            "code":"E0023",
            "codeDescription":{
               "href":"https://doc.rust-lang.org/error-index.html#E0023"
            },
            "source":"rustc",
            "message":"tuple variant has 3 fields",
            "relatedInformation":[
               {
                  "location":{
                     "uri":"file:///home/krath/Documents/kasm/src/execute/mod.rs",
                     "range":{
                        "start":{
                           "line":43,
                           "character":40
                        },
                        "end":{
                           "line":43,
                           "character":47
                        }
                     }
                  },
                  "message":"original diagnostic"
               }
            ]
         }
      ],
      "version":0
   }
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported tuple-variant mismatch and inspecting the textDocument/publishDiagnostics output alongside the rustc diagnostics and rust-analyzer information. Determine whether whitespace messages and their ranges are intended; done means the expected behavior is established and, if needed, covered by a focused fix and regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.