Skip to content

Commit 7d9e106

Browse files
committed
add test for ICE: Unexpected unsized type tail: &ReStatic [u8] #122488
Fixes #122488
1 parent 5dc7fe4 commit 7d9e106

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// ICE Unexpected unsized type tail: &ReStatic [u8]
2+
// issue: rust-lang/rust#122488
3+
use std::ops::Deref;
4+
5+
struct ArenaSet<U: Deref, V: ?Sized = <U as Deref>::Target>(V, U);
6+
//~^ ERROR the size for values of type `V` cannot be known at compilation time
7+
8+
const DATA: *const ArenaSet<Vec<u8>> = std::ptr::null_mut();
9+
10+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
error[E0277]: the size for values of type `V` cannot be known at compilation time
2+
--> $DIR/issue-unsized-tail-restatic-ice-122488.rs:5:61
3+
|
4+
LL | struct ArenaSet<U: Deref, V: ?Sized = <U as Deref>::Target>(V, U);
5+
| -------------------------------- ^ doesn't have a size known at compile-time
6+
| |
7+
| this type parameter needs to be `Sized`
8+
|
9+
= note: only the last field of a struct may have a dynamically sized type
10+
= help: change the field's type to have a statically known size
11+
help: consider removing the `?Sized` bound to make the type parameter `Sized`
12+
|
13+
LL - struct ArenaSet<U: Deref, V: ?Sized = <U as Deref>::Target>(V, U);
14+
LL + struct ArenaSet<U: Deref, V = <U as Deref>::Target>(V, U);
15+
|
16+
help: borrowed types always have a statically known size
17+
|
18+
LL | struct ArenaSet<U: Deref, V: ?Sized = <U as Deref>::Target>(&V, U);
19+
| +
20+
help: the `Box` type always has a statically known size and allocates its contents in the heap
21+
|
22+
LL | struct ArenaSet<U: Deref, V: ?Sized = <U as Deref>::Target>(Box<V>, U);
23+
| ++++ +
24+
25+
error: aborting due to 1 previous error
26+
27+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)