Skip to content

Commit f9a53a6

Browse files
committed
Clearer error when the macro is used in a non-module item
Signed-off-by: Christian Poveda <[email protected]>
1 parent 7bbb49b commit f9a53a6

File tree

1 file changed

+2
-1
lines changed
  • cyclonedx-bom-macros/src

1 file changed

+2
-1
lines changed

cyclonedx-bom-macros/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ fn helper(
253253
annotated_item: TokenStream,
254254
) -> syn::Result<proc_macro2::TokenStream> {
255255
// This parses the module being annotated by the `#[versioned(..)]` attribute.
256-
let module = syn::parse::<syn::ItemMod>(annotated_item)?;
256+
let module = syn::parse::<syn::ItemMod>(annotated_item)
257+
.map_err(|err| Error::new(err.span(), format!("cannot parse module: {err}")))?;
257258

258259
// This parses the versions passed to the attribute, e.g. the `"1.3"`
259260
// and `"1.4"`in `#[versioned("1.3", "1.4")]

0 commit comments

Comments
 (0)