-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Tracking issue for Span::def_site()
#54724
Comments
This is likely highly related to #54727 as well |
Hygiene serialization was implemented in #72121. This ensures that items with def-site hygiene are not visible from another crate. |
What's this blocked on? |
This needs more tests, especially for cross-crate cases. Any bugs found from that would have to be fixed and any unexpected behavior would need to be reviewed. |
It would be helpful to understand what EDIT: based on my reading of #68716, I think what def_side does for proc macros is essentially introducing a fresh hygiene context. For macro rules, it would also make def-site names available, but for proc-macros def-site is essentially empty. |
Reviewed this in our @rust-lang/lang backlog bonanza. We are tagging this as "needs summary" because, while we'd love to see this stabilized, most of us weren't really sure what "def-site" was supposed to mean -- i.e., this needs more than new tests, we need some kind of docs about the intended effect that can be reviewed. |
I'm a noob, but recently while experimenting with proc_macro I discovered a specific circumstance where def_site works and call_site doesn't. Here is the repo. I created 3 proc_macro's. In
In
Running the code works, but you must compile with
If you change
We now get compile errors, because there are multiple definitions of
I'm positive what I've pointed out is known by most people looking at this issue, but for those that aren't experts this might be clarifying. Something like this could be added to the documentation. I'm willing to provide a PR after getting feedback. |
Raising for awareness: Def site hygiene has some odd properties with fields (and enum variants) by allowing them to have non-unique names which makes sense, but at the same time yields some very confusing results in regards to diagnostics and more importantly derives (this breaks serde de/serialization in very funny ways), #![feature(decl_macro)]
macro m($s:ident, $field:ident) {
#[derive(Debug, Default)]
struct $s {
field: u32,
$field: u32
}
}
m!(S, field);
fn main() {
println!("{:?}", S::default());
} |
This is a tracking issue for the
Span::def_site()
API. The feature for this isproc_maro_def_site
. Thedef_site
span primarily relates to hygiene today in that it's not copy-paste hygiene.This is likely blocked on larger hygiene reform and more thorny Macros 2.0 issues. I'm not personally clear on what the blockers are at this time, but I wanted to make sure we had a dedicated tracking issue!
cc #45934
The text was updated successfully, but these errors were encountered: