Skip to content

Commit

Permalink
Support attributes in broadcast groups
Browse files Browse the repository at this point in the history
  • Loading branch information
jaybosamiya-ms committed Jun 15, 2024
1 parent 1ab5356 commit 0952bd2
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

* Support attributes in `broadcast group`s

# v0.3.6

* Support parsing empty requires/ensures/... clauses
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ fn to_doc<'a>(
Rule::use_tree => map_to_doc(ctx, arena, pair),
Rule::use_tree_list => comma_delimited(ctx, arena, pair, false).braces().group(),
Rule::broadcast_use_list => comma_delimited(ctx, arena, pair, false).group(),
Rule::broadcast_group_member => map_to_doc(ctx, arena, pair),
Rule::broadcast_group_list => comma_delimited(ctx, arena, pair, false).braces(),
Rule::fn_qualifier => map_to_doc(ctx, arena, pair),
Rule::fn_terminator => map_to_doc(ctx, arena, pair),
Expand Down
6 changes: 5 additions & 1 deletion src/verus.pest
Original file line number Diff line number Diff line change
Expand Up @@ -950,8 +950,12 @@ broadcast_group_identifier = {
identifier
}

broadcast_group_member = {
attr* ~ path
}

broadcast_group_list = {
"{" ~ (path ~ ("," ~ path)* ~ ","?)? ~ "}"
"{" ~ (broadcast_group_member ~ ("," ~ broadcast_group_member)* ~ ","?)? ~ "}"
}

broadcast_group = {
Expand Down
40 changes: 40 additions & 0 deletions tests/verus-consistency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2362,3 +2362,43 @@ verus! {
} // verus!
"###);
}

#[test]
fn verus_broadcast_group_with_attributes() {
let file = r#"
verus! {
#[cfg_attr(verus_keep_ghost, verifier::prune_unless_this_module_is_used)]
pub broadcast group group_hash_axioms { axiom_hash_map_contains_deref_key,
#[cfg(feature = "alloc")]
axiom_hash_map_contains_box,
axiom_hash_map_maps_deref_key_to_value,
#[cfg(feature = "alloc")]
#[some_other_attribute]
axiom_hash_map_maps_box_key_to_value,
axiom_primitive_types_have_deterministic_hash,
axiom_random_state_conforms_to_build_hasher_model,
axiom_spec_hash_map_len,
}
}
"#;

assert_snapshot!(parse_and_format(file).unwrap(), @r###"
verus! {
#[cfg_attr(verus_keep_ghost, verifier::prune_unless_this_module_is_used)]
pub broadcast group group_hash_axioms {
axiom_hash_map_contains_deref_key,
#[cfg(feature = "alloc")]
axiom_hash_map_contains_box,
axiom_hash_map_maps_deref_key_to_value,
#[cfg(feature = "alloc")]
#[some_other_attribute]
axiom_hash_map_maps_box_key_to_value,
axiom_primitive_types_have_deterministic_hash,
axiom_random_state_conforms_to_build_hasher_model,
axiom_spec_hash_map_len,
}
} // verus!
"###);
}

0 comments on commit 0952bd2

Please sign in to comment.