@@ -30,6 +30,24 @@ pub trait ReplaceDecls {
30
30
}
31
31
}
32
32
33
+ impl < T : ReplaceDecls + Clone > ReplaceDecls for std:: sync:: Arc < T > {
34
+ fn replace_decls_inner (
35
+ & mut self ,
36
+ decl_mapping : & DeclMapping ,
37
+ handler : & Handler ,
38
+ ctx : & mut TypeCheckContext ,
39
+ ) -> Result < bool , ErrorEmitted > {
40
+ if let Some ( item) = std:: sync:: Arc :: get_mut ( self ) {
41
+ item. replace_decls_inner ( decl_mapping, handler, ctx)
42
+ } else {
43
+ let mut item = self . as_ref ( ) . clone ( ) ;
44
+ let r = item. replace_decls_inner ( decl_mapping, handler, ctx) ?;
45
+ * self = std:: sync:: Arc :: new ( item) ;
46
+ Ok ( r)
47
+ }
48
+ }
49
+ }
50
+
33
51
pub ( crate ) trait ReplaceFunctionImplementingType {
34
52
fn replace_implementing_type ( & mut self , engines : & Engines , implementing_type : ty:: TyDecl ) ;
35
53
}
@@ -38,6 +56,18 @@ pub(crate) trait UpdateConstantExpression {
38
56
fn update_constant_expression ( & mut self , engines : & Engines , implementing_type : & TyDecl ) ;
39
57
}
40
58
59
+ impl < T : UpdateConstantExpression + Clone > UpdateConstantExpression for std:: sync:: Arc < T > {
60
+ fn update_constant_expression ( & mut self , engines : & Engines , implementing_type : & TyDecl ) {
61
+ if let Some ( item) = std:: sync:: Arc :: get_mut ( self ) {
62
+ item. update_constant_expression ( engines, implementing_type) ;
63
+ } else {
64
+ let mut item = self . as_ref ( ) . clone ( ) ;
65
+ item. update_constant_expression ( engines, implementing_type) ;
66
+ * self = std:: sync:: Arc :: new ( item) ;
67
+ }
68
+ }
69
+ }
70
+
41
71
// Iterate the tree searching for references to a const generic,
42
72
// and initialize its value with the passed value
43
73
pub ( crate ) trait MaterializeConstGenerics {
@@ -49,3 +79,22 @@ pub(crate) trait MaterializeConstGenerics {
49
79
value : & TyExpression ,
50
80
) -> Result < ( ) , ErrorEmitted > ;
51
81
}
82
+
83
+ impl < T : MaterializeConstGenerics + Clone > MaterializeConstGenerics for std:: sync:: Arc < T > {
84
+ fn materialize_const_generics (
85
+ & mut self ,
86
+ engines : & Engines ,
87
+ handler : & Handler ,
88
+ name : & str ,
89
+ value : & TyExpression ,
90
+ ) -> Result < ( ) , ErrorEmitted > {
91
+ if let Some ( item) = std:: sync:: Arc :: get_mut ( self ) {
92
+ item. materialize_const_generics ( engines, handler, name, value)
93
+ } else {
94
+ let mut item = self . as_ref ( ) . clone ( ) ;
95
+ let r = item. materialize_const_generics ( engines, handler, name, value) ;
96
+ * self = std:: sync:: Arc :: new ( item) ;
97
+ r
98
+ }
99
+ }
100
+ }
0 commit comments