@@ -120,21 +120,21 @@ fn const_to_valtree_inner<'tcx>(
120120 // We could allow wide raw pointers where both sides are integers in the future,
121121 // but for now we reject them.
122122 if matches ! ( val. layout. abi, Abi :: ScalarPair ( ..) ) {
123- return Err ( ValTreeCreationError :: NonSupportedType ) ;
123+ return Err ( ValTreeCreationError :: NonSupportedType ( ty ) ) ;
124124 }
125125 let val = val. to_scalar ( ) ;
126126 // We are in the CTFE machine, so ptr-to-int casts will fail.
127127 // This can only be `Ok` if `val` already is an integer.
128128 let Ok ( val) = val. try_to_scalar_int ( ) else {
129- return Err ( ValTreeCreationError :: NonSupportedType ) ;
129+ return Err ( ValTreeCreationError :: NonSupportedType ( ty ) ) ;
130130 } ;
131131 // It's just a ScalarInt!
132132 Ok ( ty:: ValTree :: Leaf ( val) )
133133 }
134134
135135 // Technically we could allow function pointers (represented as `ty::Instance`), but this is not guaranteed to
136136 // agree with runtime equality tests.
137- ty:: FnPtr ( _) => Err ( ValTreeCreationError :: NonSupportedType ) ,
137+ ty:: FnPtr ( _) => Err ( ValTreeCreationError :: NonSupportedType ( ty ) ) ,
138138
139139 ty:: Ref ( _, _, _) => {
140140 let derefd_place = ecx. deref_pointer ( place) ?;
@@ -148,15 +148,15 @@ fn const_to_valtree_inner<'tcx>(
148148 // resolving their backing type, even if we can do that at const eval time. We may
149149 // hypothetically be able to allow `dyn StructuralPartialEq` trait objects in the future,
150150 // but it is unclear if this is useful.
151- ty:: Dynamic ( ..) => Err ( ValTreeCreationError :: NonSupportedType ) ,
151+ ty:: Dynamic ( ..) => Err ( ValTreeCreationError :: NonSupportedType ( ty ) ) ,
152152
153153 ty:: Tuple ( elem_tys) => {
154154 branches ( ecx, place, elem_tys. len ( ) , None , num_nodes)
155155 }
156156
157157 ty:: Adt ( def, _) => {
158158 if def. is_union ( ) {
159- return Err ( ValTreeCreationError :: NonSupportedType ) ;
159+ return Err ( ValTreeCreationError :: NonSupportedType ( ty ) ) ;
160160 } else if def. variants ( ) . is_empty ( ) {
161161 bug ! ( "uninhabited types should have errored and never gotten converted to valtree" )
162162 }
@@ -180,7 +180,7 @@ fn const_to_valtree_inner<'tcx>(
180180 | ty:: Closure ( ..)
181181 | ty:: CoroutineClosure ( ..)
182182 | ty:: Coroutine ( ..)
183- | ty:: CoroutineWitness ( ..) => Err ( ValTreeCreationError :: NonSupportedType ) ,
183+ | ty:: CoroutineWitness ( ..) => Err ( ValTreeCreationError :: NonSupportedType ( ty ) ) ,
184184 }
185185}
186186
@@ -251,7 +251,7 @@ pub(crate) fn eval_to_valtree<'tcx>(
251251 let valtree_result = const_to_valtree_inner ( & ecx, & place, & mut num_nodes) ;
252252
253253 match valtree_result {
254- Ok ( valtree) => Ok ( Some ( valtree) ) ,
254+ Ok ( valtree) => Ok ( Ok ( valtree) ) ,
255255 Err ( err) => {
256256 let did = cid. instance . def_id ( ) ;
257257 let global_const_id = cid. display ( tcx) ;
@@ -262,7 +262,7 @@ pub(crate) fn eval_to_valtree<'tcx>(
262262 tcx. dcx ( ) . emit_err ( MaxNumNodesInConstErr { span, global_const_id } ) ;
263263 Err ( handled. into ( ) )
264264 }
265- ValTreeCreationError :: NonSupportedType => Ok ( None ) ,
265+ ValTreeCreationError :: NonSupportedType ( ty ) => Ok ( Err ( ty ) ) ,
266266 }
267267 }
268268 }
0 commit comments