Skip to content

Commit 6b189ce

Browse files
committed
Don't swallow the other fields of the diagnostic code
1 parent 25b1a6c commit 6b189ce

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/cargo/core/compiler/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2168,12 +2168,14 @@ fn on_stderr_line_inner(
21682168
rendered: String,
21692169
#[serde(flatten, borrow)]
21702170
other: std::collections::BTreeMap<Cow<'a, str>, serde_json::Value>,
2171-
code: Option<DiagnosticCode>,
2171+
code: Option<DiagnosticCode<'a>>,
21722172
}
21732173

21742174
#[derive(serde::Deserialize, serde::Serialize)]
2175-
struct DiagnosticCode {
2175+
struct DiagnosticCode<'a> {
21762176
code: String,
2177+
#[serde(flatten, borrow)]
2178+
other: std::collections::BTreeMap<Cow<'a, str>, serde_json::Value>,
21772179
}
21782180

21792181
if let Ok(mut error) =

tests/testsuite/test.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4474,7 +4474,8 @@ fn json_diagnostic_includes_explanation() {
44744474
"$message_type": "diagnostic",
44754475
"children": "{...}",
44764476
"code": {
4477-
"code": "E0764"
4477+
"code": "E0764",
4478+
"explanation": "{...}"
44784479
},
44794480
"level": "error",
44804481
"message": "{...}",

0 commit comments

Comments
 (0)