Highlights source location data for each error in wax::BuildError::locations()
, and forwards the (minimal) error message given as a help
annotation.
VYPJUPPKPVSIDCQPKZE2RJLMUQDI2IYV5COBQAEXI3VF3SF4CQTAC
GlobError::Build(_build_error) => todo!(),
GlobError::Build(build_error) => {
for location in build_error.locations() {
// Create a token stream from the attribute's string literal
let [proc_macro2::TokenTree::Literal(ref string_literal)] =
derive_attribute
.to_token_stream()
.into_iter()
.collect::<Vec<_>>()[..]
else {
abort!(derive_attribute, "unexpected macro attribute");
};
let (span_start, span_length) = location.span();
let error_source = string_literal
// Offset by 1 to skip the starting `"` double-quote character
.subspan(span_start + 1..=span_start + span_length)
// Fall back to the whole attribute if `subspan()` returns `None`
// This will always happend on stable as subspan is nightly-only:
// https://docs.rs/proc-macro2/latest/proc_macro2/struct.Literal.html#method.subspan
.unwrap_or(derive_attribute.span());
emit_error! { error_source, "invalid glob";
note = location.to_string();
};
}
}