Auto merge of #61052 - jsgf:emit-save-analysis-notifications, r=alexcrichton

Emit save analysis notifications

Addresses issue https://github.com/rust-lang/rust/issues/61047
This commit is contained in:
bors 2019-06-11 02:25:39 +00:00
commit efc30d0cda
4 changed files with 26 additions and 8 deletions

View File

@ -1016,7 +1016,7 @@ pub fn new(odir: Option<&'a Path>, cratename: &str) -> 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),
@ -1054,7 +1054,7 @@ fn output_file(&self, ctx: &SaveContext<'_, '_>) -> File {
|e| sess.fatal(&format!("Could not open {}: {}", file_name.display(), e)),
);
output_file
(output_file, file_name)
}
}
@ -1066,13 +1066,23 @@ fn save<'l, 'tcx>(
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");
}
}
}

View File

@ -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"}

View File

@ -0,0 +1,4 @@
// compile-pass
// compile-flags: -Zsave-analysis -Zemit-artifact-notifications
// compile-flags: --crate-type rlib --error-format=json
pub fn foo() {}

View File

@ -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"}