File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments