Tweak fully_expand_fragment
loop.
Control flow never gets past the end of the `ExpandResult::Retry` match arm, due to the `span_bug` and the `continue`. Therefore, the code after the match can only be reached from the `ExpandResult::Ready` arm. This commit moves that code after the match into the `ExpandResult::Ready` arm, avoiding the need for the `continue` in the `ExpandResult::Retry` arm.
This commit is contained in:
parent
79c4d0202f
commit
3b6978196d
1 changed files with 9 additions and 11 deletions
|
@ -471,7 +471,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
||||||
self.cx.force_mode = force;
|
self.cx.force_mode = force;
|
||||||
|
|
||||||
let fragment_kind = invoc.fragment_kind;
|
let fragment_kind = invoc.fragment_kind;
|
||||||
let (expanded_fragment, new_invocations) = match self.expand_invoc(invoc, &ext.kind) {
|
match self.expand_invoc(invoc, &ext.kind) {
|
||||||
ExpandResult::Ready(fragment) => {
|
ExpandResult::Ready(fragment) => {
|
||||||
let mut derive_invocations = Vec::new();
|
let mut derive_invocations = Vec::new();
|
||||||
let derive_placeholders = self
|
let derive_placeholders = self
|
||||||
|
@ -503,13 +503,19 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
||||||
})
|
})
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
let (fragment, collected_invocations) =
|
let (expanded_fragment, collected_invocations) =
|
||||||
self.collect_invocations(fragment, &derive_placeholders);
|
self.collect_invocations(fragment, &derive_placeholders);
|
||||||
// We choose to expand any derive invocations associated with this macro
|
// We choose to expand any derive invocations associated with this macro
|
||||||
// invocation *before* any macro invocations collected from the output
|
// invocation *before* any macro invocations collected from the output
|
||||||
// fragment.
|
// fragment.
|
||||||
derive_invocations.extend(collected_invocations);
|
derive_invocations.extend(collected_invocations);
|
||||||
(fragment, derive_invocations)
|
|
||||||
|
progress = true;
|
||||||
|
if expanded_fragments.len() < depth {
|
||||||
|
expanded_fragments.push(Vec::new());
|
||||||
|
}
|
||||||
|
expanded_fragments[depth - 1].push((expn_id, expanded_fragment));
|
||||||
|
invocations.extend(derive_invocations.into_iter().rev());
|
||||||
}
|
}
|
||||||
ExpandResult::Retry(invoc) => {
|
ExpandResult::Retry(invoc) => {
|
||||||
if force {
|
if force {
|
||||||
|
@ -520,17 +526,9 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
||||||
} else {
|
} else {
|
||||||
// Cannot expand, will retry this invocation later.
|
// Cannot expand, will retry this invocation later.
|
||||||
undetermined_invocations.push((invoc, Some(ext)));
|
undetermined_invocations.push((invoc, Some(ext)));
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
progress = true;
|
|
||||||
if expanded_fragments.len() < depth {
|
|
||||||
expanded_fragments.push(Vec::new());
|
|
||||||
}
|
}
|
||||||
expanded_fragments[depth - 1].push((expn_id, expanded_fragment));
|
|
||||||
invocations.extend(new_invocations.into_iter().rev());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.cx.current_expansion = orig_expansion_data;
|
self.cx.current_expansion = orig_expansion_data;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue