-
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
Add support for use Trait::func
#17304
Comments
I don't see why this forces us to introduce trait data into DefMap. Since macros cannot be trait members, trait members cannot affect the fixpoint algorithm of name resolution. Therefore, we can stop as soon as we resolved the before-last segment to a trait, and maintain a list of "probably/should be trait assoc items" of TraitId and Names. We'll probably need to have a query to resolve them anyway (for diagnostics etc.), but that will be a very lightweight query that will not recompute the DefMap. |
I think my reasoning here was that we need to call Happy to be proven wrong though if my thinking is incorrect / or the problem can be avoided somehow! |
That would be a problem for your approach, but not mine, no? My entire point is that we don't call |
But then how will you access the associated items post expansion? The following is valid rust. macro_rules! f_maker {
() => { fn f() {} }
}
trait T {
f_maker!();
} |
Ah I guess this part is the workaround for it (deferring the full resolution to the end?) if I understood you correctly. That feels rather hacky to me though |
DefMap will expand the macro (as it expands all macros), but it won't (fully) resolve the import. Yes, this is a hack, but if the other approach proves to be to expensive we can try that. |
rust-lang/rfcs#3591 is likely to be introduced to the language, which will require some changes to our early name resolution, notably this change ties in trait assoc items into early name resolution so our corresponding
DefMap
query will have to collect and expand macros in trait assoc item position, replacing the currenttrait_data
query. This will unfortunately slow down def map creation and also invalidate it when trait assoc item signatures are changed but that's just the nature of moving things into early nameres. OTOH this does get rid of one of the more frequent queries which might slightly reduce memory usage/or improve perf in other ways.Note this hasn't been accepted yet so there is little reason to implement that right now.
The text was updated successfully, but these errors were encountered: