The error messages are not much better than before, but now at least give a hint of where to go next. Since it is now using the common error handling code, it should be much easier to improve going forward.
7JPOCQEISAIOD7LV4JYBE6NNUWUKKNE73MEPQYTIZ7PP44ZAD2RAC
73C6NOJ7W7ZCQ2THEZ4HXNZF3734VIPHI5VKQ2CCPLOA4L3JFIIQC
YZ6PVVQCLWYRFM33CH6BDB7U6BSP5PM5LH3FMKRXV3BH5KCRFM4AC
CESJ4CTO26X4GBZBPXRXLOJT3JQJOGFN5EJSNAAZELNQRZF7QSYAC
NFV26FRQF6JNR7WLU72HR7W2GDHLDGDPAX3CYHZLBQEACJ24AB4QC
K3G4HK2JH4MFDAMYD6N2AZONCHE7QYMQ3S4LAND3A5IAD7BHC5TAC
OWXLFLRMQDTXWN5QQQLJNAATWFWXIN2S4UQA2LC2A6AWX4UWM6LQC
O77KA6C4UJGZXVGPEA7WCRQH6XYQJPWETSPDXI3VOKOSRQND7JEQC
NO3PDO7PY7J3WPADNCS5VD6HKFY63E23I3SDR4DHXNVQJTG27RAAC
XGRU7WZEM6PTUCSHUA6QGNK7N34M7OPE52BTDC33BHSUEWM6B4FAC
4BMW4JJOJ3XKMSUXDGOG4QC6QPDBC4PBOD3M2RAQQPRAF3CSGXUQC
let locales = attribute::locales(attribute)?;
// Parse the token streams
let attribute: syn::LitStr = syn::parse2(attribute_stream)
.map_err(|parse_error| ParseError::InvalidAttribute(parse_error))?;
let derive_input: syn::DeriveInput = syn::parse2(derive_input_stream)
.map_err(|parse_error| ParseError::InvalidDeriveInput(parse_error))?;
let locales = attribute::locales(&attribute)?;
note = "There must be at least one named field (unit structs are unsupported!)"
note = "There must be at least one named field (unit structs are unsupported!)";
}
}
}
}
fn parse(error: ParseError, attribute_stream: TokenStream, derive_input_stream: TokenStream) {
match error {
ParseError::InvalidAttribute(invalid_attribute) => {
emit_error! { attribute_stream, invalid_attribute;
help = "Expected a path glob, for example {}",
r#"#[localize("i18n/**/strings.ftl")]"#;
}
}
ParseError::InvalidDeriveInput(invalid_derive_input) => {
emit_error! { derive_input_stream, invalid_derive_input;
help = "This macro can only be used on structs or enums";
let original_item = proc_macro2::TokenStream::from(item.clone());
let attribute_stream = proc_macro2::TokenStream::from(attribute.clone());
let derive_attribute: syn::LitStr = parse_macro_input!(attribute);
let derive_input = parse_macro_input!(item);
let attribute_stream = proc_macro2::TokenStream::from(attribute);
let derive_input_stream = proc_macro2::TokenStream::from(item);
let ident = derive_input.ident;
quote! {
#original_item
impl<W: ::std::io::Write> ::fluent_embed::Localize<W> for #ident {
const CANONICAL_LOCALE: ::fluent_embed::icu_locale::LanguageIdentifier =
::fluent_embed::icu_locale::langid!("en-US");
fn available_locales(&self) -> Vec<::fluent_embed::icu_locale::LanguageIdentifier> {
unimplemented!("Encountered error in derive macro")
}
match syn::parse2::<syn::DeriveInput>(derive_input_stream.clone()) {
Ok(derive_input) => {
let ident = derive_input.ident;
quote! {
#derive_input_stream
impl<W: ::std::io::Write> ::fluent_embed::Localize<W> for #ident {
const CANONICAL_LOCALE: ::fluent_embed::icu_locale::LanguageIdentifier =
::fluent_embed::icu_locale::langid!("en-US");
fn message_for_locale(
&self,
writer: &mut W,
locale: &::fluent_embed::icu_locale::LanguageIdentifier,
) -> Result<(), ::fluent_embed::LocalizationError> {
unimplemented!("Encountered error in derive macro")
fn available_locales(&self) -> Vec<::fluent_embed::icu_locale::LanguageIdentifier> {
unimplemented!("Encountered error in derive macro")
}
fn message_for_locale(
&self,
writer: &mut W,
locale: &::fluent_embed::icu_locale::LanguageIdentifier,
) -> Result<(), ::fluent_embed::LocalizationError> {
unimplemented!("Encountered error in derive macro")
}
}