@@ -130,11 +130,12 @@ pub struct CompileConfig<'a> {
130130}
131131
132132impl < ' a > CompileConfig < ' a > {
133+ #[ must_use]
133134 pub fn new (
134135 src_path : & ' a Path ,
135136 externals : Option < & ' a [ PathBuf ] > ,
136137 output_path : Option < PathBuf > ,
137- ) -> CompileConfig < ' a > {
138+ ) -> Self {
138139 Self {
139140 src_path,
140141 header_paths : vec ! [ src_path] ,
@@ -449,7 +450,7 @@ impl Loader {
449450 let parser_path = config. src_path . join ( "parser.c" ) ;
450451 config. scanner_path = self . get_scanner_path ( config. src_path ) ;
451452
452- let mut paths_to_check = vec ! [ parser_path. clone ( ) ] ;
453+ let mut paths_to_check = vec ! [ parser_path] ;
453454
454455 if let Some ( scanner_path) = config. scanner_path . as_ref ( ) {
455456 paths_to_check. push ( scanner_path. clone ( ) ) ;
@@ -488,7 +489,9 @@ impl Loader {
488489 }
489490
490491 let lock_path = if env:: var ( "CROSS_RUNNER" ) . is_ok ( ) {
491- PathBuf :: from ( "/tmp" )
492+ tempfile:: tempdir ( )
493+ . unwrap ( )
494+ . path ( )
492495 . join ( "tree-sitter" )
493496 . join ( "lock" )
494497 . join ( format ! ( "{}.lock" , config. name) )
@@ -1021,7 +1024,7 @@ impl Loader {
10211024 language_name : grammar_json. name . clone ( ) ,
10221025 scope : config_json. scope ,
10231026 language_id,
1024- file_types : config_json. file_types . unwrap_or ( Vec :: new ( ) ) ,
1027+ file_types : config_json. file_types . unwrap_or_default ( ) ,
10251028 content_regex : Self :: regex ( config_json. content_regex . as_deref ( ) ) ,
10261029 first_line_regex : Self :: regex ( config_json. first_line_regex . as_deref ( ) ) ,
10271030 injection_regex : Self :: regex ( config_json. injection_regex . as_deref ( ) ) ,
@@ -1048,8 +1051,11 @@ impl Loader {
10481051 . push ( self . language_configurations . len ( ) ) ;
10491052 }
10501053
1051- self . language_configurations
1052- . push ( unsafe { mem:: transmute ( configuration) } ) ;
1054+ self . language_configurations . push ( unsafe {
1055+ mem:: transmute :: < LanguageConfiguration < ' _ > , LanguageConfiguration < ' static > > (
1056+ configuration,
1057+ )
1058+ } ) ;
10531059
10541060 if set_current_path_config
10551061 && self . language_configuration_in_current_path . is_none ( )
@@ -1088,8 +1094,11 @@ impl Loader {
10881094 highlight_names : & self . highlight_names ,
10891095 use_all_highlight_names : self . use_all_highlight_names ,
10901096 } ;
1091- self . language_configurations
1092- . push ( unsafe { mem:: transmute ( configuration) } ) ;
1097+ self . language_configurations . push ( unsafe {
1098+ mem:: transmute :: < LanguageConfiguration < ' _ > , LanguageConfiguration < ' static > > (
1099+ configuration,
1100+ )
1101+ } ) ;
10931102 self . languages_by_id
10941103 . push ( ( parser_path. to_owned ( ) , OnceCell :: new ( ) , None ) ) ;
10951104 }
@@ -1327,8 +1336,7 @@ impl<'a> LanguageConfiguration<'a> {
13271336 . unwrap_or_else ( || ranges. last ( ) . unwrap ( ) ) ;
13281337 error. offset = offset_within_section - range. start ;
13291338 error. row = source[ range. start ..offset_within_section]
1330- . chars ( )
1331- . filter ( |c| * c == '\n' )
1339+ . matches ( |c| c == '\n' )
13321340 . count ( ) ;
13331341 Error :: from ( error) . context ( format ! ( "Error in query file {path:?}" ) )
13341342 }
0 commit comments