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

Add local_inner_macros to all helper macros #233

Merged
merged 1 commit into from
Aug 26, 2018

Conversation

ubnt-intrepid
Copy link
Contributor

It allows to use the Rust2018-style macro imports correctly:

use juniper::graphql_object;

graphql_object!(User: () |&self| { ... });

In the future when dropping compatibility with pre-2018 compilers, it is able to be replaced with the explicit $crate prefixes instead of local_inner_macros.

Notes

In macro_rules! with the annotation local_inner_macros, all of macro calls are transformed into $crate::builtin!(...) (rust-lang/rust#53464 (comment)). Therefore, name resolutions of built-in macros are not perfomed correctly.
To avoid such situation, some helper macros are introduced to make built-in macros be interpreted as crate-local macros.

It allows to use the Rust2018-style macro imports correctly:

```rust
use juniper::graphql_object;

graphql_object!(User: () |&self| { ... });
```

In the future when dropping compatibility with pre-2018 compilers,
it is able to be replaced with the explicit `$crate` prefixes instead of
`local_inner_macros`.

In `macro_rules!` with the annotation `local_inner_macros`, all of macro calls
are transformed into `$crate::builtin!(...)` (See [1] for details).
Therefore, name resolutions of built-in macros are not perfomed correctly.
To avoid such situation, some helper macros are introduced to make built-in
macros be interpreted as crate-local macros.

[1]: rust-lang/rust#53464 (comment)
@codecov-io
Copy link

codecov-io commented Aug 26, 2018

Codecov Report

Merging #233 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #233      +/-   ##
==========================================
- Coverage   89.89%   89.88%   -0.01%     
==========================================
  Files          96       96              
  Lines       18167    18153      -14     
==========================================
- Hits        16331    16317      -14     
  Misses       1836     1836
Impacted Files Coverage Δ
juniper/src/macros/interface.rs 100% <ø> (ø) ⬆️
juniper/src/macros/args.rs 100% <ø> (ø) ⬆️
juniper/src/macros/scalar.rs 100% <ø> (ø) ⬆️
juniper/src/macros/object.rs 97.67% <ø> (ø) ⬆️
juniper/src/macros/union.rs 100% <ø> (ø) ⬆️
juniper/src/macros/field.rs 88.23% <100%> (ø) ⬆️
juniper/src/util.rs 96.29% <0%> (-3.71%) ⬇️
juniper/src/integrations/serde.rs 49.28% <0%> (-1.64%) ⬇️
juniper_codegen/src/util.rs 77.65% <0%> (-0.42%) ⬇️
juniper/src/lib.rs 84.61% <0%> (-0.24%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 273edc1...4a009a9. Read the comment docs.

Copy link
Member

@LegNeato LegNeato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet, thanks for the PR! 🍻

@LegNeato LegNeato merged commit d496220 into graphql-rust:master Aug 26, 2018
@ubnt-intrepid ubnt-intrepid deleted the local-inner-macros branch August 26, 2018 19:31
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 this pull request may close these issues.

3 participants