Support user-defined predicate call in annotation#22
Conversation
8b90c59 to
4cd0a34
Compare
| } | ||
|
|
||
| #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
| pub struct UserDefinedPred { |
There was a problem hiding this comment.
This struct seems to be unused. I think it's more natural to rename UserDefinedPredSymbol to UserDefinedPred and remove this one.
There was a problem hiding this comment.
Originally I defined this struct to implement a parser for definitions of user-defined predicates. If the parser is implemented in the future, it might be fine to leave this definition as is.
There was a problem hiding this comment.
I’d like to avoid leaving unused structs because it makes the intent harder to understand later. Requirements might change by the time we write the parser for the definitions, so I don’t think there's a need to define them speculatively right now. (Either way, I think cargo clippy or something will probably flag it.)
|
I reflected the comments in above review. |
170ea6d to
d602bb3
Compare
| Pred::Matcher(p) | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
please add impl From<UserDefinedPred> for Pred
a user-defined predicate call
…o `UserDefinedPred`
be21283 to
463e7d3
Compare
|
I accidentally deleted the tests in |
coord-e
left a comment
There was a problem hiding this comment.
Is it okay to squash-merge this PR?
okay, please!
| fn main() { | ||
| let a = 3; | ||
| assert!(double(a) == 6); | ||
| } No newline at end of file |
There was a problem hiding this comment.
please add newline at the end of file (same for tests/ui/pass/annot_preds_raw_command_multi.rs)
This extention allows users to call arbitrary user-defined predicates (e.g., is_double(x, result)) within annotations.
Currently, a dedicated syntax for defining user-defined predicates is not yet supported. Therefore, users must define them using the #![thrust::raw_define()] (introduced in #21 ) attribute for now.
The predicate
is_double()defined using#![thrust::raw_define()]can be called in the annotations such as#[thrust::ensures()]: