@@ -162,14 +162,18 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
162
162
scalar_format( value) , path, "a valid unicode codepoint" ) ;
163
163
} ,
164
164
ty:: Float ( _) | ty:: Int ( _) | ty:: Uint ( _) if const_mode => {
165
- // Integers/floats in CTFE: Must be scalar bits
165
+ // Integers/floats in CTFE: Must be scalar bits, pointers are dangerous
166
166
try_validation ! ( value. to_bits( size) ,
167
167
scalar_format( value) , path, "initialized plain bits" ) ;
168
168
}
169
169
ty:: Float ( _) | ty:: Int ( _) | ty:: Uint ( _) | ty:: RawPtr ( _) => {
170
- // Anything but undef goes
171
- try_validation ! ( value. not_undef( ) ,
172
- scalar_format( value) , path, "a raw pointer" ) ;
170
+ if const_mode {
171
+ // Anything but undef goes
172
+ try_validation ! ( value. not_undef( ) ,
173
+ scalar_format( value) , path, "a raw pointer" ) ;
174
+ } else {
175
+ // At run-time, for now, we accept *anything* for these types.
176
+ }
173
177
} ,
174
178
ty:: Ref ( ..) => {
175
179
// This is checked by the recursive reference handling, nothing to do here.
@@ -182,10 +186,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
182
186
scalar_format( value) , path, "a function pointer" ) ;
183
187
// FIXME: Check if the signature matches
184
188
}
185
- ty:: FnDef ( ..) => {
186
- // This is a zero-sized type with all relevant data sitting in the type.
187
- // There is nothing to validate.
188
- }
189
+ // This should be all
190
+ ty:: Never => bug ! ( "Uninhabited type should have been catched earlier" ) ,
189
191
_ => bug ! ( "Unexpected primitive type {}" , ty)
190
192
}
191
193
Ok ( ( ) )
0 commit comments