1- use std:: sync :: { Arc , Mutex } ;
1+ use std:: cell :: RefCell ;
22
33use swc_core:: common:: errors:: { DiagnosticBuilder , Emitter } ;
44
55pub struct ErrorReporter {
6- pub errors : Arc < Mutex < Vec < String > > > ,
7- pub warnings : Arc < Mutex < Vec < String > > > ,
6+ pub errors : RefCell < Vec < String > > ,
7+ pub warnings : RefCell < Vec < String > > ,
88}
99
1010impl ErrorReporter {
11- pub fn new ( errors : Arc < Mutex < Vec < String > > > , warnings : Arc < Mutex < Vec < String > > > ) -> Self {
11+ pub fn new ( errors : RefCell < Vec < String > > , warnings : RefCell < Vec < String > > ) -> Self {
1212 ErrorReporter { errors, warnings }
1313 }
1414}
1515
1616impl Default for ErrorReporter {
1717 fn default ( ) -> Self {
1818 ErrorReporter {
19- errors : Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ,
20- warnings : Arc :: new ( Mutex :: new ( Vec :: new ( ) ) ) ,
19+ errors : RefCell :: new ( Vec :: new ( ) ) ,
20+ warnings : RefCell :: new ( Vec :: new ( ) ) ,
2121 }
2222 }
2323}
@@ -29,16 +29,14 @@ impl Emitter for ErrorReporter {
2929 | swc_core:: common:: errors:: Level :: Fatal
3030 | swc_core:: common:: errors:: Level :: PhaseFatal
3131 | swc_core:: common:: errors:: Level :: Error => {
32- let mut errors = self . errors . lock ( ) . unwrap ( ) ;
33- errors. push ( diagnostic. message ( ) ) ;
32+ self . errors . borrow_mut ( ) . push ( diagnostic. message ( ) ) ;
3433 }
3534 swc_core:: common:: errors:: Level :: Warning
3635 | swc_core:: common:: errors:: Level :: Note
3736 | swc_core:: common:: errors:: Level :: Help
3837 | swc_core:: common:: errors:: Level :: Cancelled
3938 | swc_core:: common:: errors:: Level :: FailureNote => {
40- let mut warnings = self . warnings . lock ( ) . unwrap ( ) ;
41- warnings. push ( diagnostic. message ( ) ) ;
39+ self . warnings . borrow_mut ( ) . push ( diagnostic. message ( ) ) ;
4240 }
4341 }
4442 }
0 commit comments