Add proof_with() and declare_with() builtin functions for ghost/track…#2436
Open
ziqiaozhou wants to merge 4 commits into
Open
Add proof_with() and declare_with() builtin functions for ghost/track…#2436ziqiaozhou wants to merge 4 commits into
ziqiaozhou wants to merge 4 commits into
Conversation
68b907c to
de1defd
Compare
…ed args Why: to allow with spec in verus_spec for traits and external functions. - Add builtin API: proof_with(), declare_with() (plus aliases declare_with_tracked/declare_with_ghost for backward compatibility) - Infer Tracked vs Ghost mode from the type annotation via ADT DefId - Add VIR lowering in fn_call_to_vir.rs with type and mode checking - Add pre-scan for declare_with params in rust_to_vir_func.rs - Add proof_with test suite - Add first-pass lifetime checking to ensure that tracked/ghost arguments passed via proof_with() satisfy the lifetime constraints declared by declare_with() in the callee. - Add proof_with_lifetime.rs module with region-aware lifetime checking - Use rustc_hir_analysis::lower_ty() to preserve real regions instead of erased regions from typeck writeback - Check that argument regions outlive expected parameter regions using the function's where-clause predicates - Add test cases for lifetime mismatch detection (both Tracked and Ghost) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Ziqiao Zhou <ziqiaozhou@microsoft.com>
de1defd to
188e57c
Compare
… tuple of args, and b should be call to a function that takes extra args
ca79384 to
7953d42
Compare
- Rewrite proof_with_lifetime.rs using InferCtxt region solver - Rename external_fn_extra_tracked_params → declare_with_params - Clean up check_proof_with_lifetime signature (10 → 7 args) - Simplify is_tracked match in pre_scan_declare_with_params - Refactor pending_tracked_args to Option<Vec> with take() semantics - Remove in_args_depth field from BodyCtxt Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
7953d42 to
8fb7da4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…ed args
Why: to allow with spec in verus_spec for traits and external functions.
Add builtin API: proof_with(), declare_with() (plus aliases declare_with_tracked/declare_with_ghost for backward compatibility)
Infer Tracked vs Ghost mode from the type annotation via ADT DefId
Add VIR lowering in fn_call_to_vir.rs with type and mode checking
Add pre-scan for declare_with params in rust_to_vir_func.rs
Add proof_with test suite
Add first-pass lifetime checking to ensure that tracked/ghost arguments passed via proof_with() satisfy the lifetime constraints declared by declare_with() in the callee.
Add proof_with_lifetime.rs module with region-aware lifetime checking
Use rustc_hir_analysis::lower_ty() to preserve real regions instead of erased regions from typeck writeback
Check that argument regions outlive expected parameter regions using the function's where-clause predicates
Add test cases for lifetime mismatch detection (both Tracked and Ghost)
For trait methods,
#[verus_spec(with...)]andproof_with!pair should rewrite code to following styleFor external functions, we need to expand
assume_specificationandproof_with!to rewrite code in following styleBy submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.