Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metadata! doesn't use $crate #91

Closed
themaxdavitt opened this issue Feb 27, 2023 · 0 comments · Fixed by #98
Closed

metadata! doesn't use $crate #91

themaxdavitt opened this issue Feb 27, 2023 · 0 comments · Fixed by #98

Comments

@themaxdavitt
Copy link

themaxdavitt commented Feb 27, 2023

I'm trying to create my own panic hook using the reporting mechanism from this crate but with my own error message. Something like this:

https://github.com/themaxdavitt/human-panic-metadata-poc/blob/c1ce95c11449018aa4f3bde9868a34d54798d110/wrapper/src/lib.rs#L24-L33

However, currently the metadata! macro refers to the Metadata struct without using $crate to help the compiler know where that Metadata type is defined, leading to the following error:

error[E0422]: cannot find struct, variant or union type `Metadata` in this scope
 --> user/src/bin/broken.rs:4:5
  |
4 |     wrapper::broken_custom_panic_hook!();
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
  |

If I replace the metadata! invocation with the contents of the macro itself (using $crate to refer to the Metadata type to populate), it compiles as expected:

https://github.com/themaxdavitt/human-panic-metadata-poc/blob/c1ce95c11449018aa4f3bde9868a34d54798d110/wrapper/src/lib.rs#L7-L21


Here's the repo I created demonstrating this. Let me know if you have any questions and thanks for maintaining this crate!

EDIT: I know this is pretty minor, and can easily be fixed by just useing the type before invoking the macro, I just wanted to leave an issue about it in case someone else stumbles across this.

epage added a commit to epage/human-panic that referenced this issue Mar 15, 2023
@epage epage closed this as completed in #98 Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant