File tree Expand file tree Collapse file tree 2 files changed +33
-24
lines changed Expand file tree Collapse file tree 2 files changed +33
-24
lines changed Original file line number Diff line number Diff line change @@ -102,7 +102,11 @@ fn execute() -> i32 {
102
102
if opts. version {
103
103
return handle_command_status ( get_rustfmt_info ( & [ String :: from ( "--version" ) ] ) ) ;
104
104
}
105
- if opts. rustfmt_options . iter ( ) . any ( |s| is_status_options ( s. as_str ( ) ) ) {
105
+ if opts
106
+ . rustfmt_options
107
+ . iter ( )
108
+ . any ( |s| is_status_options ( s. as_str ( ) ) )
109
+ {
106
110
return handle_command_status ( get_rustfmt_info ( & opts. rustfmt_options ) ) ;
107
111
}
108
112
Original file line number Diff line number Diff line change @@ -903,29 +903,34 @@ impl Drop for TempFile {
903
903
}
904
904
}
905
905
906
- fn rustfmt ( ) -> PathBuf {
907
- let mut me = env:: current_exe ( ) . expect ( "failed to get current executable" ) ;
908
- // Chop of the test name.
909
- me. pop ( ) ;
910
- // Chop off `deps`.
911
- me. pop ( ) ;
912
-
913
- // If we run `cargo test --release`, we might only have a release build.
914
- if cfg ! ( release) {
915
- // `../release/`
916
- me. pop ( ) ;
917
- me. push ( "release" ) ;
918
- }
919
- me. push ( "rustfmt" ) ;
920
- assert ! (
921
- me. is_file( ) || me. with_extension( "exe" ) . is_file( ) ,
922
- if cfg!( release) {
923
- "no rustfmt bin, try running `cargo build --release` before testing"
924
- } else {
925
- "no rustfmt bin, try running `cargo build` before testing"
926
- }
927
- ) ;
928
- me
906
+ fn rustfmt ( ) -> & ' static Path {
907
+ lazy_static ! {
908
+ static ref RUSTFMT_PATH : PathBuf = {
909
+ let mut me = env:: current_exe( ) . expect( "failed to get current executable" ) ;
910
+ // Chop of the test name.
911
+ me. pop( ) ;
912
+ // Chop off `deps`.
913
+ me. pop( ) ;
914
+
915
+ // If we run `cargo test --release`, we might only have a release build.
916
+ if cfg!( release) {
917
+ // `../release/`
918
+ me. pop( ) ;
919
+ me. push( "release" ) ;
920
+ }
921
+ me. push( "rustfmt" ) ;
922
+ assert!(
923
+ me. is_file( ) || me. with_extension( "exe" ) . is_file( ) ,
924
+ if cfg!( release) {
925
+ "no rustfmt bin, try running `cargo build --release` before testing"
926
+ } else {
927
+ "no rustfmt bin, try running `cargo build` before testing"
928
+ }
929
+ ) ;
930
+ me
931
+ } ;
932
+ }
933
+ & RUSTFMT_PATH
929
934
}
930
935
931
936
#[ test]
You can’t perform that action at this time.
0 commit comments