Repository: rust-cli/human-panic (language: rust)

Issue:
metadata! doesn't use $crate
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](https://github.com/rust-cli/human-panic/blob/b092bc3d4b6a166ceeae72159582a9d909d0601a/src/lib.rs#L72) 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](https://github.com/themaxdavitt/human-panic-metadata-poc)'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 `use`ing the type before invoking the macro, I just wanted to leave an issue about it in case someone else stumbles across this.


Discussion / hints:

Fix patch:
diff --git a/src/lib.rs b/src/lib.rs
index 7b195ba..db0f415 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -69,7 +69,7 @@ pub struct Metadata {
 #[macro_export]
 macro_rules! metadata {
     () => {
-        Metadata {
+        $crate::Metadata {
             version: env!("CARGO_PKG_VERSION").into(),
             name: env!("CARGO_PKG_NAME").into(),
             authors: env!("CARGO_PKG_AUTHORS").replace(":", ", ").into(),


Test patch: