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

Unresolved import when trying to use impl_header! #323

Closed
mhristache opened this issue Feb 17, 2015 · 3 comments · Fixed by #325
Closed

Unresolved import when trying to use impl_header! #323

mhristache opened this issue Feb 17, 2015 · 3 comments · Fixed by #325

Comments

@mhristache
Copy link

I am trying to implement a custom HTTP header using impl_header macro from hyper crate but it seems it cannot resolve the hyper::header module.

Here is my code:

#[macro_use] extern crate hyper;

use hyper::header;

struct CustomHeader(String);
impl_header!(CustomHeader, "name", 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`.
@seanmonstar
Copy link
Member

Tried against master? I think a fix for this was merged in this morning (so
hasn't been published via cargo yet).

On Tue, Feb 17, 2015, 12:34 PM maximih notifications@github.com wrote:

I am trying to implement a custom HTTP header using impl_header macro from
hyper crate but it seems it cannot resolve the hyper::header module.

Here is my code:

#[macro_use] extern crate hyper;

use hyper::header;

struct CustomHeader(String);
impl_header!(CustomHeader, "name", String);

And here is the compiler error:

:11:14: 11:20 error: unresolved import header::HeaderFormat. Maybe a missing extern crate header?
:11 Result { use header:: HeaderFormat ; self . fmt_header ( f ) } } }
^~~~~~
: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.


Reply to this email directly or view it on GitHub
#323.

@mhristache
Copy link
Author

Seems parts of it was fixed on master but there is one issue left (check use header::HeaderFormat; below) causing the whole macro to fail:

    impl ::std::fmt::Display for $from {
        fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
            use header::HeaderFormat;
            self.fmt_header(f)
        }
    }

<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 ) } } }

@naps62
Copy link

naps62 commented Feb 19, 2015

I'm getting the exact same issue. Also tried against master, resulting in the same partial fix

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.

3 participants