Skip to content

Commit 0e6174c

Browse files
committed
Make ProjectJsonData more backwards-compatible
The structure has been slowly accumulating new, required fields, which has been breaking clients and requiring them to add `"sysroot_project": null` just to continue functioning. No more. Also makes clear to future editors of this code that they should add #[serde(default)] to new fields.
1 parent b217a0c commit 0e6174c

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

crates/project-model/src/project_json.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,14 +375,19 @@ pub enum RunnableKind {
375375

376376
#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
377377
pub struct ProjectJsonData {
378+
#[serde(default)]
378379
sysroot: Option<Utf8PathBuf>,
380+
#[serde(default)]
379381
sysroot_src: Option<Utf8PathBuf>,
382+
#[serde(default)]
380383
sysroot_project: Option<Box<ProjectJsonData>>,
381384
#[serde(default)]
382385
cfg_groups: FxHashMap<String, CfgList>,
383386
crates: Vec<CrateData>,
384387
#[serde(default)]
385388
runnables: Vec<RunnableData>,
389+
//
390+
// New fields should be #[serde(default)]. This applies to most of this datastructure.
386391
}
387392

388393
#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq, Default)]
@@ -417,6 +422,8 @@ struct CrateData {
417422
build: Option<BuildData>,
418423
#[serde(default)]
419424
proc_macro_cwd: Option<Utf8PathBuf>,
425+
//
426+
// New fields should be #[serde(default)].
420427
}
421428

422429
mod cfg_ {
@@ -464,14 +471,18 @@ pub struct BuildData {
464471
label: String,
465472
build_file: Utf8PathBuf,
466473
target_kind: TargetKindData,
474+
//
475+
// New fields should be #[serde(default)].
467476
}
468477

469478
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
470479
pub struct RunnableData {
471-
pub program: String,
472-
pub args: Vec<String>,
473-
pub cwd: Utf8PathBuf,
474-
pub kind: RunnableKindData,
480+
program: String,
481+
args: Vec<String>,
482+
cwd: Utf8PathBuf,
483+
kind: RunnableKindData,
484+
//
485+
// New fields should be #[serde(default)].
475486
}
476487

477488
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]

0 commit comments

Comments
 (0)