Move inner_attr code downwards.

This puts it just before the `replace_ranges` initialization, which
makes sense because the two variables are closely related.
This commit is contained in:
Nicholas Nethercote 2024-07-15 10:33:21 +10:00
parent 1f67cf9e63
commit f9c7ca70cb

View file

@ -256,16 +256,6 @@ impl<'a> Parser<'a> {
return Ok(ret);
}
let mut inner_attr_replace_ranges = Vec::new();
// Take the captured ranges for any inner attributes that we parsed.
for inner_attr in ret.attrs().iter().filter(|a| a.style == ast::AttrStyle::Inner) {
if let Some(attr_range) = self.capture_state.inner_attr_ranges.remove(&inner_attr.id) {
inner_attr_replace_ranges.push((attr_range, None));
} else {
self.dcx().span_delayed_bug(inner_attr.span, "Missing token range for attribute");
}
}
let replace_ranges_end = self.capture_state.replace_ranges.len();
assert!(
@ -283,6 +273,16 @@ impl<'a> Parser<'a> {
let num_calls = end_pos - start_pos;
// Take the captured ranges for any inner attributes that we parsed.
let mut inner_attr_replace_ranges = Vec::new();
for inner_attr in ret.attrs().iter().filter(|a| a.style == ast::AttrStyle::Inner) {
if let Some(attr_range) = self.capture_state.inner_attr_ranges.remove(&inner_attr.id) {
inner_attr_replace_ranges.push((attr_range, None));
} else {
self.dcx().span_delayed_bug(inner_attr.span, "Missing token range for attribute");
}
}
// This is hot enough for `deep-vector` that checking the conditions for an empty iterator
// is measurably faster than actually executing the iterator.
let replace_ranges: Box<[ReplaceRange]> =