From 18bdfb545416730b1fc0fc33c92df9385a36f2ab Mon Sep 17 00:00:00 2001 From: Max Johnson Date: Fri, 6 Mar 2026 12:19:42 -0800 Subject: [PATCH] build: patch rules_rust process_wrapper metadata handling Co-authored-by: Codex --- MODULE.bazel | 6 ++++++ ...ules_rs_process_wrapper_emit_metadata.patch | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 patches/rules_rs_process_wrapper_emit_metadata.patch diff --git a/MODULE.bazel b/MODULE.bazel index f55bd1f26d..927680c5c2 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -42,6 +42,12 @@ bazel_dep(name = "rules_platform", version = "0.1.0") bazel_dep(name = "rules_rs", version = "0.0.40") rules_rust = use_extension("@rules_rs//rs/experimental:rules_rust.bzl", "rules_rust") +rules_rust.patch( + patches = [ + "//patches:rules_rs_process_wrapper_emit_metadata.patch", + ], + strip = 1, +) use_repo(rules_rust, "rules_rust") toolchains = use_extension("@rules_rs//rs/experimental/toolchains:module_extension.bzl", "toolchains") diff --git a/patches/rules_rs_process_wrapper_emit_metadata.patch b/patches/rules_rs_process_wrapper_emit_metadata.patch new file mode 100644 index 0000000000..3455c7fbd1 --- /dev/null +++ b/patches/rules_rs_process_wrapper_emit_metadata.patch @@ -0,0 +1,18 @@ +diff --git a/util/process_wrapper/rustc.rs b/util/process_wrapper/rustc.rs +index ddb82c9..69052ce 100644 +--- a/util/process_wrapper/rustc.rs ++++ b/util/process_wrapper/rustc.rs +@@ -64,10 +64,12 @@ pub(crate) fn process_json(line: String, error_format: ErrorFormat) -> LineResult { + let parsed: JsonValue = line + .parse() + .map_err(|_| "error parsing rustc output as json".to_owned())?; + Ok(match parsed.try_into() { ++ Ok(RustcMessage::Emit(emit)) if emit == "metadata" => LineOutput::Terminate, ++ Ok(RustcMessage::Emit(_)) => LineOutput::Skip, + Ok(RustcMessage::Message(rendered)) => { + output_based_on_error_format(line, rendered, error_format) + } +- _ => LineOutput::Skip, ++ Err(()) => LineOutput::Skip, + }) + }