@@ -84,19 +84,18 @@ fn const_to_valtree_inner<'tcx>(
8484 Some ( ty:: ValTree :: Leaf ( val. assert_int ( ) ) )
8585 }
8686
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.
9190 // Technically we could allow function pointers, but they are not guaranteed to be the
9291 // same as the function pointers at runtime.
9392 ty:: FnPtr ( _) | ty:: RawPtr ( _) => None ,
9493 ty:: Ref ( ..) => unimplemented ! ( "need to use deref_const" ) ,
9594
9695 // 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 .
10099 ty:: Dynamic ( ..) => None ,
101100
102101 ty:: Slice ( _) | ty:: Str => {
@@ -107,8 +106,7 @@ fn const_to_valtree_inner<'tcx>(
107106
108107 ty:: Adt ( def, _) => {
109108 if def. variants . is_empty ( ) {
110- // Uninhabited
111- return None ;
109+ bug ! ( "uninhabited types should have errored and never gotten converted to valtree" )
112110 }
113111
114112 let variant = ecx. read_discriminant ( & place. into ( ) ) . unwrap ( ) . 1 ;
0 commit comments