Invert token iteration order in macro mapping

This commit is contained in:
Lukas Wirth 2024-10-25 13:29:07 +02:00
parent ca3699bd50
commit 20ac30fb75
8 changed files with 33 additions and 25 deletions

View file

@ -397,6 +397,7 @@ fn traverse(
Some(AttrOrDerive::Derive(_)) => inside_attribute,
None => false,
};
let descended_element = if in_macro {
// Attempt to descend tokens into macro-calls.
let res = match element {
@ -412,7 +413,7 @@ fn traverse(
let tok = tok.value;
let my_rank = ranker.rank_token(&tok);
if my_rank > 0b1110 {
if my_rank >= Ranker::MAX_RANK {
// a rank of 0b1110 means that we have found a maximally interesting
// token so stop early.
t = Some(tok);