]> git.lizzy.rs Git - rust.git/commit
Merge #6734
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>
Sun, 6 Dec 2020 13:26:54 +0000 (13:26 +0000)
committerGitHub <noreply@github.com>
Sun, 6 Dec 2020 13:26:54 +0000 (13:26 +0000)
commit1403ddf029a6a4ced904146ac7b475c923f6129f
tree5de8d09fea220460bf49657f086d3130c79eb491
parent8d5aa08712e782f22f04525f291ec74dae183568
parent45b8b3d57fd1a38a0ccce8516cbebbd09184d59a
Merge #6734

6734: Emit additional diagnostics for hints/help/etc r=lnicola a=jonas-schievink

This makes rust-analyzer diagnostics match native rustc diagnostics in the terminal more closely. Unfortunately all of this is a bodge, since we already provide this information to the client in the form of `DiagnosticRelatedInformation`, but at least VS Code chooses such a poor UI for these that they don't help much, as evidenced [here](https://twitter.com/yaahc_/status/1335297260444250112) and in https://github.com/rust-lang/rust/issues/79741.

This PR papers over these client UI problems by taking the `DiagnosticRelatedInformation` and turning each one into its own hint-level diagnostic, which makes it show up in the source code. Quick fixes are attached to all resulting diagnostics, which makes them more discoverable.

### Example: "Consider removing this semicolon"

![screenshot-2020-12-06-01:27:29](https://user-images.githubusercontent.com/1786438/101268366-46423980-3762-11eb-9a69-1ff0b1806c2f.png)
![screenshot-2020-12-06-01:27:39](https://user-images.githubusercontent.com/1786438/101268367-46dad000-3762-11eb-81fa-afd234d44f17.png)
![screenshot-2020-12-06-01:27:46](https://user-images.githubusercontent.com/1786438/101268368-46dad000-3762-11eb-9205-4b9bd9f4406d.png)

### Example: "Value used after move"

![screenshot-2020-12-06-01:33:00](https://user-images.githubusercontent.com/1786438/101268447-22332800-3763-11eb-85ce-8c742927a2c8.png)
![screenshot-2020-12-06-01:33:07](https://user-images.githubusercontent.com/1786438/101268448-22cbbe80-3763-11eb-8f16-0590895d8bc6.png)

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>