You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
both Rust Stable 1.46 and Nightly 1.48 report that
error[E0277]: the trait bound `B: C` is not satisfied
--> src/main.rs:6:12
|
2 | const SIZE: usize;
| ------------------ required by `C::SIZE`
...
6 | s: [B; <B as C>::SIZE],
| ^^^^^^^^^^^^^^ the trait `C` is not implemented for `B`
|
help: consider further restricting this bound
|
5 | pub struct A<B: C + C> {
| ^^^
error: aborting due to previous error
The bound C on the generic parameter B is correctly picked up at the type level, for t: C::D, but not at the constant-value level,
for <B as C>::SIZE
Thanks for the report! This is currently a known issue where array lengths cannot make use of generic parameters, which is tracked in #43408, so closing as a duplicate of that.
In the following code,
both Rust Stable 1.46 and Nightly 1.48 report that
The bound
C
on the generic parameterB
is correctly picked up at the type level, fort: C::D
, but not at the constant-value level,for
<B as C>::SIZE
Moreover, the suggested fix is useless
Meta
rustc --version --verbose
:The bug also seems to affect Stable 1.46
If this is intended behavior, how are you meant to bound
B
appropriately to be able to use associated constants?Is this something relating to const-generics awaiting stabilization? Either way, the error message is very misleading.
Extended case
Extend the above code with
Then,
e
has the same error asA
, but notg
.The text was updated successfully, but these errors were encountered: