-
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
Separate foreign items in HIR #37713
Comments
Marking this as E-mentor. I'll give a short write-up here; happy to provide a more detailed one too upon request! The work that needs to be done is basically to model foreign items on impl items -- we would get a |
Something I've wanted to do for a while is just remove the pointless "foreign mod" nonsense in HIR. |
For someone who has never worked on anything hir-related... Could you give examples of Rust code that compiles down to:
|
|
So an |
Yes.
It's just a |
Thanks! Now some more questions, about what @eddyb said:
|
Yes.
Suppose we have a foreign module like this:
, then foreign items ( |
Does that mean that |
Yeah, the whole point of this exercise is to get rid of |
One question is whether we might want to have a bunch of imports that share some common information - AFAIK all the attributes on an cc @retep998 |
|
@retep998 Is the Ugh I guess lint scoping is a thing. I just don't want |
These associations are extracted pretty early on and stored in |
@retep998 @vadimcn I'm not sure it's feasible to lift "foreign items" to the surrounding scope, even if just because of the lint scoping issue, i.e. If we had a way of cheaply duplicating such attributes... maybe, but still. It's annoying because they're almost regular items, and having them separate from all the other items is complexity I'd like to get rid of. |
@aochagavia Are you working on this? If not, I'd like to try it. |
@nikomatsakis Did we even come to an consensus on this? It'd be nice not to have "foreign items". |
@cramertj Go ahead! I never figured out what exactly needed to happen, so I didn't even start working on it. |
@aochagavia If I understand @eddyb's comment correctly, it doesn't sound like there's been a decision as to what should be done. |
@eddyb to be perfectly honest, I've not been following the discussion that closely. I just read over it. I agree with your intuition that it would be nice to lift them, but there seem to be some practical hurdles in the way:
It seems to me that my original plan -- to keep the Ultimately it seems like |
Can we move them to |
Reordering slightly:
I considered this, but it seems not obviously good. e.g., it means that the HIR will not reflect the
This is sort of interesting-- since name resolution is already done, I guess we don't care too much. I'm still having trouble seeing the value here, I have to admit, over just making them item-like. Perhaps there is lots of code that gets simplified? I guess that compared to impl-item and trait-item, foreign-item seems like small potatoes. |
(But maybe we can think of an approach that works for all of those things?) |
Seems like this is not fully baked enough to be E-mentor. |
Solved by #79318. |
PR #37660 separates impl items from impls in the HIR for improved interaction with incremental compilation. It probably makes sense to separate foreign items in this way too -- not so much for improved incremental compilation precision, as because it makes the layout more analogous.
The text was updated successfully, but these errors were encountered: