educe/trait_handlers/partial_eq/
panic.rs1use quote::ToTokens;
2use syn::{spanned::Spanned, Meta};
3
4#[inline]
5pub(crate) fn union_without_unsafe(meta: &Meta) -> syn::Error {
6 let mut s = meta.into_token_stream().to_string();
7
8 match s.len() {
9 9 => s.push_str("(unsafe)"),
10 11 => s.insert_str(10, "unsafe"),
11 _ => unreachable!(),
12 }
13
14 syn::Error::new(
15 meta.span(),
16 format!(
17 "a union's `PartialEq` implementation is not precise, because it ignores the type of \
18 fields\n* If your union doesn't care about that, use `#[educe({s})]` to implement \
19 the `PartialEq` trait for it."
20 ),
21 )
22}