1111
1212use std:: collections:: HashMap ;
1313use std:: fmt;
14- use std:: fs:: { self , File } ;
15- use std:: io:: prelude:: * ;
14+ use std:: fs;
1615use std:: path:: Path ;
1716
1817use regex:: Regex ;
@@ -58,13 +57,11 @@ pub fn check(path: &Path, bad: &mut bool, verbose: bool) {
5857 let lib_features = get_and_check_lib_features ( path, bad, & features) ;
5958 assert ! ( !lib_features. is_empty( ) ) ;
6059
61- let mut contents = String :: new ( ) ;
62-
6360 super :: walk_many ( & [ & path. join ( "test/ui" ) ,
6461 & path. join ( "test/ui-fulldeps" ) ,
6562 & path. join ( "test/compile-fail" ) ] ,
6663 & mut |path| super :: filter_dirs ( path) ,
67- & mut |entry, _contents | {
64+ & mut |entry, contents | {
6865 let file = entry. path ( ) ;
6966 let filename = file. file_name ( ) . unwrap ( ) . to_string_lossy ( ) ;
7067 if !filename. ends_with ( ".rs" ) || filename == "features.rs" ||
@@ -75,9 +72,6 @@ pub fn check(path: &Path, bad: &mut bool, verbose: bool) {
7572 let filen_underscore = filename. replace ( '-' , "_" ) . replace ( ".rs" , "" ) ;
7673 let filename_is_gate_test = test_filen_gate ( & filen_underscore, & mut features) ;
7774
78- contents. truncate ( 0 ) ;
79- t ! ( t!( File :: open( & file) , & file) . read_to_string( & mut contents) ) ;
80-
8175 for ( i, line) in contents. lines ( ) . enumerate ( ) {
8276 let mut err = |msg : & str | {
8377 tidy_error ! ( bad, "{}:{}: {}" , file. display( ) , i + 1 , msg) ;
@@ -369,20 +363,16 @@ fn get_and_check_lib_features(base_src_path: &Path,
369363
370364fn map_lib_features ( base_src_path : & Path ,
371365 mf : & mut dyn FnMut ( Result < ( & str , Feature ) , & str > , & Path , usize ) ) {
372- let mut contents = String :: new ( ) ;
373366 super :: walk ( base_src_path,
374367 & mut |path| super :: filter_dirs ( path) || path. ends_with ( "src/test" ) ,
375- & mut |entry, _contents | {
368+ & mut |entry, contents | {
376369 let file = entry. path ( ) ;
377370 let filename = file. file_name ( ) . unwrap ( ) . to_string_lossy ( ) ;
378371 if !filename. ends_with ( ".rs" ) || filename == "features.rs" ||
379372 filename == "diagnostic_list.rs" {
380373 return ;
381374 }
382375
383- contents. truncate ( 0 ) ;
384- t ! ( t!( File :: open( & file) , & file) . read_to_string( & mut contents) ) ;
385-
386376 let mut becoming_feature: Option < ( String , Feature ) > = None ;
387377 for ( i, line) in contents. lines ( ) . enumerate ( ) {
388378 macro_rules! err {
0 commit comments