Closed
Description
I tried this code:
struct B<A: Sized = [(); {
let x = [0u8; !0usize];
1
}]> {
a: A
}
fn main() {
}
I expected to see this happen: This code should compile, as A
is a generic type with the default type being [(); 1]
. When I remove the let x = [0u8; !0usize]
line, everything compiles fine.
Instead, this happened: I got an error message, error[E0277]
Meta
rustc --version --verbose
:
Stable version: 1.47.0
Beta version: 1.48.0-beta.5
1.49.0-nightly (2020-11-05 9d78d1d02761b906038b)
Backtrace
Compiling playground v0.0.1 (/playground)
error[E0277]: the size for values of type `A` cannot be known at compilation time
--> src/main.rs:32:19
|
31 | struct B<A: Sized = [(); {
| -
| |
| this type parameter needs to be `Sized`
| required by this bound in `B`
32 | let x = [0u8; !0usize];
| ^^^^^^^ doesn't have a size known at compile-time
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground`
To learn more, run the command again with --verbose.