Skip to content

Commit

Permalink
Auto merge of #61052 - jsgf:emit-save-analysis-notifications, r=alexc…
Browse files Browse the repository at this point in the history
…richton

Emit save analysis notifications

Addresses issue #61047
  • Loading branch information
bors committed Jun 11, 2019
2 parents 5e2c110 + 7a22c34 commit efc30d0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/librustc_save_analysis/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ impl<'a> DumpHandler<'a> {
}
}

fn output_file(&self, ctx: &SaveContext<'_, '_>) -> File {
fn output_file(&self, ctx: &SaveContext<'_, '_>) -> (File, PathBuf) {
let sess = &ctx.tcx.sess;
let file_name = match ctx.config.output_file {
Some(ref s) => PathBuf::from(s),
Expand Down Expand Up @@ -1054,7 +1054,7 @@ impl<'a> DumpHandler<'a> {
|e| sess.fatal(&format!("Could not open {}: {}", file_name.display(), e)),
);

output_file
(output_file, file_name)
}
}

Expand All @@ -1066,13 +1066,23 @@ impl<'a> SaveHandler for DumpHandler<'a> {
cratename: &str,
input: &'l Input,
) {
let output = &mut self.output_file(&save_ctxt);
let mut dumper = JsonDumper::new(output, save_ctxt.config.clone());
let mut visitor = DumpVisitor::new(save_ctxt, &mut dumper);
let sess = &save_ctxt.tcx.sess;
let file_name = {
let (mut output, file_name) = self.output_file(&save_ctxt);
let mut dumper = JsonDumper::new(&mut output, save_ctxt.config.clone());
let mut visitor = DumpVisitor::new(save_ctxt, &mut dumper);

visitor.dump_crate_info(cratename, krate);
visitor.dump_compilation_options(input, cratename);
visit::walk_crate(&mut visitor, krate);
visitor.dump_crate_info(cratename, krate);
visitor.dump_compilation_options(input, cratename);
visit::walk_crate(&mut visitor, krate);

file_name
};

if sess.opts.debugging_opts.emit_artifact_notifications {
sess.parse_sess.span_diagnostic
.emit_artifact_notification(&file_name, "save-analysis");
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/save-analysis/emit-notifications.nll.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"artifact":"$TEST_BUILD_DIR/save-analysis/emit-notifications.nll/save-analysis/libemit_notifications.json","emit":"save-analysis"}
{"artifact":"$TEST_BUILD_DIR/save-analysis/emit-notifications.nll/libemit_notifications.rlib","emit":"link"}
4 changes: 4 additions & 0 deletions src/test/ui/save-analysis/emit-notifications.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// compile-pass
// compile-flags: -Zsave-analysis -Zemit-artifact-notifications
// compile-flags: --crate-type rlib --error-format=json
pub fn foo() {}
2 changes: 2 additions & 0 deletions src/test/ui/save-analysis/emit-notifications.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"artifact":"$TEST_BUILD_DIR/save-analysis/emit-notifications/save-analysis/libemit_notifications.json","emit":"save-analysis"}
{"artifact":"$TEST_BUILD_DIR/save-analysis/emit-notifications/libemit_notifications.rlib","emit":"link"}

0 comments on commit efc30d0

Please sign in to comment.