Hi, I wanted to have a go at https://github.com/rust-analyzer/rust-analyzer/issues/8645 (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
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
That is referring to the E0123 codes rustc includes in most diagnostics
I think we could just include those in each
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/handler.rs to it's underlying error code to be able to filter them
Fix comes from a diagnostic, the association is apparently lost when they're stored in
You might be able to change
DiagnosticCollection to keep this association
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
we want to keep our own codes, and just have a notion of what rustc diagnostics our own diagnostics correspond to
Would adding a DiagnosticCode field to the
Fix struct be a good idea?
Are you talking about this code?
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.
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
that shoud've been
(if you are asking yourself "what's that
// pub name", I ask myself the same question)
Looks like it used to be the