From 2a940fb5e0f9444d5940295e2643d60a5ada7b79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sch=C3=A4fer?= Date: Fri, 2 May 2025 16:28:47 +0200 Subject: [PATCH] xso-proc: work around regression in rustc nightly skip-changelog, this is no user-facing change. See-Also: https://github.com/rust-lang/rust/issues/140585 --- xso-proc/src/compound.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/xso-proc/src/compound.rs b/xso-proc/src/compound.rs index b4b31da6ee8341b169a1bcf221ef4739ccc5d2a6..802a3b45666714b655175d952d0e60f8cdd283a1 100644 --- a/xso-proc/src/compound.rs +++ b/xso-proc/src/compound.rs @@ -278,15 +278,29 @@ impl Compound { format!("{}", name_b) }; - let field_a = FieldName(&member_a).to_string(); - let field_b = FieldName(&member_b).to_string(); + // See TODO below for why we do the extra replace calls. + let attr_a = attr_a.replace('{', "{{").replace('}', "}}"); + let attr_b = attr_b.replace('{', "{{").replace('}', "}}"); + let field_a = FieldName(&member_a) + .to_string() + .replace('{', "{{") + .replace('}', "}}"); + let field_b = FieldName(&member_b) + .to_string() + .replace('{', "{{") + .replace('}', "}}"); // By assigning the checks to a `const`, we ensure that they // are in fact evaluated at compile time, even if that constant // is never used. checks.extend(quote_spanned! {span=> const _: () = { if #check { - panic!("member {} and member {} match the same XML attribute: {} == {}", #field_a, #field_b, #attr_a, #attr_b); + // TODO: Rust nightly from 2025-05-02 (or around that date) didn't like our fancy panic, so we use something simpler. + // Filed bug upstream: https://github.com/rust-lang/rust/issues/140585 + // For now, we work around this because it breaks our docs builds... + //panic!("member {} and member {} match the same XML attribute: {} == {}", #field_a, #field_b, #attr_a, #attr_b); + // Note that we cannot replace it with concat!(..), because we may have `{` and `}` in the strings... + panic!(concat!("member ", #field_a, " and member ", #field_b, " match the same XML attribute: ", #attr_a, " == ", #attr_b)); } }; }) }