Unauthorized import when calling a macro defined in an external box

I'm trying to implement my own HTTP header using the impl_header macro from the hypermarket, but it doesn't seem to be able to resolve the hyper::header module.

Here is my code:

 #[macro_use] extern crate hyper; use hyper::header; struct CustomHeader; impl_header!(CustomHeader, "value", String); 

And here is the compiler error:

 <hyper macros>:11:14: 11:20 error: unresolved import `header::HeaderFormat`. Maybe a missing `extern crate header`? <hyper macros>:11 Result { use header:: HeaderFormat ; self . fmt_header ( f ) } } } ^~~~~~ <hyper macros>:1:1: 11:67 note: in expansion of impl_header! lib.rs:4:1: 4:45 note: expansion site error: aborting due to previous error Could not compile `macro_issue`. 

Any clue why this is happening and how can I fix it?

thanks

0
source share
1 answer

I agree with Renato that this is a problem with hyper, and you should indicate an error (or even better request for transfer!). If you want to get around this for now, you can re-export header as your own:

 #[macro_use] extern crate hyper; pub use hyper::header as header; struct CustomHeader; impl_header!(CustomHeader, "value", String); fn main() {} 

Unfortunately, this simply opens up a whole new wave of errors that I will let you understand!

+1
source

All Articles