Stream: t-compiler/rust-analyzer

Topic: Duplicated Diagnostics


Eduardo Canellas (Jan 15 2021 at 02:41, on Zulip):

Hello, I'm trying to debug the issue 6851 from rust-analyzer and I'm new here. I found that I could remove the duplicated code actions I had by commenting lines 314-341 on crates/rust-analyzer/src/diagnostics/to_proto.rs. Is this solution OK or it would not be the way to go? @matklad commented on issue 6734 that those "related information" diagnostics were not useful for VS code. :thinking:

Jonas Schievink [he/him] (Jan 15 2021 at 03:13, on Zulip):

I don't think that would be the right way, it would basically undo the PR that showed more detailed rustc diagnostics

Jonas Schievink [he/him] (Jan 15 2021 at 03:13, on Zulip):

Instead we shouldn't duplicate the fixes onto each diagnostic we return

Eduardo Canellas (Jan 15 2021 at 03:31, on Zulip):

Oh, thanks. Now I see that it isn't a good option. I'll think more about it later.

Jonas Schievink [he/him] (Jan 15 2021 at 12:31, on Zulip):

I can look at this too

Eduardo Canellas (Jan 15 2021 at 16:36, on Zulip):

That looks hard to deal with. Some things work on some diagnostics, others don't... The best "fix" I could find so far was to skip related_information diagnostics when it starts on the same line as the primary span. It worked for the cases I was testing manually.

Something like this around line 324:

if info.message.is_empty() || same_line {
    continue;
}

The idea was to limit the amount of fixes to 1 on the same spot and primary span. This may work for most cases, though maybe not of them.... :thinking:

Jonas Schievink [he/him] (Jan 15 2021 at 17:14, on Zulip):

@Eduardo Canellas I'd be surprised if we need to do that, it should suffice to just emit fixes alongside the diagnostic that includes them, instead of collecting and duplicating them with each subdiagnostic. Can you give https://github.com/rust-analyzer/rust-analyzer/pull/7285 a try to see if it fixes the issues? It works for me.

Eduardo Canellas (Jan 15 2021 at 18:54, on Zulip):

@Jonas Schievink I tried it and it fixed the issues I was testing. :happy:

Last update: Jul 28 2021 at 04:00UTC