Skip to content

Commit e4e97ca

Browse files
authored
Rollup merge of rust-lang#61014 - jsgf:emit-artifact-type, r=alexcrichton
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
2 parents 30d550d + 6c38625 commit e4e97ca

File tree

7 files changed

+12
-9
lines changed

7 files changed

+12
-9
lines changed

src/librustc_codegen_ssa/back/link.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(sess: &'a Session,
9696
}
9797
}
9898
if sess.opts.debugging_opts.emit_artifact_notifications {
99-
sess.parse_sess.span_diagnostic.emit_artifact_notification(&out_filename);
99+
sess.parse_sess.span_diagnostic.emit_artifact_notification(&out_filename, "link");
100100
}
101101
}
102102

src/librustc_errors/emitter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub trait Emitter {
5656
/// Emit a notification that an artifact has been output.
5757
/// This is currently only supported for the JSON format,
5858
/// other formats can, and will, simply ignore it.
59-
fn emit_artifact_notification(&mut self, _path: &Path) {}
59+
fn emit_artifact_notification(&mut self, _path: &Path, _artifact_type: &str) {}
6060

6161
/// Checks if should show explanations about "rustc --explain"
6262
fn should_show_explain(&self) -> bool {

src/librustc_errors/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,8 @@ impl Handler {
769769
}
770770
}
771771

772-
pub fn emit_artifact_notification(&self, path: &Path) {
773-
self.emitter.borrow_mut().emit_artifact_notification(path);
772+
pub fn emit_artifact_notification(&self, path: &Path, artifact_type: &str) {
773+
self.emitter.borrow_mut().emit_artifact_notification(path, artifact_type);
774774
}
775775
}
776776

src/librustc_interface/passes.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,8 @@ fn encode_and_write_metadata<'tcx>(
10501050
tcx.sess.fatal(&format!("failed to write {}: {}", out_filename.display(), e));
10511051
}
10521052
if tcx.sess.opts.debugging_opts.emit_artifact_notifications {
1053-
tcx.sess.parse_sess.span_diagnostic.emit_artifact_notification(&out_filename);
1053+
tcx.sess.parse_sess.span_diagnostic
1054+
.emit_artifact_notification(&out_filename, "metadata");
10541055
}
10551056
}
10561057

src/libsyntax/json.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ impl Emitter for JsonEmitter {
9292
}
9393
}
9494

95-
fn emit_artifact_notification(&mut self, path: &Path) {
96-
let data = ArtifactNotification { artifact: path };
95+
fn emit_artifact_notification(&mut self, path: &Path, artifact_type: &str) {
96+
let data = ArtifactNotification { artifact: path, emit: artifact_type };
9797
let result = if self.pretty {
9898
writeln!(&mut self.dst, "{}", as_pretty_json(&data))
9999
} else {
@@ -185,6 +185,8 @@ struct DiagnosticCode {
185185
struct ArtifactNotification<'a> {
186186
/// The path of the artifact.
187187
artifact: &'a Path,
188+
/// What kind of artifact we're emitting.
189+
emit: &'a str,
188190
}
189191

190192
impl Diagnostic {
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"artifact":"$TEST_BUILD_DIR/emit-artifact-notifications.nll/libemit_artifact_notifications.rmeta"}
1+
{"artifact":"$TEST_BUILD_DIR/emit-artifact-notifications.nll/libemit_artifact_notifications.rmeta","emit":"metadata"}
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"artifact":"$TEST_BUILD_DIR/emit-artifact-notifications/libemit_artifact_notifications.rmeta"}
1+
{"artifact":"$TEST_BUILD_DIR/emit-artifact-notifications/libemit_artifact_notifications.rmeta","emit":"metadata"}

0 commit comments

Comments
 (0)