@@ -114,7 +114,7 @@ pub struct Mismatch {
114
114
115
115
impl Mismatch {
116
116
fn new ( line_number : u32 ) -> Mismatch {
117
- Mismatch { line_number : line_number , lines : Vec :: new ( ) }
117
+ Mismatch { line_number, lines : Vec :: new ( ) }
118
118
}
119
119
}
120
120
@@ -199,7 +199,7 @@ fn write_diff(expected: &str, actual: &str, context_size: usize) -> String {
199
199
}
200
200
}
201
201
}
202
- writeln ! ( output, "" ) . unwrap ( ) ;
202
+ writeln ! ( output) . unwrap ( ) ;
203
203
}
204
204
output
205
205
}
@@ -230,7 +230,7 @@ pub fn run(config: Config, testpaths: &TestPaths, revision: Option<&str>) {
230
230
debug ! ( "running {:?}" , testpaths. file. display( ) ) ;
231
231
let props = TestProps :: from_file ( & testpaths. file , revision, & config) ;
232
232
233
- let cx = TestCx { config : & config, props : & props, testpaths, revision : revision } ;
233
+ let cx = TestCx { config : & config, props : & props, testpaths, revision } ;
234
234
create_dir_all ( & cx. output_base_dir ( ) ) . unwrap ( ) ;
235
235
236
236
if config. mode == Incremental {
@@ -578,8 +578,8 @@ impl<'test> TestCx<'test> {
578
578
if self . props . pp_exact . is_some ( ) {
579
579
// Now we have to care about line endings
580
580
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, "" ) ;
583
583
}
584
584
585
585
self . compare_source ( & expected, & actual) ;
@@ -740,7 +740,7 @@ impl<'test> TestCx<'test> {
740
740
let exe_file = self . make_exe_name ( ) ;
741
741
742
742
let prefixes = {
743
- static PREFIXES : & ' static [ & ' static str ] = & [ "cdb" , "cdbg" ] ;
743
+ static PREFIXES : & [ & str ] = & [ "cdb" , "cdbg" ] ;
744
744
// No "native rust support" variation for CDB yet.
745
745
PREFIXES
746
746
} ;
@@ -811,12 +811,12 @@ impl<'test> TestCx<'test> {
811
811
fn run_debuginfo_gdb_test_no_opt ( & self ) {
812
812
let prefixes = if self . config . gdb_native_rust {
813
813
// GDB with Rust
814
- static PREFIXES : & ' static [ & ' static str ] = & [ "gdb" , "gdbr" ] ;
814
+ static PREFIXES : & [ & str ] = & [ "gdb" , "gdbr" ] ;
815
815
println ! ( "NOTE: compiletest thinks it is using GDB with native rust support" ) ;
816
816
PREFIXES
817
817
} else {
818
818
// Generic GDB
819
- static PREFIXES : & ' static [ & ' static str ] = & [ "gdb" , "gdbg" ] ;
819
+ static PREFIXES : & [ & str ] = & [ "gdb" , "gdbg" ] ;
820
820
println ! ( "NOTE: compiletest thinks it is using GDB without native rust support" ) ;
821
821
PREFIXES
822
822
} ;
@@ -875,12 +875,12 @@ impl<'test> TestCx<'test> {
875
875
. arg ( & exe_file)
876
876
. arg ( & self . config . adb_test_dir )
877
877
. status ( )
878
- . expect ( & format ! ( "failed to exec `{:?}`" , adb_path) ) ;
878
+ . unwrap_or_else ( |_| panic ! ( "failed to exec `{:?}`" , adb_path) ) ;
879
879
880
880
Command :: new ( adb_path)
881
881
. args ( & [ "forward" , "tcp:5039" , "tcp:5039" ] )
882
882
. status ( )
883
- . expect ( & format ! ( "failed to exec `{:?}`" , adb_path) ) ;
883
+ . unwrap_or_else ( |_| panic ! ( "failed to exec `{:?}`" , adb_path) ) ;
884
884
885
885
let adb_arg = format ! (
886
886
"export LD_LIBRARY_PATH={}; \
@@ -897,7 +897,7 @@ impl<'test> TestCx<'test> {
897
897
. stdout ( Stdio :: piped ( ) )
898
898
. stderr ( Stdio :: inherit ( ) )
899
899
. spawn ( )
900
- . expect ( & format ! ( "failed to exec `{:?}`" , adb_path) ) ;
900
+ . unwrap_or_else ( |_| panic ! ( "failed to exec `{:?}`" , adb_path) ) ;
901
901
902
902
// Wait for the gdbserver to print out "Listening on port ..."
903
903
// at which point we know that it's started and then we can
@@ -922,7 +922,7 @@ impl<'test> TestCx<'test> {
922
922
let Output { status, stdout, stderr } = Command :: new ( & gdb_path)
923
923
. args ( debugger_opts)
924
924
. output ( )
925
- . expect ( & format ! ( "failed to exec `{:?}`" , gdb_path) ) ;
925
+ . unwrap_or_else ( |_| panic ! ( "failed to exec `{:?}`" , gdb_path) ) ;
926
926
let cmdline = {
927
927
let mut gdb = Command :: new ( & format ! ( "{}-gdb" , self . config. target) ) ;
928
928
gdb. args ( debugger_opts) ;
@@ -1063,11 +1063,11 @@ impl<'test> TestCx<'test> {
1063
1063
}
1064
1064
1065
1065
let prefixes = if self . config . lldb_native_rust {
1066
- static PREFIXES : & ' static [ & ' static str ] = & [ "lldb" , "lldbr" ] ;
1066
+ static PREFIXES : & [ & str ] = & [ "lldb" , "lldbr" ] ;
1067
1067
println ! ( "NOTE: compiletest thinks it is using LLDB with native rust support" ) ;
1068
1068
PREFIXES
1069
1069
} else {
1070
- static PREFIXES : & ' static [ & ' static str ] = & [ "lldb" , "lldbg" ] ;
1070
+ static PREFIXES : & [ & str ] = & [ "lldb" , "lldbg" ] ;
1071
1071
println ! ( "NOTE: compiletest thinks it is using LLDB without native rust support" ) ;
1072
1072
PREFIXES
1073
1073
} ;
@@ -1842,8 +1842,8 @@ impl<'test> TestCx<'test> {
1842
1842
1843
1843
// Need to be sure to put both the lib_path and the aux path in the dylib
1844
1844
// 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 < _ > > ( ) ;
1847
1847
if let Some ( p) = aux_path {
1848
1848
path. insert ( 0 , PathBuf :: from ( p) )
1849
1849
}
@@ -1854,7 +1854,7 @@ impl<'test> TestCx<'test> {
1854
1854
command. env ( dylib_env_var ( ) , newpath) ;
1855
1855
1856
1856
let mut child = disable_error_reporting ( || command. spawn ( ) )
1857
- . expect ( & format ! ( "failed to exec `{:?}`" , & command) ) ;
1857
+ . unwrap_or_else ( |_| panic ! ( "failed to exec `{:?}`" , & command) ) ;
1858
1858
if let Some ( input) = input {
1859
1859
child. stdin . as_mut ( ) . unwrap ( ) . write_all ( input. as_bytes ( ) ) . unwrap ( ) ;
1860
1860
}
@@ -2446,8 +2446,8 @@ impl<'test> TestCx<'test> {
2446
2446
2447
2447
self . check_no_compiler_crash ( & proc_res, self . props . should_ice ) ;
2448
2448
2449
- const PREFIX : & ' static str = "MONO_ITEM " ;
2450
- const CGU_MARKER : & ' static str = "@@" ;
2449
+ const PREFIX : & str = "MONO_ITEM " ;
2450
+ const CGU_MARKER : & str = "@@" ;
2451
2451
2452
2452
let actual: Vec < MonoItem > = proc_res
2453
2453
. stdout
@@ -2976,7 +2976,7 @@ impl<'test> TestCx<'test> {
2976
2976
Filter :: MachineApplicableOnly ,
2977
2977
)
2978
2978
. unwrap_or_default ( ) ;
2979
- if suggestions. len ( ) > 0
2979
+ if ! suggestions. is_empty ( )
2980
2980
&& !self . props . run_rustfix
2981
2981
&& !self . props . rustfix_only_machine_applicable
2982
2982
{
@@ -2990,7 +2990,7 @@ impl<'test> TestCx<'test> {
2990
2990
. open ( coverage_file_path. as_path ( ) )
2991
2991
. expect ( "could not create or open file" ) ;
2992
2992
2993
- if let Err ( _ ) = writeln ! ( file, "{}" , self . testpaths. file. display( ) ) {
2993
+ if writeln ! ( file, "{}" , self . testpaths. file. display( ) ) . is_err ( ) {
2994
2994
panic ! ( "couldn't write to {}" , coverage_file_path. display( ) ) ;
2995
2995
}
2996
2996
}
@@ -3007,10 +3007,9 @@ impl<'test> TestCx<'test> {
3007
3007
} ,
3008
3008
)
3009
3009
. 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
+ } ) ;
3014
3013
3015
3014
errors += self . compare_output ( "fixed" , & fixed_code, & expected_fixed) ;
3016
3015
} else if !expected_fixed. is_empty ( ) {
@@ -3519,7 +3518,7 @@ impl<'test> TestCx<'test> {
3519
3518
let examined_content =
3520
3519
self . load_expected_output_from_path ( & examined_path) . unwrap_or_else ( |_| String :: new ( ) ) ;
3521
3520
3522
- if canon_content == & examined_content {
3521
+ if canon_content == examined_content {
3523
3522
self . delete_file ( & examined_path) ;
3524
3523
}
3525
3524
}
0 commit comments