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

Support paths relative to the current file in query_file!() #11

Closed
abonander opened this issue Dec 28, 2019 · 5 comments
Closed

Support paths relative to the current file in query_file!() #11

abonander opened this issue Dec 28, 2019 · 5 comments
Labels
needs rust feature This issue or PR needs a Rust feature to be stabilized before it can be merged into master postponed

Comments

@abonander
Copy link
Collaborator

abonander commented Dec 28, 2019

This would require proc_macro::SourceFile to be stabilized (or a similar API): rust-lang/rust#54725

Probably would require fixing rust-lang/rust#62892

We could make it work on nightly using --cfg procmacro2_semver_exempt but that's a half-measure.

@abonander abonander added the needs rust feature This issue or PR needs a Rust feature to be stabilized before it can be merged into master label Jan 6, 2020
@de-vri-es
Copy link

You can also make it work on nightly by using proc_macro2::Span::unwrap to get a real proc_macro::Span and then use the feature gated API. I did something similar here.

That still can't support stable, but atleast it doesn't require all transitive reverse dependencies to build with --cfg procmacro2_semver_exempt.

It doesn't seem nice to introduce behavioural differences in the same macro between stable and nightly though. If it's important enough, it might be better to add the functionality to a separate macro only available on nightly, possibly with a feature.

@mehcode
Copy link
Member

mehcode commented Jan 12, 2020

The current paths are at least cargo workspace relative.. for me, that's good enough to not want to do anything until we can do it properly.

@mehcode
Copy link
Member

mehcode commented Mar 24, 2020

It looks like we can support this soon once rust-lang/rust#69041 lands

@abonander
Copy link
Collaborator Author

That doesn't give us a stable way to get the path still.

@mehcode
Copy link
Member

mehcode commented Dec 31, 2020

This doesn't seem like its going to happen in Rust in the near future so I'm going to mark this postponed and close. We just need to make sure our work-arounds are well documented and we're fine I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs rust feature This issue or PR needs a Rust feature to be stabilized before it can be merged into master postponed
Projects
None yet
Development

No branches or pull requests

3 participants