Stream: t-compiler/rust-analyzer

Topic: Prefer ra fixes to rustc

Ayomide Bamidele (May 28 2021 at 12:45, on Zulip):

Hi, I wanted to have a go at (if no one is currently working on it). I have a question about the instructions provided. What exactly does "assign codes to our diagnostics to match rustc" mean? I found that Assist has AssistId - so would it be a case of having some sort of Map somewhere that maps AssistIds to rustc diagnostic codes? Or am I looking at the wrong place

Jonas Schievink [he/him] (May 28 2021 at 12:50, on Zulip):

That is referring to the E0123 codes rustc includes in most diagnostics

Jonas Schievink [he/him] (May 28 2021 at 12:50, on Zulip):

I think we could just include those in each Diagnostic implementation?

Ayomide Bamidele (May 28 2021 at 12:59, on Zulip):

Ah okay, I see. But when filtering out the error codes, I'm not sure how I would get from the Fix object in rust-analyzer/ to it's underlying error code to be able to filter them

Jonas Schievink [he/him] (May 28 2021 at 13:04, on Zulip):

Originally each Fix comes from a diagnostic, the association is apparently lost when they're stored in DiagnosticCollection.

Jonas Schievink [he/him] (May 28 2021 at 13:04, on Zulip):

You might be able to change DiagnosticCollection to keep this association

Ayomide Bamidele (May 28 2021 at 13:28, on Zulip):

Okay I think I understand what to do now. However, in the implementations of ra Diagnostics, the codes are already defined as text names like no-such-field instead of E0123 etc. Would it be okay to change the appripriate ones to match rustc? Or keep them as they are and have logic to map them to a rustc code if appriopriate? I feel like the former would be cleaner, but not sure how much code relies on specifc DiagnosticCode values

Florian Diebold (May 28 2021 at 13:29, on Zulip):

we want to keep our own codes, and just have a notion of what rustc diagnostics our own diagnostics correspond to

Ayomide Bamidele (May 29 2021 at 10:38, on Zulip):

Would adding a DiagnosticCode field to the Fix struct be a good idea?

matklad (May 31 2021 at 09:32, on Zulip):

Are you talking about this code?


matklad (May 31 2021 at 09:33, on Zulip):

Short term, yeah, adding code to fix would work. Long term, this should be refactored according to the FIXMEs. Then, the code will be in the diagnostics, and the fix will be a part of diagnostic.

Ayomide Bamidele (May 31 2021 at 11:26, on Zulip):

Refactoring seems like it would be a fun challenge, though I can't seem to find an ra_id module in the repo or any mention of it other than the FIXME when I CTRL+SHIFT+F

matklad (May 31 2021 at 13:19, on Zulip):

that shoud've been ide::Diagnostics

matklad (May 31 2021 at 13:19, on Zulip):

This thing

matklad (May 31 2021 at 13:20, on Zulip):

(if you are asking yourself "what's that // pub name", I ask myself the same question)

Laurențiu (May 31 2021 at 13:56, on Zulip):

Looks like it used to be the code

Last update: Jul 26 2021 at 13:15UTC