So I have the following very convoluted code:
pub struct Predicate<const B: bool> {}
pub trait True {}
impl True for Predicate<true> {}
pub const fn check(N: usize) > bool {
N % 2 > 0
}
impl<const N: usize> Montgomery<N> {
const R: usize = N.next_power_of_two();
pub const fn new(original: usize) > Montgomery<N>
where
Predicate<{ Self::R.is_power_of_two() }>: True,
Predicate<{ check(N) }>: True,
{}
}
And rustc (the 11May21 nightly) flags this,
error[E0283]: type annotations needed
> src\montgomery.rs:82:34

4  pub trait True {}
  required by this bound in `True`
...
82  Predicate<{ check(N) }>: True,
 ^^^^ cannot infer type for struct `Predicate<{ check(N) }>`

= note: cannot satisfy `Predicate<{ check(N) }>: True`
And I have absolutely no idea what this refers to, because there is only one True
, and the manual entry for E0283 doesn't seem to help because it's talking about ambiguity in implementation where no ambiguity appears to exist.
What's going on? I know const generics are incomplete, have I just ran into an edge case or misunderstood the message?