File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ // ICE !base.layout().is_sized()
2+ // issue: rust-lang/rust#123078
3+
4+ struct S {
5+ a : [ u8 ] ,
6+ //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
7+ b : ( ) ,
8+ }
9+
10+ const C : S = unsafe { std:: mem:: transmute ( ( ) ) } ;
11+ //~^ ERROR cannot transmute between types of different sizes, or dependently-sized types
12+ const _: [ ( ) ; {
13+ C ;
14+ 0
15+ } ] = [ ] ;
16+
17+ pub fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
2+ --> $DIR/base-layout-is-sized-ice-123078.rs:5:8
3+ |
4+ LL | a: [u8],
5+ | ^^^^ doesn't have a size known at compile-time
6+ |
7+ = help: the trait `Sized` is not implemented for `[u8]`
8+ = note: only the last field of a struct may have a dynamically sized type
9+ = help: change the field's type to have a statically known size
10+ help: borrowed types always have a statically known size
11+ |
12+ LL | a: &[u8],
13+ | +
14+ help: the `Box` type always has a statically known size and allocates its contents in the heap
15+ |
16+ LL | a: Box<[u8]>,
17+ | ++++ +
18+
19+ error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
20+ --> $DIR/base-layout-is-sized-ice-123078.rs:10:23
21+ |
22+ LL | const C: S = unsafe { std::mem::transmute(()) };
23+ | ^^^^^^^^^^^^^^^^^^^
24+ |
25+ = note: source type: `()` (0 bits)
26+ = note: target type: `S` (this type does not have a fixed size)
27+
28+ error: aborting due to 2 previous errors
29+
30+ Some errors have detailed explanations: E0277, E0512.
31+ For more information about an error, try `rustc --explain E0277`.
You can’t perform that action at this time.
0 commit comments