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

Breaking change in the header! macro not documented #490

Closed
mhristache opened this issue Apr 30, 2015 · 9 comments · Fixed by #492
Closed

Breaking change in the header! macro not documented #490

mhristache opened this issue Apr 30, 2015 · 9 comments · Fixed by #492
Labels
A-headers Area: headers. C-bug Category: bug. Something is wrong. This is bad!

Comments

@mhristache
Copy link

I updated to 0.3.15 and my code is now failing due to changes in header! macro:

src/lib.rs:250:43: 250:44 error: unexpected end of macro invocation
src/lib.rs:250 header!{ (TenantId, "TenantId") => [String] }

This is most likely due to commits efd6c96 and a27e681 which are not listed as breaking changes.

With the new header! implementation It seems I must also add a dummy test function when implementing the header which is, IMHO, an unnecessary complication and makes the header! macro harder to use. E.g. for my example above:

header!{ (TenantId, "TenantId") => [String] test1 {} }

Is this the intended behaviour?

@mhristache
Copy link
Author

cc @pyfisch as he is the one which added the commits mentioned above

@seanmonstar
Copy link
Member

I'd say this was an oversight. We shouldn't have made a breaking change. A reason making it easier to miss is that all of our internal uses do include a test function.

I think part of a fix so as to make sure we don't break the exported header! macro in the future is to use it in the examples/ directory.

@seanmonstar seanmonstar added C-bug Category: bug. Something is wrong. This is bad! A-headers Area: headers. labels Apr 30, 2015
@pyfisch
Copy link
Contributor

pyfisch commented Apr 30, 2015

Sorry, I forgot to add BREAKING CHANGE warnings to the commits. The current behaviour is the intended behaviour.

It is impossible (I think so) to add optional parts to a macro without duplicating the definition, since every header should have tests this is no problem for the core of hyper. I think also external headers should have tests, they have been proven useful to discover bugs in header parsing and formatting inside hyper. Using the test_header! macro makes it really easy to test headers but it requires to be inside the header! macro. #489 will allow external code to use it in tests, but you can also write your own test functions inside the header! macro test section.

@seanmonstar
Copy link
Member

@pyfisch can't the macro be written such that without the test pattern, a dummy empty one is created?

macro_rules! header {
  ( $foo:ty $bar:ty ) => ( header! { $foo $bar test_dummy {} } )
}

@pyfisch
Copy link
Contributor

pyfisch commented Apr 30, 2015

@seanmonstar yes this will probably work.

@pyfisch
Copy link
Contributor

pyfisch commented Apr 30, 2015

There is one problem: you can't have multiple headers with no tests in one module, because there will be multiple test_dummy modules.

@mhristache
Copy link
Author

I guess you can append the identto the name of the test function as the ident has to be unique anyhow.

@pyfisch
Copy link
Contributor

pyfisch commented Apr 30, 2015

Joining identifiers like function or module names does not work.

@reem
Copy link
Contributor

reem commented May 1, 2015

grumbles something about macros not being hygienic even though they are supposed to be

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-headers Area: headers. C-bug Category: bug. Something is wrong. This is bad!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants