@@ -39,6 +39,17 @@ pub struct UnimplementedData {
39
39
pub loc : Location ,
40
40
}
41
41
42
+ impl UnimplementedData {
43
+ pub fn new ( operation : & str , bug_url : & str , goto_type : Type , loc : Location ) -> Self {
44
+ UnimplementedData {
45
+ operation : operation. to_string ( ) ,
46
+ bug_url : bug_url. to_string ( ) ,
47
+ goto_type,
48
+ loc,
49
+ }
50
+ }
51
+ }
52
+
42
53
/// Relevent information about a projected place (i.e. an lvalue).
43
54
#[ derive( Debug ) ]
44
55
pub struct ProjectedPlace < ' tcx > {
@@ -193,7 +204,12 @@ impl<'tcx> TypeOrVariant<'tcx> {
193
204
}
194
205
195
206
impl < ' tcx > GotocCtx < ' tcx > {
196
- fn codegen_field ( & mut self , res : Expr , t : TypeOrVariant < ' tcx > , f : & Field ) -> Expr {
207
+ fn codegen_field (
208
+ & mut self ,
209
+ res : Expr ,
210
+ t : TypeOrVariant < ' tcx > ,
211
+ f : & Field ,
212
+ ) -> Result < Expr , UnimplementedData > {
197
213
match t {
198
214
TypeOrVariant :: Type ( t) => {
199
215
match t. kind ( ) {
@@ -216,7 +232,7 @@ impl<'tcx> GotocCtx<'tcx> {
216
232
| ty:: Infer ( _)
217
233
| ty:: Error ( _) => unreachable ! ( "type {:?} does not have a field" , t) ,
218
234
ty:: Tuple ( _) => {
219
- res. member ( & Self :: tuple_fld_name ( f. index ( ) ) , & self . symbol_table )
235
+ Ok ( res. member ( & Self :: tuple_fld_name ( f. index ( ) ) , & self . symbol_table ) )
220
236
}
221
237
ty:: Adt ( def, _) if def. repr ( ) . simd ( ) => {
222
238
// this is a SIMD vector - the index represents one
@@ -229,27 +245,27 @@ impl<'tcx> GotocCtx<'tcx> {
229
245
// assert!(v.1 == 2);
230
246
// }
231
247
let size_index = Expr :: int_constant ( f. index ( ) , Type :: size_t ( ) ) ;
232
- res. index_array ( size_index)
248
+ Ok ( res. index_array ( size_index) )
233
249
}
234
250
// if we fall here, then we are handling either a struct or a union
235
251
ty:: Adt ( def, _) => {
236
252
let field = & def. variants ( ) . raw [ 0 ] . fields [ f. index ( ) ] ;
237
- res. member ( & field. name . to_string ( ) , & self . symbol_table )
253
+ Ok ( res. member ( & field. name . to_string ( ) , & self . symbol_table ) )
238
254
}
239
- ty:: Closure ( ..) => res. member ( & f. index ( ) . to_string ( ) , & self . symbol_table ) ,
240
- ty:: Generator ( ..) => self . codegen_unimplemented (
255
+ ty:: Closure ( ..) => Ok ( res. member ( & f. index ( ) . to_string ( ) , & self . symbol_table ) ) ,
256
+ ty:: Generator ( ..) => Err ( UnimplementedData :: new (
241
257
"ty::Generator" ,
242
- Type :: code ( vec ! [ ] , Type :: empty ( ) ) ,
243
- res. location ( ) . clone ( ) ,
244
258
"https://github.com/model-checking/kani/issues/416" ,
245
- ) ,
259
+ Type :: code ( vec ! [ ] , Type :: empty ( ) ) ,
260
+ * res. location ( ) ,
261
+ ) ) ,
246
262
_ => unimplemented ! ( ) ,
247
263
}
248
264
}
249
265
// if we fall here, then we are handling an enum
250
266
TypeOrVariant :: Variant ( v) => {
251
267
let field = & v. fields [ f. index ( ) ] ;
252
- res. member ( & field. name . to_string ( ) , & self . symbol_table )
268
+ Ok ( res. member ( & field. name . to_string ( ) , & self . symbol_table ) )
253
269
}
254
270
}
255
271
}
@@ -375,7 +391,7 @@ impl<'tcx> GotocCtx<'tcx> {
375
391
}
376
392
ProjectionElem :: Field ( f, t) => {
377
393
let typ = TypeOrVariant :: Type ( t) ;
378
- let expr = self . codegen_field ( before. goto_expr , before. mir_typ_or_variant , & f) ;
394
+ let expr = self . codegen_field ( before. goto_expr , before. mir_typ_or_variant , & f) ? ;
379
395
Ok ( ProjectedPlace :: new (
380
396
expr,
381
397
typ,
@@ -424,13 +440,12 @@ impl<'tcx> GotocCtx<'tcx> {
424
440
let typ = self . tcx . mk_array ( * ty, subarray_len) ;
425
441
let goto_typ = self . codegen_ty ( typ) ;
426
442
// unimplemented
427
- Err ( UnimplementedData {
428
- operation : "Sub-array binding" . to_string ( ) ,
429
- bug_url : "https://github.com/model-checking/kani/issues/707"
430
- . to_string ( ) ,
431
- goto_type : goto_typ,
432
- loc : * before. goto_expr . location ( ) ,
433
- } )
443
+ Err ( UnimplementedData :: new (
444
+ "Sub-array binding" ,
445
+ "https://github.com/model-checking/kani/issues/707" ,
446
+ goto_typ,
447
+ * before. goto_expr . location ( ) ,
448
+ ) )
434
449
}
435
450
ty:: Slice ( elemt) => {
436
451
let len = if from_end {
0 commit comments