Skip to content

Commit

Permalink
Rollup merge of rust-lang#61014 - jsgf:emit-artifact-type, r=alexcric…
Browse files Browse the repository at this point in the history
…hton

Make -Zemit-artifact-notifications also emit the artifact type

This is easier for tooling to handle than trying to reverse-engineer the type from the filename extension. The field name and value is intended to reflect the `--emit` command-line option.

Related issues rust-lang#60988 rust-lang#58465
cc @alexcrichton
  • Loading branch information
Centril authored May 22, 2019
2 parents 5ae36a8 + 6c38625 commit db96c83
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(sess: &'a Session,
}
}
if sess.opts.debugging_opts.emit_artifact_notifications {
sess.parse_sess.span_diagnostic.emit_artifact_notification(&out_filename);
sess.parse_sess.span_diagnostic.emit_artifact_notification(&out_filename, "link");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub trait Emitter {
/// Emit a notification that an artifact has been output.
/// This is currently only supported for the JSON format,
/// other formats can, and will, simply ignore it.
fn emit_artifact_notification(&mut self, _path: &Path) {}
fn emit_artifact_notification(&mut self, _path: &Path, _artifact_type: &str) {}

/// Checks if should show explanations about "rustc --explain"
fn should_show_explain(&self) -> bool {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_errors/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -769,8 +769,8 @@ impl Handler {
}
}

pub fn emit_artifact_notification(&self, path: &Path) {
self.emitter.borrow_mut().emit_artifact_notification(path);
pub fn emit_artifact_notification(&self, path: &Path, artifact_type: &str) {
self.emitter.borrow_mut().emit_artifact_notification(path, artifact_type);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/librustc_interface/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,8 @@ fn encode_and_write_metadata<'tcx>(
tcx.sess.fatal(&format!("failed to write {}: {}", out_filename.display(), e));
}
if tcx.sess.opts.debugging_opts.emit_artifact_notifications {
tcx.sess.parse_sess.span_diagnostic.emit_artifact_notification(&out_filename);
tcx.sess.parse_sess.span_diagnostic
.emit_artifact_notification(&out_filename, "metadata");
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/libsyntax/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ impl Emitter for JsonEmitter {
}
}

fn emit_artifact_notification(&mut self, path: &Path) {
let data = ArtifactNotification { artifact: path };
fn emit_artifact_notification(&mut self, path: &Path, artifact_type: &str) {
let data = ArtifactNotification { artifact: path, emit: artifact_type };
let result = if self.pretty {
writeln!(&mut self.dst, "{}", as_pretty_json(&data))
} else {
Expand Down Expand Up @@ -185,6 +185,8 @@ struct DiagnosticCode {
struct ArtifactNotification<'a> {
/// The path of the artifact.
artifact: &'a Path,
/// What kind of artifact we're emitting.
emit: &'a str,
}

impl Diagnostic {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/emit-artifact-notifications.nll.stderr
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"artifact":"$TEST_BUILD_DIR/emit-artifact-notifications.nll/libemit_artifact_notifications.rmeta"}
{"artifact":"$TEST_BUILD_DIR/emit-artifact-notifications.nll/libemit_artifact_notifications.rmeta","emit":"metadata"}
2 changes: 1 addition & 1 deletion src/test/ui/emit-artifact-notifications.stderr
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"artifact":"$TEST_BUILD_DIR/emit-artifact-notifications/libemit_artifact_notifications.rmeta"}
{"artifact":"$TEST_BUILD_DIR/emit-artifact-notifications/libemit_artifact_notifications.rmeta","emit":"metadata"}

0 comments on commit db96c83

Please sign in to comment.