@@ -120,21 +120,21 @@ fn const_to_valtree_inner<'tcx>(
120
120
// We could allow wide raw pointers where both sides are integers in the future,
121
121
// but for now we reject them.
122
122
if matches ! ( val. layout. abi, Abi :: ScalarPair ( ..) ) {
123
- return Err ( ValTreeCreationError :: NonSupportedType ) ;
123
+ return Err ( ValTreeCreationError :: NonSupportedType ( ty ) ) ;
124
124
}
125
125
let val = val. to_scalar ( ) ;
126
126
// We are in the CTFE machine, so ptr-to-int casts will fail.
127
127
// This can only be `Ok` if `val` already is an integer.
128
128
let Ok ( val) = val. try_to_scalar_int ( ) else {
129
- return Err ( ValTreeCreationError :: NonSupportedType ) ;
129
+ return Err ( ValTreeCreationError :: NonSupportedType ( ty ) ) ;
130
130
} ;
131
131
// It's just a ScalarInt!
132
132
Ok ( ty:: ValTree :: Leaf ( val) )
133
133
}
134
134
135
135
// Technically we could allow function pointers (represented as `ty::Instance`), but this is not guaranteed to
136
136
// agree with runtime equality tests.
137
- ty:: FnPtr ( _) => Err ( ValTreeCreationError :: NonSupportedType ) ,
137
+ ty:: FnPtr ( _) => Err ( ValTreeCreationError :: NonSupportedType ( ty ) ) ,
138
138
139
139
ty:: Ref ( _, _, _) => {
140
140
let derefd_place = ecx. deref_pointer ( place) ?;
@@ -148,15 +148,15 @@ fn const_to_valtree_inner<'tcx>(
148
148
// resolving their backing type, even if we can do that at const eval time. We may
149
149
// hypothetically be able to allow `dyn StructuralPartialEq` trait objects in the future,
150
150
// but it is unclear if this is useful.
151
- ty:: Dynamic ( ..) => Err ( ValTreeCreationError :: NonSupportedType ) ,
151
+ ty:: Dynamic ( ..) => Err ( ValTreeCreationError :: NonSupportedType ( ty ) ) ,
152
152
153
153
ty:: Tuple ( elem_tys) => {
154
154
branches ( ecx, place, elem_tys. len ( ) , None , num_nodes)
155
155
}
156
156
157
157
ty:: Adt ( def, _) => {
158
158
if def. is_union ( ) {
159
- return Err ( ValTreeCreationError :: NonSupportedType ) ;
159
+ return Err ( ValTreeCreationError :: NonSupportedType ( ty ) ) ;
160
160
} else if def. variants ( ) . is_empty ( ) {
161
161
bug ! ( "uninhabited types should have errored and never gotten converted to valtree" )
162
162
}
@@ -180,7 +180,7 @@ fn const_to_valtree_inner<'tcx>(
180
180
| ty:: Closure ( ..)
181
181
| ty:: CoroutineClosure ( ..)
182
182
| ty:: Coroutine ( ..)
183
- | ty:: CoroutineWitness ( ..) => Err ( ValTreeCreationError :: NonSupportedType ) ,
183
+ | ty:: CoroutineWitness ( ..) => Err ( ValTreeCreationError :: NonSupportedType ( ty ) ) ,
184
184
}
185
185
}
186
186
@@ -251,7 +251,7 @@ pub(crate) fn eval_to_valtree<'tcx>(
251
251
let valtree_result = const_to_valtree_inner ( & ecx, & place, & mut num_nodes) ;
252
252
253
253
match valtree_result {
254
- Ok ( valtree) => Ok ( Some ( valtree) ) ,
254
+ Ok ( valtree) => Ok ( Ok ( valtree) ) ,
255
255
Err ( err) => {
256
256
let did = cid. instance . def_id ( ) ;
257
257
let global_const_id = cid. display ( tcx) ;
@@ -262,7 +262,7 @@ pub(crate) fn eval_to_valtree<'tcx>(
262
262
tcx. dcx ( ) . emit_err ( MaxNumNodesInConstErr { span, global_const_id } ) ;
263
263
Err ( handled. into ( ) )
264
264
}
265
- ValTreeCreationError :: NonSupportedType => Ok ( None ) ,
265
+ ValTreeCreationError :: NonSupportedType ( ty ) => Ok ( Err ( ty ) ) ,
266
266
}
267
267
}
268
268
}
0 commit comments