Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For loops #954

Merged
merged 21 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0b8ce08
In lifetime_generate, only select from all_impls(trait_id) on demand
Chris-Hawblitzel Dec 12, 2023
bda76f8
Support into_iter for Range
Chris-Hawblitzel Dec 13, 2023
d1085d2
Mark feature(step_trait) as cfg_attr(verus_keep_ghost)
Chris-Hawblitzel Dec 13, 2023
65847ae
Initial support for for-loops
Chris-Hawblitzel Jan 3, 2024
5b89140
For for-loops, keep ghost iterator separate from exec iterator
Chris-Hawblitzel Jan 5, 2024
31cd01f
Refactor syntax macro visit order on loop invariants
Chris-Hawblitzel Jan 5, 2024
01bac5f
Switch some parse_quote_spanned to Verbatim quote_spanned
Chris-Hawblitzel Jan 5, 2024
7187d6b
Add Vec custom iterator example
Chris-Hawblitzel Jan 5, 2024
6d66cc1
Remove old ignored test
Chris-Hawblitzel Jan 9, 2024
7a36030
Rewrite InferSpecForLoopIter in modes not in ast_simplify
Chris-Hawblitzel Jan 9, 2024
8e0b755
Push/pop modes.rs state around InferSpecForLoopIter
Chris-Hawblitzel Jan 9, 2024
635e34c
Limit axiom_spec_range_next to specific types
Chris-Hawblitzel Jan 10, 2024
f6ab69e
Replace ghost_condition with ghost_ensures
Chris-Hawblitzel Jan 10, 2024
f12572c
Merge branch 'main' into for-loop
Chris-Hawblitzel Jan 11, 2024
569b870
Add ret_mode to TypingSnapshot
Chris-Hawblitzel Jan 11, 2024
5b2a059
Fix comment and panic message
Chris-Hawblitzel Jan 11, 2024
b602bfe
Return Option from ghost_peek_next and ghost_decrease
Chris-Hawblitzel Jan 17, 2024
7393ae1
Update loops.rs test with more precise ghost_peek_next
Chris-Hawblitzel Jan 17, 2024
1fe732a
Match for loop translation from https://doc.rust-lang.org/reference/e…
Chris-Hawblitzel Jan 20, 2024
e062d0a
Refactor state in modes.rs (#961)
Chris-Hawblitzel Jan 24, 2024
7aa5217
Merge branch 'main' into for-loop
Chris-Hawblitzel Jan 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions dependencies/syn/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,10 @@ ast_struct! {
pub for_token: Token![for],
pub pat: Pat,
pub in_token: Token![in],
pub expr_name: Option<Box<(Ident, Token![:])>>,
pub expr: Box<Expr>,
pub invariant: Option<Invariant>,
pub decreases: Option<Decreases>,
pub body: Block,
}
}
Expand Down Expand Up @@ -2435,7 +2438,14 @@ pub(crate) mod parsing {
let pat = pat::parsing::multi_pat_with_leading_vert(input)?;

let in_token: Token![in] = input.parse()?;
let expr_name = if input.peek2(Token![:]) && input.peek(Ident) {
Some(Box::new((input.parse()?, input.parse()?)))
} else {
None
};
let expr: Expr = input.call(Expr::parse_without_eager_brace)?;
let invariant = input.parse()?;
let decreases = input.parse()?;

let content;
let brace_token = braced!(content in input);
Expand All @@ -2448,7 +2458,10 @@ pub(crate) mod parsing {
for_token,
pat,
in_token,
expr_name,
expr: Box::new(expr),
invariant,
decreases,
body: Block { brace_token, stmts },
})
}
Expand Down Expand Up @@ -3444,7 +3457,14 @@ pub(crate) mod printing {
self.for_token.to_tokens(tokens);
self.pat.to_tokens(tokens);
self.in_token.to_tokens(tokens);
if let Some(expr_name) = &self.expr_name {
let (name, colon) = &**expr_name;
name.to_tokens(tokens);
colon.to_tokens(tokens);
}
wrap_bare_struct(tokens, &self.expr);
self.invariant.to_tokens(tokens);
self.decreases.to_tokens(tokens);
self.body.brace_token.surround(tokens, |tokens| {
inner_attrs_to_tokens(&self.attrs, tokens);
tokens.append_all(&self.body.stmts);
Expand Down
3 changes: 3 additions & 0 deletions dependencies/syn/src/gen/clone.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dependencies/syn/src/gen/debug.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion dependencies/syn/src/gen/eq.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions dependencies/syn/src/gen/fold.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dependencies/syn/src/gen/hash.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions dependencies/syn/src/gen/visit.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions dependencies/syn/src/gen/visit_mut.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions dependencies/syn/syn.json
Original file line number Diff line number Diff line change
Expand Up @@ -1560,11 +1560,35 @@
"in_token": {
"token": "In"
},
"expr_name": {
"option": {
"box": {
"tuple": [
{
"proc_macro2": "Ident"
},
{
"token": "Colon"
}
]
}
}
},
"expr": {
"box": {
"syn": "Expr"
}
},
"invariant": {
"option": {
"syn": "Invariant"
}
},
"decreases": {
"option": {
"syn": "Decreases"
}
},
"body": {
"syn": "Block"
}
Expand Down
96 changes: 96 additions & 0 deletions dependencies/syn/tests/debug/gen.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions source/builtin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,13 @@ macro_rules! decreases_to {
};
}

#[cfg(verus_keep_ghost)]
#[rustc_diagnostic_item = "verus::builtin::infer_spec_for_loop_iter"]
#[verifier::spec]
pub fn infer_spec_for_loop_iter<A>(_: A) -> Option<A> {
unimplemented!()
}

#[cfg(verus_keep_ghost)]
#[rustc_diagnostic_item = "verus::builtin::global_size_of"]
#[verifier::spec]
Expand Down
Loading
Loading