E0218
A requires or ensures clause on a method of impl Trait for Type. A trait method's contract lives on the trait's declaration and binds every impl, however it is called, so an impl declares none of its own: move the clause to the trait. A method of an inherent impl keeps its contract. Spans the clause.
Machine-applicable fix: none.
Example
This program fails with E0218.
trait Shape {
fn size(self) -> Int
}
struct Square { side: Int }
impl Shape for Square {
fn size(self) -> Int
ensures |r| r > 0
{
self.side
}
}
Fixed
The same program, fixed.
trait Shape {
fn size(self) -> Int
ensures |r| r > 0
}
struct Square { side: Int }
impl Shape for Square {
fn size(self) -> Int {
self.side
}
}
Listed in the checker notes. oskac explain E0218 prints this entry offline.