You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
3564: Better handling of a few kinds of cargo/clippy diagnostics r=matklad a=kiljacken
This was initially supposed to just be a fix for #3433, but I caught a few things that ended up being useful as well.
This PR primarily makes us handle multi-edit fix suggestions properly. Instead of just applying the first fix we apply all the parts of the fix in a single action.
Second up, this PR handles diagnostics with multiple primary spans, f.x. the unused import diagnostic from rustc:

The LSP doesn't handle this too well, as it only support a single complete range for each diagnostic, so we get duplicate messages in the problem panel of VSCode:

However, I feel like the improved visual aspect in-editor outweighs the duplication in the problem panel. I'm open to not including the second commit if anybody really doesn't like the idea of duplicate diagnostics in the problem pane.
Fixes#3433Fixes#3257
Co-authored-by: Emil Lauridsen <mine809@gmail.com>
Copy file name to clipboardExpand all lines: crates/ra_cargo_watch/src/conv/snapshots/ra_cargo_watch__conv__test__snap_clippy_pass_by_ref.snap
+87-85Lines changed: 87 additions & 85 deletions
Original file line number
Diff line number
Diff line change
@@ -2,98 +2,100 @@
2
2
source: crates/ra_cargo_watch/src/conv/test.rs
3
3
expression: diag
4
4
---
5
-
MappedRustDiagnostic {
6
-
location: Location {
7
-
uri: "file:///test/compiler/mir/tagset.rs",
8
-
range: Range {
9
-
start: Position {
10
-
line: 41,
11
-
character: 23,
12
-
},
13
-
end: Position {
14
-
line: 41,
15
-
character: 28,
5
+
[
6
+
MappedRustDiagnostic {
7
+
location: Location {
8
+
uri: "file:///test/compiler/mir/tagset.rs",
9
+
range: Range {
10
+
start: Position {
11
+
line: 41,
12
+
character: 23,
13
+
},
14
+
end: Position {
15
+
line: 41,
16
+
character: 28,
17
+
},
16
18
},
17
19
},
18
-
},
19
-
diagnostic: Diagnostic {
20
-
range: Range {
21
-
start: Position {
22
-
line: 41,
23
-
character: 23,
24
-
},
25
-
end: Position {
26
-
line: 41,
27
-
character: 28,
20
+
diagnostic: Diagnostic {
21
+
range: Range {
22
+
start: Position {
23
+
line: 41,
24
+
character: 23,
25
+
},
26
+
end: Position {
27
+
line: 41,
28
+
character: 28,
29
+
},
28
30
},
29
-
},
30
-
severity: Some(
31
-
Warning,
32
-
),
33
-
code: Some(
34
-
String(
35
-
"trivially_copy_pass_by_ref",
31
+
severity: Some(
32
+
Warning,
36
33
),
37
-
),
38
-
source: Some(
39
-
"clippy",
40
-
),
41
-
message: "this argument is passed by reference, but would be more efficient if passed by value\n#[warn(clippy::trivially_copy_pass_by_ref)] implied by #[warn(clippy::all)]\nfor further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref",
42
-
related_information: Some(
43
-
[
44
-
DiagnosticRelatedInformation {
45
-
location: Location {
46
-
uri: "file:///test/compiler/lib.rs",
47
-
range: Range {
48
-
start: Position {
49
-
line: 0,
50
-
character: 8,
51
-
},
52
-
end: Position {
53
-
line: 0,
54
-
character: 19,
34
+
code: Some(
35
+
String(
36
+
"trivially_copy_pass_by_ref",
37
+
),
38
+
),
39
+
source: Some(
40
+
"clippy",
41
+
),
42
+
message: "this argument is passed by reference, but would be more efficient if passed by value\n#[warn(clippy::trivially_copy_pass_by_ref)] implied by #[warn(clippy::all)]\nfor further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref",
43
+
related_information: Some(
44
+
[
45
+
DiagnosticRelatedInformation {
46
+
location: Location {
47
+
uri: "file:///test/compiler/lib.rs",
48
+
range: Range {
49
+
start: Position {
50
+
line: 0,
51
+
character: 8,
52
+
},
53
+
end: Position {
54
+
line: 0,
55
+
character: 19,
56
+
},
55
57
},
56
58
},
59
+
message: "lint level defined here",
57
60
},
58
-
message: "lint level defined here",
59
-
},
60
-
],
61
-
),
62
-
tags: None,
63
-
},
64
-
fixes: [
65
-
CodeAction {
66
-
title: "consider passing by value instead: \'self\'",
0 commit comments