@@ -453,7 +453,7 @@ impl fmt::Display for MemoryOrder {
453453// ============================================================================
454454
455455/// Unique ID for a pseudo (virtual register)
456- #[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash ) ]
456+ #[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash , Default ) ]
457457pub struct PseudoId ( pub u32 ) ;
458458
459459impl fmt:: Display for PseudoId {
@@ -463,9 +463,10 @@ impl fmt::Display for PseudoId {
463463}
464464
465465/// Type of pseudo value
466- #[ derive( Debug , Clone , PartialEq ) ]
466+ #[ derive( Debug , Clone , PartialEq , Default ) ]
467467pub enum PseudoKind {
468468 /// Void (no value)
469+ #[ default]
469470 Void ,
470471 /// Undefined value
471472 Undef ,
@@ -484,7 +485,7 @@ pub enum PseudoKind {
484485}
485486
486487/// A pseudo (virtual register or value) in SSA form
487- #[ derive( Debug , Clone ) ]
488+ #[ derive( Debug , Clone , Default ) ]
488489pub struct Pseudo {
489490 pub id : PseudoId ,
490491 pub kind : PseudoKind ,
@@ -498,16 +499,6 @@ impl PartialEq for Pseudo {
498499 }
499500}
500501
501- impl Default for Pseudo {
502- fn default ( ) -> Self {
503- Self {
504- id : PseudoId ( 0 ) ,
505- kind : PseudoKind :: Void ,
506- name : None ,
507- }
508- }
509- }
510-
511502impl Pseudo {
512503 /// Create an undefined pseudo
513504 pub fn undef ( id : PseudoId ) -> Self {
@@ -1722,7 +1713,7 @@ impl GlobalDef {
17221713// ============================================================================
17231714
17241715/// A module containing multiple functions
1725- #[ derive( Debug , Clone ) ]
1716+ #[ derive( Debug , Clone , Default ) ]
17261717pub struct Module {
17271718 /// Functions
17281719 pub functions : Vec < Function > ,
@@ -1749,22 +1740,6 @@ pub struct Module {
17491740}
17501741
17511742impl Module {
1752- /// Create a new module
1753- pub fn new ( ) -> Self {
1754- Self {
1755- functions : Vec :: new ( ) ,
1756- globals : Vec :: new ( ) ,
1757- strings : Vec :: new ( ) ,
1758- wide_strings : Vec :: new ( ) ,
1759- debug : false ,
1760- source_files : Vec :: new ( ) ,
1761- extern_symbols : HashSet :: new ( ) ,
1762- extern_tls_symbols : HashSet :: new ( ) ,
1763- comp_dir : None ,
1764- source_name : None ,
1765- }
1766- }
1767-
17681743 /// Add a function
17691744 pub fn add_function ( & mut self , func : Function ) {
17701745 self . functions . push ( func) ;
@@ -1857,12 +1832,6 @@ impl Module {
18571832 }
18581833}
18591834
1860- impl Default for Module {
1861- fn default ( ) -> Self {
1862- Self :: new ( )
1863- }
1864- }
1865-
18661835impl fmt:: Display for Module {
18671836 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
18681837 // Globals
@@ -2060,7 +2029,7 @@ mod tests {
20602029 #[ test]
20612030 fn test_module ( ) {
20622031 let types = TypeTable :: new ( & Target :: host ( ) ) ;
2063- let mut module = Module :: new ( ) ;
2032+ let mut module = Module :: default ( ) ;
20642033
20652034 module. add_global ( "counter" , types. int_id , Initializer :: Int ( 0 ) ) ;
20662035
@@ -2073,7 +2042,7 @@ mod tests {
20732042
20742043 #[ test]
20752044 fn test_module_extern_symbols ( ) {
2076- let mut module = Module :: new ( ) ;
2045+ let mut module = Module :: default ( ) ;
20772046
20782047 // New module should have empty extern_symbols
20792048 assert ! ( module. extern_symbols. is_empty( ) ) ;
@@ -2181,7 +2150,7 @@ mod tests {
21812150 #[ test]
21822151 fn test_add_global_aligned_tentative_definition ( ) {
21832152 let types = TypeTable :: new ( & Target :: host ( ) ) ;
2184- let mut module = Module :: new ( ) ;
2153+ let mut module = Module :: default ( ) ;
21852154
21862155 // Add a tentative definition (no initializer)
21872156 module. add_global_aligned ( "x" , types. int_id , Initializer :: None , None , false ) ;
@@ -2198,7 +2167,7 @@ mod tests {
21982167 #[ test]
21992168 fn test_add_global_aligned_non_tentative_not_replaced ( ) {
22002169 let types = TypeTable :: new ( & Target :: host ( ) ) ;
2201- let mut module = Module :: new ( ) ;
2170+ let mut module = Module :: default ( ) ;
22022171
22032172 // Add a real definition (with initializer)
22042173 module. add_global_aligned ( "x" , types. int_id , Initializer :: Int ( 10 ) , None , false ) ;
@@ -2212,7 +2181,7 @@ mod tests {
22122181 #[ test]
22132182 fn test_add_global_tls_aligned_tentative_definition ( ) {
22142183 let types = TypeTable :: new ( & Target :: host ( ) ) ;
2215- let mut module = Module :: new ( ) ;
2184+ let mut module = Module :: default ( ) ;
22162185
22172186 // Add a TLS tentative definition
22182187 module. add_global_tls_aligned ( "tls_var" , types. int_id , Initializer :: None , None , false ) ;
0 commit comments