Add annotation support for trait methods and verify that implementations satisfy them#25
Add annotation support for trait methods and verify that implementations satisfy them#25coeff-aij wants to merge 3 commits intocoord-e:mainfrom
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.
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.
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().