@@ -84,19 +84,18 @@ fn const_to_valtree_inner<'tcx>(
84
84
Some ( ty:: ValTree :: Leaf ( val. assert_int ( ) ) )
85
85
}
86
86
87
- // Raw pointers are not allowed in type level constants, as raw pointers cannot be treated
88
- // like references. If we looked behind the raw pointer, we may be breaking the meaning of
89
- // the raw pointer. Equality on raw pointers is performed on the pointer and not on the pointee,
90
- // and we cannot guarantee any kind of pointer stability in the type system.
87
+ // Raw pointers are not allowed in type level constants, as raw pointers compare equal if
88
+ // their addresses are equal. Since we cannot guarantee any kind of pointer stability in
89
+ // the type system.
91
90
// Technically we could allow function pointers, but they are not guaranteed to be the
92
91
// same as the function pointers at runtime.
93
92
ty:: FnPtr ( _) | ty:: RawPtr ( _) => None ,
94
93
ty:: Ref ( ..) => unimplemented ! ( "need to use deref_const" ) ,
95
94
96
95
// Trait objects are not allowed in type level constants, as we have no concept for
97
- // resolving their backing type, even if we can do that at const eval time. We may want to consider
98
- // adding a `ValTree::DownCast(Ty<'tcx>, Box<ValTree>)` in the future, but I don't even know the
99
- // questions such a concept would open up, so an RFC would probably be good for this .
96
+ // resolving their backing type, even if we can do that at const eval time. We may
97
+ // hypothetically be able to allow `dyn StructuralEq` trait objects in the future,
98
+ // but it is unclear if this is useful .
100
99
ty:: Dynamic ( ..) => None ,
101
100
102
101
ty:: Slice ( _) | ty:: Str => {
@@ -107,8 +106,7 @@ fn const_to_valtree_inner<'tcx>(
107
106
108
107
ty:: Adt ( def, _) => {
109
108
if def. variants . is_empty ( ) {
110
- // Uninhabited
111
- return None ;
109
+ bug ! ( "uninhabited types should have errored and never gotten converted to valtree" )
112
110
}
113
111
114
112
let variant = ecx. read_discriminant ( & place. into ( ) ) . unwrap ( ) . 1 ;
0 commit comments