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
This commit is contained in:
Jonas Schäfer 2025-05-02 16:28:47 +02:00
commit 2a940fb5e0

View file

@ -278,15 +278,29 @@ impl Compound {
format!("{}", name_b) format!("{}", name_b)
}; };
let field_a = FieldName(&member_a).to_string(); // See TODO below for why we do the extra replace calls.
let field_b = FieldName(&member_b).to_string(); 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 // By assigning the checks to a `const`, we ensure that they
// are in fact evaluated at compile time, even if that constant // are in fact evaluated at compile time, even if that constant
// is never used. // is never used.
checks.extend(quote_spanned! {span=> checks.extend(quote_spanned! {span=>
const _: () = { if #check { 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));
} }; } };
}) })
} }