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

feat: allow custom names for proc macros #1781

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

remybar
Copy link

@remybar remybar commented Nov 26, 2024

At the moment, the macro name is the name of the function tagged with #[attribute_macro]/#[inline_macro]/#[derive_macro].

In Cairo, it is quite common to use the :: separator in macro names, but as this separator is not allowed in function names, we cannot use it for Cairo proc macros.

This PR adds string litteral argument to allow to set a custom name for a proc macros.

For example, here is a proc macro to process dojo::model attributes:

#[attribute_macro("dojo::model")
pub fn dojo_model(args: TokenStream, token_stream: TokenStream) -> ProcMacroResult {
}

At the moment, the macro name is the name of the function tagged with
`#[attribute_macro]/#[inline_macro]/#[derive_macro]`.

In Cairo, it is quite common to use the `::` separator in macro names,
but as this separator is not allowed in function names, we cannot use it
for Cairo proc macros.

This PR adds string litteral argument to allow to set a custom name for a
proc macros.

For example, here is a proc macro to process `dojo::model` attributes:
```rust
pub fn dojo_model(args: TokenStream, token_stream: TokenStream) -> ProcMacroResult {
}
```
@remybar remybar requested a review from a team as a code owner November 26, 2024 20:17
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.

1 participant