Skip to content

Commit e4b8af5

Browse files
committed
Regression test for issue 60431.
1 parent 8f171c4 commit e4b8af5

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// rust-lang/rust#60431: This is a scenario where to determine the size of
2+
// `&Ref<Obstack>`, we need to know the concrete type of the last field in
3+
// `Ref<Obstack>` (i.e. its "struct tail"), and determining that concrete type
4+
// requires normalizing `Obstack::Dyn`.
5+
//
6+
// The old "struct tail" computation did not perform such normalization, and so
7+
// the compiler would ICE when trying to figure out if `Ref<Obstack>` is a
8+
// dynamically-sized type (DST).
9+
10+
// run-pass
11+
12+
use std::mem;
13+
14+
pub trait Arena {
15+
type Dyn : ?Sized;
16+
}
17+
18+
pub struct DynRef {
19+
_dummy: [()],
20+
}
21+
22+
pub struct Ref<A: Arena> {
23+
_value: u8,
24+
_dyn_arena: A::Dyn,
25+
}
26+
27+
pub struct Obstack;
28+
29+
impl Arena for Obstack {
30+
type Dyn = DynRef;
31+
}
32+
33+
fn main() {
34+
assert_eq!(mem::size_of::<&Ref<Obstack>>(), mem::size_of::<&[()]>());
35+
}

0 commit comments

Comments
 (0)