Closed
Description
I tried this code:
trait Unsigned {
const REIFY: usize;
}
struct A<T: Unsigned> {
buf: [u8; <T as Unsigned>::REIFY]
}
I expected to see an error about associated constants not being allowed in array lengths or something.
Instead, this is the error given by rustc.
error[E0277]: the trait bound `T: Unsigned` is not satisfied
--> src/lib.rs:6:15
|
2 | const REIFY: usize;
| ------------------- required by `Unsigned::REIFY`
...
6 | buf: [u8; <T as Unsigned>::REIFY]
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `Unsigned` is not implemented for `T`
|
help: consider further restricting this bound
|
5 | struct A<T: Unsigned + Unsigned> {
(There is an additional "T
is never used" error, but that one makes sense, since there are no valid uses of T
in the struct definition.)
Meta
rustc --version --verbose
:
rustc 1.48.0 (7eac88abb 2020-11-16)
binary: rustc
commit-hash: 7eac88abb2e57e752f3302f02be5f3ce3d7adfb4
commit-date: 2020-11-16
host: x86_64-unknown-linux-gnu
release: 1.48.0
LLVM version: 11.0
I tested this in Stable, Beta, and Nightly, on the Rust Playground.