-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
[rustdoc] Fix invalid handling of field followed by negated macro call #150099
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: main
Are you sure you want to change the base?
Conversation
1047c0f to
851f169
Compare
| .copied() | ||
| } | ||
|
|
||
| fn peek_next_if<F: Fn((TokenKind, &'a str)) -> bool>( |
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.
So in case we don't find the item we're interested in, we don't want the item to impact the "peeked" items position, so I needed to write this function to "put back the item" in case it didn't match the condition.
| for _ in 0..nb_items { | ||
| if let Some((_, text, _)) = classifier.next() { | ||
| len += text.len(); | ||
| } |
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.
Code doesn't need this continue anymore and that makes it much simpler to understand (so yeah, kinda congratulating myself here ^^').
| let mut nb_items = 0; | ||
|
|
||
| loop { | ||
| let ret = loop { |
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.
We don't return in this loop because we need to call stop_peeking before exiting this function. So instead, we break the value to return, call stop_peeking and then actually return. Not super graceful but it works.
This is the bug uncovered in #150022. Once fixed Ill rebuild all compiler docs and see if we can enable the option for compiler docs. =D
It's a weird case where we extracted some tokens out of the iterator and then, when checking next items (from this iterator), it didn't find the
:token, and therefore badly assumed the token kind.The solution I came up with is to instead not extract tokens from the iterator and to count how many tokens are in the current path. So when iterate over the items, instead of having a mix of extracted tokens and tokens still inside the iterator, we now only iterate over the iterator.
The biggest change here is that
get_full_ident_pathwill return an option instead of aVec, and if it's contains:(one, not two), then it will returnNoneand the:will be handled like any token and not like a path (which is more correct imo).r? @yotamofek