-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Project json compatibility improvements #21423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cormacrelf
wants to merge
5
commits into
rust-lang:master
Choose a base branch
from
cormacrelf:project-json-compatibility
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+64
−8
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d8b74b7
Add a test for parsing BuildData and RunnableData json
cormacrelf 2969b3b
Add unknown runnable kind for forwards compatibility
cormacrelf 967277d
Privatise some fields and structs in project_json
cormacrelf fa181ab
A comment to help ProjectJsonData stay backwards-compatible
cormacrelf f8bc65a
Restore a deleted comment that was quite informative
cormacrelf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -368,6 +368,9 @@ pub enum RunnableKind { | |
| /// Template for checking a target, emitting rustc JSON diagnostics. | ||
| /// May include {label} which will get the label from the `build` section of a crate. | ||
| Flycheck, | ||
|
|
||
| /// For forwards-compatibility, i.e. old rust-analyzer binary with newer workspace discovery tools | ||
| Unknown, | ||
| } | ||
|
|
||
| #[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)] | ||
|
|
@@ -380,6 +383,8 @@ pub struct ProjectJsonData { | |
| crates: Vec<CrateData>, | ||
| #[serde(default)] | ||
| runnables: Vec<RunnableData>, | ||
| // | ||
| // New fields should be Option or #[serde(default)]. This applies to most of this datastructure. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "most of this datastructure" is ambiguous: which parts of the datastructure? How about "everything should be optional except crates, so we can add support for new fields that old rust-project.json tools aren't generating yet". |
||
| } | ||
|
|
||
| #[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq, Default)] | ||
|
|
@@ -457,32 +462,37 @@ enum EditionData { | |
| } | ||
|
|
||
| #[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)] | ||
| pub struct BuildData { | ||
| struct BuildData { | ||
| label: String, | ||
| build_file: Utf8PathBuf, | ||
| target_kind: TargetKindData, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] | ||
| pub struct RunnableData { | ||
| pub program: String, | ||
| pub args: Vec<String>, | ||
| pub cwd: Utf8PathBuf, | ||
| pub kind: RunnableKindData, | ||
| struct RunnableData { | ||
| program: String, | ||
| args: Vec<String>, | ||
| cwd: Utf8PathBuf, | ||
| kind: RunnableKindData, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] | ||
| #[serde(rename_all = "camelCase")] | ||
| pub enum RunnableKindData { | ||
| enum RunnableKindData { | ||
| Flycheck, | ||
| Check, | ||
| Run, | ||
| TestOne, | ||
|
|
||
| /// For forwards-compatibility, i.e. old rust-analyzer binary with newer workspace discovery tools | ||
| #[allow(unused)] | ||
| #[serde(other)] | ||
| Unknown, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)] | ||
| #[serde(rename_all = "camelCase")] | ||
| pub enum TargetKindData { | ||
| enum TargetKindData { | ||
| Bin, | ||
| /// Any kind of Cargo lib crate-type (dylib, rlib, proc-macro, ...). | ||
| Lib, | ||
|
|
@@ -546,6 +556,7 @@ impl From<RunnableKindData> for RunnableKind { | |
| RunnableKindData::Run => RunnableKind::Run, | ||
| RunnableKindData::TestOne => RunnableKind::TestOne, | ||
| RunnableKindData::Flycheck => RunnableKind::Flycheck, | ||
| RunnableKindData::Unknown => RunnableKind::Unknown, | ||
| } | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| { | ||
| "sysroot_src": null, | ||
| "crates": [ | ||
| { | ||
| "display_name": "hello_world", | ||
| "root_module": "$ROOT$src/lib.rs", | ||
| "edition": "2018", | ||
| "deps": [], | ||
| "is_workspace_member": true, | ||
| "build": { | ||
| "label": "//:hello_world", | ||
| "build_file": "$ROOT$BUILD", | ||
| "target_kind": "bin" | ||
| } | ||
| } | ||
| ], | ||
| "runnables": [ | ||
| { | ||
| "kind": "run", | ||
| "program": "bazel", | ||
| "args": ["run", "{label}"], | ||
| "cwd": "$ROOT$" | ||
| }, | ||
| { | ||
| "kind": "flycheck", | ||
| "program": "$ROOT$custom-flychecker.sh", | ||
| "args": ["{label}"], | ||
| "cwd": "$ROOT$" | ||
| }, | ||
| { | ||
| "kind": "we-ignore-unknown-runnable-kinds-for-forwards-compatibility", | ||
| "program": "abc", | ||
| "args": ["{label}"], | ||
| "cwd": "$ROOT$" | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: it's not that they're newer tools, it's that they're tool that can output additional types of runnable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is implied by this comment being attached to a serde(other) variant called "Unknown"