-
Notifications
You must be signed in to change notification settings - Fork 14
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
Breaks under reexport #28
Comments
I added support for the same method as Regarding the method of making attributes unnecessary:
|
Thanks for responding so quickly.
Could we put this behind a feature flag "reexport" with documentation pointing out this issue.
I think this is not quite right. The linked example uses |
If I understand right this will be the right way to do this once stabilized EDIT: could this be used? https://docs.rs/proc-macro2/latest/proc_macro2/struct.Span.html#method.mixed_site |
Thanks for the explanation. I was worried that changing the behavior depending on the future flag would cause problems when the flag was turned on by other crates, but this seems to work fine.
Indeed it is. Another option would be to give up on exporting the macro directly with
It would be best if we could do something like I tried, but I could not use the crates listed in [ // sandbox_rust_macros/src/lib.rs
use proc_macro2::Span;
use quote::quote_spanned;
#[proc_macro]
pub fn ts_new(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
quote_spanned!(Span::def_site() => ::proc_macro2::TokenStream::new()).into()
} // main.rs
fn main() {
let x = sandbox_rust_macros::ts_new!();
}
Is there a way to use |
To be honest I don't really understand def_site. I was told I should keep an eye on this instead rust-lang/rust#54363, sadly It doesn't look like its happening any time soon. |
It seems to me that if the features suggested in the linked issue are available, the problem will be solved. I am also disappointed that it is not scheduled to be available soon, but I would like to use it as soon as it becomes available. |
I'd like to use this crate via a re-export in my workspace's common crate. The code generated here refers to ::parse-display, which will only exist if the crate has parse-display added to its Cargo.toml.
In other crates like serde and strum it is possible to get around this with a
#[serde(crate = "self::serde")]
. It should also be possible to eliminate the need for said attribute using a method like this, though I don't fully understand it yet. Relevant code snippetHow strum implements it
The text was updated successfully, but these errors were encountered: