-
Notifications
You must be signed in to change notification settings - Fork 1
Add annotation support for trait methods and verify that implementations satisfy them #25
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
base: main
Are you sure you want to change the base?
Conversation
src/analyze/local_def.rs
Outdated
| if let Some(trait_item_id) = self.get_trait_item(){ | ||
| tracing::info!("trait item fonud: {}", self.tcx.item_name(trait_item_id.into()).to_string()); | ||
| let trait_require_annot = self.extract_require_annot(trait_item_id.into(), ¶m_resolver); | ||
| let trait_ensure_annot = self.extract_ensure_annot(trait_item_id.into(), &result_param_resolver); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't create new instance of Analyzer for method definitions in trait because they don't appear in MIR. I have extended the self.extract_*_annot() so that they can analyze any definitions not only the one identified by self.local_def_id. This implementation works, but it could be refactored for a clearer architecture.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have extended the self.extract_*_annot() so that they can analyze any definitions not only the one identified by self.local_def_id. This implementation works, but it could be refactored for a clearer architecture.
Cool, could you move these extract_*_annot() functions that take DefId to analyze::Analyzer? I'm putting utilities that need tcx and aren't bound to crates, local defs, or basic blocks into analyze::Analyzer.
78ed922 to
acc62a1
Compare
|
We also need to verify that every predicate implementation defined in a trait is annotated with the |
functions in impl blocks Update src/analyze/local_def.rs Co-authored-by: Hiromi Ogawa <me@coord-e.com>
84c5278 to
87d818c
Compare
analyze::local_def::Analyzer
|
I've addressed your review comments. |
This feature allows users to annotate trait methods with predicates. The Thrust verifies that the concrete implementations of those methods and their associated predicates satisfy the annotations given in trait.
The specification for
A::double()is expressed through the annotations onDouble::double().The method refers to the predicate
Double::is_double(), whose concrete implementation is provided byA::is_double().