clippy reports unused imports when using both requires and ensures
I set up something like this
use std::ops::{Div, Mul, Rem, Sub};
use contracts::{ensures, requires};
use mirai_annotations::{checked_postcondition, checked_precondition};
#[requires( n != T::zero() || d != T::zero() )]
#[ensures( ret != T::zero() && n % ret == T::zero() && d % ret == T::zero() )]
pub fn euclidean<T>(n: T, d: T) -> T
where
T: Sub<Output = T>
+ Mul<Output = T>
+ Div<Output = T>
+ Rem<Output = T>
+ Ord
+ num_traits::identities::Zero
+ Copy,
{
let (mut a, mut b) = (n.max(d), n.min(d));
while b != T::zero() {
let q: T = a / b;
let r: T = a - q * b;
a = b;
b = r;
}
a
}
When I run cargo clippy, I get
warning: unused import: `ensures`
--> src/lib.rs:3:17
|
3 | use contracts::{ensures, requires};
| ^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
If I switch the order of requires and ensures, it complains that requires is unused.
Is there some way to avoid this?