@@ -95,7 +95,7 @@ fn verify_config_test_names() {
95
95
let config_name = path. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
96
96
97
97
// Make sure that config name is used in the files in the directory.
98
- verify_config_used ( & path, & config_name) ;
98
+ verify_config_used ( & path, config_name) ;
99
99
}
100
100
}
101
101
}
@@ -105,7 +105,7 @@ fn verify_config_test_names() {
105
105
// println!) that is used by `rustfmt::rustfmt_diff::print_diff`. Writing
106
106
// using only one or the other will cause the output order to differ when
107
107
// `print_diff` selects the approach not used.
108
- fn write_message ( msg : String ) {
108
+ fn write_message ( msg : & str ) {
109
109
let mut writer = OutputWriter :: new ( Color :: Auto ) ;
110
110
writer. writeln ( & format ! ( "{}" , msg) , None ) ;
111
111
}
@@ -359,8 +359,8 @@ pub enum IdempotentCheckError {
359
359
}
360
360
361
361
pub fn idempotent_check ( filename : & PathBuf ) -> Result < FormatReport , IdempotentCheckError > {
362
- let sig_comments = read_significant_comments ( & filename) ;
363
- let config = read_config ( & filename) ;
362
+ let sig_comments = read_significant_comments ( filename) ;
363
+ let config = read_config ( filename) ;
364
364
let ( error_summary, file_map, format_report) = format_file ( filename, & config) ;
365
365
if error_summary. has_parsing_errors ( ) {
366
366
return Err ( IdempotentCheckError :: Parse ) ;
@@ -660,15 +660,15 @@ impl ConfigCodeBlock {
660
660
assert ! ( self . code_block. is_some( ) && self . code_block_start. is_some( ) ) ;
661
661
662
662
if self . config_name . is_none ( ) {
663
- write_message ( format ! (
663
+ write_message ( & format ! (
664
664
"No configuration name for {}:{}" ,
665
665
CONFIGURATIONS_FILE_NAME ,
666
666
self . code_block_start. unwrap( )
667
667
) ) ;
668
668
return false ;
669
669
}
670
670
if self . config_value . is_none ( ) {
671
- write_message ( format ! (
671
+ write_message ( & format ! (
672
672
"No configuration value for {}:{}" ,
673
673
CONFIGURATIONS_FILE_NAME ,
674
674
self . code_block_start. unwrap( )
@@ -680,7 +680,7 @@ impl ConfigCodeBlock {
680
680
681
681
fn has_parsing_errors ( & self , error_summary : Summary ) -> bool {
682
682
if error_summary. has_parsing_errors ( ) {
683
- write_message ( format ! (
683
+ write_message ( & format ! (
684
684
"\u{261d} \u{1f3fd} Cannot format {}:{}" ,
685
685
CONFIGURATIONS_FILE_NAME ,
686
686
self . code_block_start. unwrap( )
@@ -703,7 +703,7 @@ impl ConfigCodeBlock {
703
703
} ) ;
704
704
}
705
705
706
- fn formatted_has_diff ( & self , file_map : FileMap ) -> bool {
706
+ fn formatted_has_diff ( & self , file_map : & FileMap ) -> bool {
707
707
let & ( ref _file_name, ref text) = file_map. first ( ) . unwrap ( ) ;
708
708
let compare = make_diff ( self . code_block . as_ref ( ) . unwrap ( ) , text, DIFF_CONTEXT_SIZE ) ;
709
709
if !compare. is_empty ( ) {
@@ -729,7 +729,7 @@ impl ConfigCodeBlock {
729
729
let ( error_summary, file_map, _report) =
730
730
format_input :: < io:: Stdout > ( input, & config, None ) . unwrap ( ) ;
731
731
732
- !self . has_parsing_errors ( error_summary) && !self . formatted_has_diff ( file_map)
732
+ !self . has_parsing_errors ( error_summary) && !self . formatted_has_diff ( & file_map)
733
733
}
734
734
735
735
// Extract a code block from the iterator. Behavior:
@@ -746,7 +746,7 @@ impl ConfigCodeBlock {
746
746
prev : Option < & ConfigCodeBlock > ,
747
747
) -> Option < ConfigCodeBlock > {
748
748
let mut code_block = ConfigCodeBlock :: new ( ) ;
749
- code_block. config_name = prev. map_or ( None , |cb| cb. config_name . clone ( ) ) ;
749
+ code_block. config_name = prev. and_then ( |cb| cb. config_name . clone ( ) ) ;
750
750
751
751
loop {
752
752
match ConfigurationSection :: get_section ( file) {
0 commit comments