I'm playing around with the recently stabilized Type-Conditional Spec Refinements feature. I have a question about how to use it. For example, reading the docs I would expect that I would be able to do this:
use prusti_contracts::*;
pub unsafe trait Foo {}
pub trait Bar {
#[refine_spec(where Self: Foo, [pure])]
fn baz(&self) -> usize;
}
but this fails with the compilation error:
error: [Prusti: unsupported feature] Type-conditional spec refinements can only be applied to trusted functions
--> src/lib.rs:33:5
|
33 | fn baz(&self) -> usize;
| ^^^^^^^^^^^^^^^^^^^^^^^
which is a bit confusing because there is no method body. However, this does seem to compile:
use prusti_contracts::*;
pub unsafe trait Foo {}
pub trait Bar {
#[trusted]
#[refine_spec(where Self: Foo, [pure])]
fn baz(&self) -> usize;
}
and so does this:
use prusti_contracts::*;
pub unsafe trait Foo {}
pub trait Bar {
fn baz(&self) -> usize;
}
#[extern_spec]
pub trait Bar {
#[refine_spec(where Self: Foo, [pure])]
fn baz(&self) -> usize;
}
What is the correct usage of #[refine_spec] on trait methods without a body? :) As an aside question, why can type-conditional spec refinements only be applied to trusted functions? Thanks!
I'm playing around with the recently stabilized Type-Conditional Spec Refinements feature. I have a question about how to use it. For example, reading the docs I would expect that I would be able to do this:
but this fails with the compilation error:
which is a bit confusing because there is no method body. However, this does seem to compile:
and so does this:
What is the correct usage of
#[refine_spec]on trait methods without a body? :) As an aside question, why can type-conditional spec refinements only be applied to trusted functions? Thanks!