Closed enjhnsn2 closed 1 week ago
The check is not implemented at all when strong references are involved so it just crashes.
Do you need the &strg? isn't the mut ref unfolding we implemented enough for this use case? I would like to know why not.
In any case, @ranjitjhala maybe you can take care of finishing the work on trait impl checking to consider strong references.
@enjhnsn2 in the mean time you can use #[flux::trusted_impl]
As requested, another implementation
#[flux_rs::sig(
fn(self: &strg RingBuffer<T>[@old]) ensures self: RingBuffer<T>[old.ring_len, 0, 0]
)]
fn empty(&mut self) {
self.head = 0;
self.tail = 0;
}
and trait method
/// Remove all elements from the ring buffer.
fn empty(&mut self);
where the implementation has a non-trivial ensures
clause.
@ranjitjhala your PR doesn't consider this case. We need the unfold_local_ptrs
hack to handle this. I think it shouldn't be too hard to reuse it, right?
Also, I always thought that if you have an &mut
in the trait definition you would never be able to make it an &strg
in the impl, but now that we've implemented the check I see that in certain situations you can. In particular, if the trait definition is completely unrefined you can turn an &mut
into an &strg
as long as you don't put extra constraints in the input at the implementation. I'm quite happy about that.
on it!
I updated the PR to handle the above (I think!) can you lmk if it works now @enjhnsn2 (and of course reopen if not!)
When I try to check the following trait implementation (here):
against the trait spec (here):
it fails with the error:
I'm a little confused because the spec is token-for-token identical in both the trait and implementation, and only asserts that we need a
&strg Self
.I also get a similar error when there is no spec on the trait at all. I don't fully understand the implementation for trait_impl checking, so I'm not sure if this is expected or not.
Any guidance?