Skip to content

Commit

Permalink
"Handle" macro_rules
Browse files Browse the repository at this point in the history
  • Loading branch information
parno committed Nov 16, 2023
1 parent 169c528 commit 7345329
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
21 changes: 19 additions & 2 deletions examples/wip.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
verus! {

trait KeyTrait: Sized {
fn zero_spec() -> Self where Self: std::marker::Sized;
#[allow(unused_macros)]
macro_rules! no_usize_overflows {
($e:expr,) => {
true
};
($($e:expr),*) => {
no_usize_overflows!(@@internal 0, $($e),*)
};
(@@internal $total:expr,) => {
true
};
(@@internal $total:expr, $a:expr) => {
usize::MAX - $total >= $a
};
(@@internal $total:expr, $a:expr, $($rest:expr),*) => {
usize::MAX - $total >= $a
&&
no_usize_overflows!(@@internal ($total + $a), $($rest),*)
};
}

} // verus!
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ fn to_doc<'a>(
// Items //
//*************************//
Rule::item => map_to_doc(ctx, arena, pair),
Rule::macro_rules => unsupported(pair),
Rule::macro_rules => s, // Don't attempt to format macro rules
Rule::macro_def => unsupported(pair),
Rule::module => unsupported(pair),
Rule::item_list => unsupported(pair),
Expand Down

0 comments on commit 7345329

Please sign in to comment.