Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

[move-compiler] implement the #[verify_only] attribute #420

Merged
merged 2 commits into from
Aug 30, 2022

Conversation

meng-xu-cs
Copy link
Collaborator

As title suggests, this is an implementation of the #[verify_only]
annotation that can be used in a way that is similar to #[test_only].

The semantics of #[verify_only] is the following:

Any AST element (in both source of in the library definitions)
annotated with the #[verify_only] attribute will be removed
after parsing, unless the verify flag is set when invoking
the compiler.

#[verify_only] has no interaction with unit-testing related
attributes such as #[test], #[test_only] or #[abort],
#[expect_failure] etc. A function that is marked #[verify_only] has
no knowledge of that a #[test_only] function might exist, unless both
verify and testing flags are set when invoking the compiler.

A large portion of this PR is in fact an refactoring of the #[test_only]
implementation as both #[test_only] and #[verify_only] involves
filtering AST nodes. This common functionality is abstracted and placed
into the move-compiler/parser/filter.rs file, and in particular, as a
FilterContext trait which can be customized as needed.

Motivation

#[verify_only] has come up in several discussions related to prover improvements. This is an attempt to implement it and unblock other lines of work.

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

New test cases added

As title suggests, this is an implementation of the `#[verify_only]`
annotation that can be used in a way that is similar to `#[test_only]`.

The semantics of `#[verify_only]` is the following:

Any AST element (in both source of in the library definitions)
annotated with the `#[verify_only]` attribute will be removed
after parsing, unless the `verify` flag is set when invoking
the compiler.

`#[verify_only]` has no interaction with unit-testing related
attributes such as `#[test]`, `#[test_only]` or `#[abort]`,
`#[expect_failure]` etc. A function that is marked `#[verify_only]` has
no knowledge of that a `#[test_only]` function might exist, unless both
`verify` and `testing` flags are set when invoking the compiler.

A large portion of this PR is in fact an refactoring of the `#[test_only]`
implementation as both `#[test_only]` and `#[verify_only]` involves
filtering AST nodes. This common functionality is abstracted and placed
into the `move-compiler/parser/filter.rs` file, and in particular, as a
`FilterContext` trait which can be customized as needed.
@meng-xu-cs meng-xu-cs marked this pull request as ready for review August 30, 2022 03:53
Copy link
Member

@wrwg wrwg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

Copy link
Member

@tnowacki tnowacki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks for generalizing the filtering logic!

@meng-xu-cs meng-xu-cs merged commit 4a5ccd2 into move-language:main Aug 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants