-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Pass the crate environment to proc macros #6820
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for some reason:
Does it makes sense to investigate further, to figure out what is the problem?
@@ -51,6 +51,9 @@ pub struct ExpansionTask { | |||
pub attributes: Option<Subtree>, | |||
|
|||
pub lib: PathBuf, | |||
|
|||
/// Environment variables to set during macro expansion. | |||
pub env: Vec<(String, String)>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would OsString
be a better fit here semantic-wise?
In analysis, we need to use String
s, because only that's compatible with env!
.
Here, the consumre is external process, so OsString might be better?
But mostly, this is irrelevant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's true. But they come from Env
, so we won't see non-UTF-8 variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, in similar cases I generally prefer to shape the interface to the shape of the external world, rather than to the shape of an internal impl.
It's less confusing to have some explicit glue code, than for two things share identical inteface by accident.
&self, | ||
subtree: &Subtree, | ||
attrs: Option<&Subtree>, | ||
env: &Env, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, yeah, I think this makes sense -- proc macro can observe compile-time env variables.
Maybe, yeah. It would be good to have more people familiar with how the proc macro server works, but it is very hard to understand. |
I am not familiar with how the proc macro server works either, but would like to help to find the problem. How could I reproduce the panic in description ? |
I've tried to use |
Why is this a draft? I have this branch installed and its been really helpful. |
Because we (and I) are still investigate how the panic is raised in the #6820 (comment) |
7047: Add force_show_panics flag for proc-macro bridge r=jonas-schievink a=edwin0cheng rust-lang/rust#75082 and rust-lang/rust#76292 added a new flag in `proc_macro::Bridge` such that the ABI was changed. These ABI changing are the reason of some weird panics which caused #6880 and maybe related to the panic mentioned in #6820. These changes are landed on rust stable 1.48 so I think it is okay to apply it now. fixes #6880 r @jonas-schievink Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
#7047 should be the cause of that panic and I think this PR could be okay now ? |
It's only used to break the dependency to proc_macro_api
Tested locally, this seems to work fine now! bors r+ |
In theory, fixes #6696.
This seems to result in these obscure crashes for some reason: