11use std:: ffi:: OsString ;
22use std:: num:: NonZeroUsize ;
33use std:: path:: { Path , PathBuf } ;
4+ use std:: sync:: OnceLock ;
45use std:: { env, process:: Command } ;
56
67use colored:: * ;
@@ -67,8 +68,8 @@ fn miri_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
6768
6869 let mut config = Config {
6970 target : Some ( target. to_owned ( ) ) ,
70- stderr_filters : STDERR . clone ( ) ,
71- stdout_filters : STDOUT . clone ( ) ,
71+ stderr_filters : stderr_filters ( ) . into ( ) ,
72+ stdout_filters : stdout_filters ( ) . into ( ) ,
7273 mode,
7374 program,
7475 out_dir : PathBuf :: from ( std:: env:: var_os ( "CARGO_TARGET_DIR" ) . unwrap ( ) ) . join ( "ui" ) ,
@@ -174,15 +175,18 @@ fn run_tests(
174175}
175176
176177macro_rules! regexes {
177- ( $name: ident: $( $regex: expr => $replacement: expr, ) * ) => { lazy_static:: lazy_static! {
178- static ref $name: Vec <( Match , & ' static [ u8 ] ) > = vec![
179- $( ( Regex :: new( $regex) . unwrap( ) . into( ) , $replacement. as_bytes( ) ) , ) *
180- ] ;
181- } } ;
178+ ( $name: ident: $( $regex: expr => $replacement: expr, ) * ) => {
179+ fn $name( ) -> & ' static [ ( Match , & ' static [ u8 ] ) ] {
180+ static S : OnceLock <Vec <( Match , & ' static [ u8 ] ) >> = OnceLock :: new( ) ;
181+ S . get_or_init( || vec![
182+ $( ( Regex :: new( $regex) . unwrap( ) . into( ) , $replacement. as_bytes( ) ) , ) *
183+ ] )
184+ }
185+ } ;
182186}
183187
184188regexes ! {
185- STDOUT :
189+ stdout_filters :
186190 // Windows file paths
187191 r"\\" => "/" ,
188192 // erase borrow tags
@@ -191,7 +195,7 @@ regexes! {
191195}
192196
193197regexes ! {
194- STDERR :
198+ stderr_filters :
195199 // erase line and column info
196200 r"\.rs:[0-9]+:[0-9]+(: [0-9]+:[0-9]+)?" => ".rs:LL:CC" ,
197201 // erase alloc ids
0 commit comments