11use super :: {
22 bimap:: { BiMap , BiMapIndex , Interned , IntoBiMapIndex } ,
33 cilnode:: { BinOp , ExtendKind , MethodKind , PtrCastRes , UnOp } ,
4- class:: { ClassDefIdx , StaticFieldDef } ,
4+ class:: { ClassDefIdx , LayoutError , StaticFieldDef } ,
55 opt:: { OptFuel , SideEffectInfoCache } ,
66 Access , CILNode , CILRoot , ClassDef , ClassRef , Const , Exporter , FieldDesc , FnSig , Int ,
77 IntoAsmIndex , MethodDef , MethodDefIdx , MethodRef , StaticFieldDesc , Type ,
@@ -480,19 +480,20 @@ impl Assembly {
480480 idx
481481 }
482482 /// Adds a new class definition to this type
483- pub fn class_def ( & mut self , def : ClassDef ) -> ClassDefIdx {
483+ pub fn class_def ( & mut self , def : ClassDef ) -> Result < ClassDefIdx , LayoutError > {
484+ def. layout_check ( self ) ?;
484485 let cref = def. ref_to ( ) ;
485486 let cref = self . alloc_class_ref ( cref) ;
486487
487488 if self . class_defs . contains_key ( & ClassDefIdx ( cref) ) {
488489 if self [ def. name ( ) ] . contains ( "core.ffi.c_void" ) || self [ def. name ( ) ] . contains ( "RustVoid" )
489490 {
490- return ClassDefIdx ( cref) ;
491+ return Ok ( ClassDefIdx ( cref) ) ;
491492 }
492493 panic ! ( )
493494 }
494495 self . class_defs . insert ( ClassDefIdx ( cref) , def. clone ( ) ) ;
495- ClassDefIdx ( cref)
496+ Ok ( ClassDefIdx ( cref) )
496497 }
497498 pub fn main_module ( & mut self ) -> ClassDefIdx {
498499 let main_module = self . alloc_string ( MAIN_MODULE ) ;
@@ -515,7 +516,7 @@ impl Assembly {
515516 if self . class_defs . contains_key ( & ClassDefIdx ( cref) ) {
516517 ClassDefIdx ( cref)
517518 } else {
518- self . class_def ( class_def)
519+ self . class_def ( class_def) . unwrap ( )
519520 }
520521 }
521522 /// Adds a method definition to this assembly.
@@ -794,6 +795,7 @@ impl Assembly {
794795 None ,
795796 true ,
796797 ) )
798+ . unwrap ( )
797799 }
798800 /// Converts the old assembly repr to the new one.
799801 #[ must_use]
0 commit comments