@@ -114,7 +114,7 @@ pub struct Mismatch {
114114
115115impl Mismatch {
116116 fn new ( line_number : u32 ) -> Mismatch {
117- Mismatch { line_number : line_number , lines : Vec :: new ( ) }
117+ Mismatch { line_number, lines : Vec :: new ( ) }
118118 }
119119}
120120
@@ -199,7 +199,7 @@ fn write_diff(expected: &str, actual: &str, context_size: usize) -> String {
199199 }
200200 }
201201 }
202- writeln ! ( output, "" ) . unwrap ( ) ;
202+ writeln ! ( output) . unwrap ( ) ;
203203 }
204204 output
205205}
@@ -230,7 +230,7 @@ pub fn run(config: Config, testpaths: &TestPaths, revision: Option<&str>) {
230230 debug ! ( "running {:?}" , testpaths. file. display( ) ) ;
231231 let props = TestProps :: from_file ( & testpaths. file , revision, & config) ;
232232
233- let cx = TestCx { config : & config, props : & props, testpaths, revision : revision } ;
233+ let cx = TestCx { config : & config, props : & props, testpaths, revision } ;
234234 create_dir_all ( & cx. output_base_dir ( ) ) . unwrap ( ) ;
235235
236236 if config. mode == Incremental {
@@ -578,8 +578,8 @@ impl<'test> TestCx<'test> {
578578 if self . props . pp_exact . is_some ( ) {
579579 // Now we have to care about line endings
580580 let cr = "\r " . to_owned ( ) ;
581- actual = actual. replace ( & cr, "" ) . to_owned ( ) ;
582- expected = expected. replace ( & cr, "" ) . to_owned ( ) ;
581+ actual = actual. replace ( & cr, "" ) ;
582+ expected = expected. replace ( & cr, "" ) ;
583583 }
584584
585585 self . compare_source ( & expected, & actual) ;
@@ -740,7 +740,7 @@ impl<'test> TestCx<'test> {
740740 let exe_file = self . make_exe_name ( ) ;
741741
742742 let prefixes = {
743- static PREFIXES : & ' static [ & ' static str ] = & [ "cdb" , "cdbg" ] ;
743+ static PREFIXES : & [ & str ] = & [ "cdb" , "cdbg" ] ;
744744 // No "native rust support" variation for CDB yet.
745745 PREFIXES
746746 } ;
@@ -811,12 +811,12 @@ impl<'test> TestCx<'test> {
811811 fn run_debuginfo_gdb_test_no_opt ( & self ) {
812812 let prefixes = if self . config . gdb_native_rust {
813813 // GDB with Rust
814- static PREFIXES : & ' static [ & ' static str ] = & [ "gdb" , "gdbr" ] ;
814+ static PREFIXES : & [ & str ] = & [ "gdb" , "gdbr" ] ;
815815 println ! ( "NOTE: compiletest thinks it is using GDB with native rust support" ) ;
816816 PREFIXES
817817 } else {
818818 // Generic GDB
819- static PREFIXES : & ' static [ & ' static str ] = & [ "gdb" , "gdbg" ] ;
819+ static PREFIXES : & [ & str ] = & [ "gdb" , "gdbg" ] ;
820820 println ! ( "NOTE: compiletest thinks it is using GDB without native rust support" ) ;
821821 PREFIXES
822822 } ;
@@ -875,12 +875,12 @@ impl<'test> TestCx<'test> {
875875 . arg ( & exe_file)
876876 . arg ( & self . config . adb_test_dir )
877877 . status ( )
878- . expect ( & format ! ( "failed to exec `{:?}`" , adb_path) ) ;
878+ . unwrap_or_else ( |_| panic ! ( "failed to exec `{:?}`" , adb_path) ) ;
879879
880880 Command :: new ( adb_path)
881881 . args ( & [ "forward" , "tcp:5039" , "tcp:5039" ] )
882882 . status ( )
883- . expect ( & format ! ( "failed to exec `{:?}`" , adb_path) ) ;
883+ . unwrap_or_else ( |_| panic ! ( "failed to exec `{:?}`" , adb_path) ) ;
884884
885885 let adb_arg = format ! (
886886 "export LD_LIBRARY_PATH={}; \
@@ -897,7 +897,7 @@ impl<'test> TestCx<'test> {
897897 . stdout ( Stdio :: piped ( ) )
898898 . stderr ( Stdio :: inherit ( ) )
899899 . spawn ( )
900- . expect ( & format ! ( "failed to exec `{:?}`" , adb_path) ) ;
900+ . unwrap_or_else ( |_| panic ! ( "failed to exec `{:?}`" , adb_path) ) ;
901901
902902 // Wait for the gdbserver to print out "Listening on port ..."
903903 // at which point we know that it's started and then we can
@@ -922,7 +922,7 @@ impl<'test> TestCx<'test> {
922922 let Output { status, stdout, stderr } = Command :: new ( & gdb_path)
923923 . args ( debugger_opts)
924924 . output ( )
925- . expect ( & format ! ( "failed to exec `{:?}`" , gdb_path) ) ;
925+ . unwrap_or_else ( |_| panic ! ( "failed to exec `{:?}`" , gdb_path) ) ;
926926 let cmdline = {
927927 let mut gdb = Command :: new ( & format ! ( "{}-gdb" , self . config. target) ) ;
928928 gdb. args ( debugger_opts) ;
@@ -1063,11 +1063,11 @@ impl<'test> TestCx<'test> {
10631063 }
10641064
10651065 let prefixes = if self . config . lldb_native_rust {
1066- static PREFIXES : & ' static [ & ' static str ] = & [ "lldb" , "lldbr" ] ;
1066+ static PREFIXES : & [ & str ] = & [ "lldb" , "lldbr" ] ;
10671067 println ! ( "NOTE: compiletest thinks it is using LLDB with native rust support" ) ;
10681068 PREFIXES
10691069 } else {
1070- static PREFIXES : & ' static [ & ' static str ] = & [ "lldb" , "lldbg" ] ;
1070+ static PREFIXES : & [ & str ] = & [ "lldb" , "lldbg" ] ;
10711071 println ! ( "NOTE: compiletest thinks it is using LLDB without native rust support" ) ;
10721072 PREFIXES
10731073 } ;
@@ -1842,8 +1842,8 @@ impl<'test> TestCx<'test> {
18421842
18431843 // Need to be sure to put both the lib_path and the aux path in the dylib
18441844 // search path for the child.
1845- let mut path = env :: split_paths ( & env :: var_os ( dylib_env_var ( ) ) . unwrap_or ( OsString :: new ( ) ) )
1846- . collect :: < Vec < _ > > ( ) ;
1845+ let mut path =
1846+ env :: split_paths ( & env :: var_os ( dylib_env_var ( ) ) . unwrap_or_default ( ) ) . collect :: < Vec < _ > > ( ) ;
18471847 if let Some ( p) = aux_path {
18481848 path. insert ( 0 , PathBuf :: from ( p) )
18491849 }
@@ -1854,7 +1854,7 @@ impl<'test> TestCx<'test> {
18541854 command. env ( dylib_env_var ( ) , newpath) ;
18551855
18561856 let mut child = disable_error_reporting ( || command. spawn ( ) )
1857- . expect ( & format ! ( "failed to exec `{:?}`" , & command) ) ;
1857+ . unwrap_or_else ( |_| panic ! ( "failed to exec `{:?}`" , & command) ) ;
18581858 if let Some ( input) = input {
18591859 child. stdin . as_mut ( ) . unwrap ( ) . write_all ( input. as_bytes ( ) ) . unwrap ( ) ;
18601860 }
@@ -2446,8 +2446,8 @@ impl<'test> TestCx<'test> {
24462446
24472447 self . check_no_compiler_crash ( & proc_res, self . props . should_ice ) ;
24482448
2449- const PREFIX : & ' static str = "MONO_ITEM " ;
2450- const CGU_MARKER : & ' static str = "@@" ;
2449+ const PREFIX : & str = "MONO_ITEM " ;
2450+ const CGU_MARKER : & str = "@@" ;
24512451
24522452 let actual: Vec < MonoItem > = proc_res
24532453 . stdout
@@ -2976,7 +2976,7 @@ impl<'test> TestCx<'test> {
29762976 Filter :: MachineApplicableOnly ,
29772977 )
29782978 . unwrap_or_default ( ) ;
2979- if suggestions. len ( ) > 0
2979+ if ! suggestions. is_empty ( )
29802980 && !self . props . run_rustfix
29812981 && !self . props . rustfix_only_machine_applicable
29822982 {
@@ -2990,7 +2990,7 @@ impl<'test> TestCx<'test> {
29902990 . open ( coverage_file_path. as_path ( ) )
29912991 . expect ( "could not create or open file" ) ;
29922992
2993- if let Err ( _ ) = writeln ! ( file, "{}" , self . testpaths. file. display( ) ) {
2993+ if writeln ! ( file, "{}" , self . testpaths. file. display( ) ) . is_err ( ) {
29942994 panic ! ( "couldn't write to {}" , coverage_file_path. display( ) ) ;
29952995 }
29962996 }
@@ -3007,10 +3007,9 @@ impl<'test> TestCx<'test> {
30073007 } ,
30083008 )
30093009 . unwrap ( ) ;
3010- let fixed_code = apply_suggestions ( & unfixed_code, & suggestions) . expect ( & format ! (
3011- "failed to apply suggestions for {:?} with rustfix" ,
3012- self . testpaths. file
3013- ) ) ;
3010+ let fixed_code = apply_suggestions ( & unfixed_code, & suggestions) . unwrap_or_else ( |_| {
3011+ panic ! ( "failed to apply suggestions for {:?} with rustfix" , self . testpaths. file)
3012+ } ) ;
30143013
30153014 errors += self . compare_output ( "fixed" , & fixed_code, & expected_fixed) ;
30163015 } else if !expected_fixed. is_empty ( ) {
@@ -3519,7 +3518,7 @@ impl<'test> TestCx<'test> {
35193518 let examined_content =
35203519 self . load_expected_output_from_path ( & examined_path) . unwrap_or_else ( |_| String :: new ( ) ) ;
35213520
3522- if canon_content == & examined_content {
3521+ if canon_content == examined_content {
35233522 self . delete_file ( & examined_path) ;
35243523 }
35253524 }
0 commit comments