Skip to content

Commit ea257a0

Browse files
authored
Replace the use of extract_if in builtin_macros, since it was only recently stabilized (#1805)
Replace the use of `extract_if`, which was only recently stabilized. The replacement code comes from the [`extract_if` documentation](https://doc.rust-lang.org/beta/std/vec/struct.Vec.html#method.extract_if)
1 parent a4095d8 commit ea257a0

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

source/builtin_macros/src/syntax.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,14 +1701,19 @@ impl Visitor {
17011701
.iter()
17021702
.map(|path| {
17031703
let mut path = path.clone();
1704-
let attrs = path
1705-
.attrs
1706-
.extract_if(0..path.attrs.len(), |attr| {
1707-
// move any cfg attrs from path to the stmt
1708-
attr.path().get_ident().map(|i| i.to_string())
1709-
== Some("cfg".to_string())
1710-
})
1711-
.collect();
1704+
let mut attrs = Vec::new();
1705+
// move any cfg attrs from path to the stmt
1706+
let mut i = 0;
1707+
while i < path.attrs.len() {
1708+
if path.attrs[i].path().get_ident().map(|i| i.to_string())
1709+
== Some("cfg".to_string())
1710+
{
1711+
let elt = path.attrs.remove(i);
1712+
attrs.push(elt);
1713+
} else {
1714+
i += 1;
1715+
}
1716+
}
17121717
let block = Expr::Verbatim(quote_spanned_builtin!(builtin, span => {
17131718
#[verus::internal(reveal_fn)] fn __VERUS_REVEAL_INTERNAL__() {
17141719
#builtin::reveal_hide_internal_path_(#path)

0 commit comments

Comments
 (0)