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

Make derive macros work outside of rune #530

Closed
ModProg opened this issue May 27, 2023 · 4 comments · Fixed by #532
Closed

Make derive macros work outside of rune #530

ModProg opened this issue May 27, 2023 · 4 comments · Fixed by #532

Comments

@ModProg
Copy link
Contributor

ModProg commented May 27, 2023

Make derive macros work outside rune such as derive(Parse). To do this one can use either https://docs.rs/proc-macro-crate/latest/proc_macro_crate/ directly or a more complicated approach like here: https://github.com/khonsulabs/bonsaidb/blob/448db4d32ea065aa39b1c4731c0e5b9d5ffce83b/crates/bonsaidb-macros/src/lib.rs#L35-L61 to get more control about it.

@udoprog
Copy link
Collaborator

udoprog commented May 27, 2023

From #531, what is the specific problem you're having?

@udoprog
Copy link
Collaborator

udoprog commented May 27, 2023

Ah, is it that the Parse, Spanned, ... macros use crate:: as a prefix? This can be fixed by:

  • Changing the context to now not use the with_crate constructor - then it will use rune:: instead.
  • Re-export pub(crate) use crate as rune in the ast::prelude.

That should cover the vast majority of uses for those derives.

@ModProg
Copy link
Contributor Author

ModProg commented May 27, 2023

* Changing the context to now use the `with_crate` constructor - then it will use `rune::` instead.

you mean to not use it? because with_crate is the issue, it makes the context use crate:: or do you mean update with_crate to use rune::?

@udoprog
Copy link
Collaborator

udoprog commented May 27, 2023

Right, s/now/not!

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.

2 participants