-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Add method find_ancestor_not_from_macro
and find_ancestor_not_from_extern_macro
to fix find_oldest_ancestor_in_same_ctxt
#144268
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
base: master
Are you sure you want to change the base?
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.
Hm, I'm not actually 100% this helper is doing what I originally wanted it to do... This will try to keep traversing up the macro invocation chain that produced the provided final span
at hand to find the oldest ancestor which has... the same syntax context as the provided final span
(???) I suppose this might work if the passed in span
you know is "local" and the user actually has control over 🤔
I feel like this is wrong, or least quite confusing... I wonder if you could go the other direction and use instead https://doc.rust-lang.org/nightly/nightly-rustc/rustc_span/struct.Span.html#method.find_ancestor_in_same_ctxt or https://doc.rust-lang.org/nightly/nightly-rustc/rustc_span/struct.Span.html#method.find_ancestor_inside_same_ctxt and get rid of this helper.
@rustbot author (re. discussion) |
Reminder, once the PR becomes ready for a review, use |
I found some problems with the comments of these APIs, I subconsciously thought that finding an ancestor would be traversing the macro expansion chain from bottom to top, but they all use “walk down”. This seems to create ambiguity. I'll look into these APIs later when I have time and find the best way to do it. |
a2a1033
to
2f977ce
Compare
find_oldest_ancestor_in_same_ctxt
find_ancestor_not_from_macro
and find_ancestor_not_from_extern_macro
to fix find_oldest_ancestor_in_same_ctxt
I found that I added two methods that allow for more fine-grained control. This change should help fix all the diagnostics shown in the macros in the standard library(#142403). @rustbot ready |
This comment has been minimized.
This comment has been minimized.
Signed-off-by: xizheyin <[email protected]>
2f977ce
to
66d2d16
Compare
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, is it possible to add specific test cases demonstrating the behaviors of
find_ancestor_not_from_macro
find_ancestor_not_from_extern_macro
find_oldest_ancestor_in_same_ctxt
Otherwise, we'd have no idea what effect changing the impls of these helpers might be.
As I was using it, I realized that the function is supposed to walk up to expand the chain? This seems to be the opposite of what I understood.
r? @jieyouxu