Skip to content

Commit

Permalink
bootstrap: add --json-output for rust-analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Apr 2, 2020
1 parent 0f72ce1 commit e992565
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/bootstrap/compile.rs
Expand Up @@ -911,7 +911,11 @@ pub fn stream_cargo(
}
// Instruct Cargo to give us json messages on stdout, critically leaving
// stderr as piped so we can get those pretty colors.
let mut message_format = String::from("json-render-diagnostics");
let mut message_format = if builder.config.json_output {
String::from("json")
} else {
String::from("json-render-diagnostics")
};
if let Some(s) = &builder.config.rustc_error_format {
message_format.push_str(",json-diagnostic-");
message_format.push_str(s);
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/config.rs
Expand Up @@ -48,6 +48,7 @@ pub struct Config {
pub ignore_git: bool,
pub exclude: Vec<PathBuf>,
pub rustc_error_format: Option<String>,
pub json_output: bool,
pub test_compare_mode: bool,
pub llvm_libunwind: bool,

Expand Down Expand Up @@ -415,6 +416,7 @@ impl Config {
let mut config = Config::default_opts();
config.exclude = flags.exclude;
config.rustc_error_format = flags.rustc_error_format;
config.json_output = flags.json_output;
config.on_fail = flags.on_fail;
config.stage = flags.stage;
config.jobs = flags.jobs.map(threads_from_config);
Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/flags.rs
Expand Up @@ -31,6 +31,7 @@ pub struct Flags {
pub incremental: bool,
pub exclude: Vec<PathBuf>,
pub rustc_error_format: Option<String>,
pub json_output: bool,
pub dry_run: bool,

// This overrides the deny-warnings configuration option,
Expand Down Expand Up @@ -156,6 +157,7 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
"VALUE",
);
opts.optopt("", "error-format", "rustc error format", "FORMAT");
opts.optflag("", "json-output", "use message-format=json");
opts.optopt(
"",
"llvm-skip-rebuild",
Expand Down Expand Up @@ -503,6 +505,7 @@ Arguments:
dry_run: matches.opt_present("dry-run"),
on_fail: matches.opt_str("on-fail"),
rustc_error_format: matches.opt_str("error-format"),
json_output: matches.opt_present("json-output"),
keep_stage: matches
.opt_strs("keep-stage")
.into_iter()
Expand Down

0 comments on commit e992565

Please sign in to comment.