File tree 2 files changed +11
-10
lines changed
rust-analyzer/tests/slow-tests
2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -13,19 +13,18 @@ use xshell::cmd;
13
13
fn check_code_formatting ( ) {
14
14
let sh = & Shell :: new ( ) . unwrap ( ) ;
15
15
sh. change_dir ( sourcegen:: project_root ( ) ) ;
16
- sh. set_var ( "RUSTUP_TOOLCHAIN" , "stable" ) ;
17
16
18
- let out = cmd ! ( sh, "rustfmt --version" ) . read ( ) . unwrap ( ) ;
17
+ let out = cmd ! ( sh, "rustup run stable rustfmt --version" ) . read ( ) . unwrap ( ) ;
19
18
if !out. contains ( "stable" ) {
20
19
panic ! (
21
20
"Failed to run rustfmt from toolchain 'stable'. \
22
21
Please run `rustup component add rustfmt --toolchain stable` to install it.",
23
22
)
24
23
}
25
24
26
- let res = cmd ! ( sh, "cargo fmt -- --check" ) . run ( ) ;
25
+ let res = cmd ! ( sh, "rustup run stable cargo fmt -- --check" ) . run ( ) ;
27
26
if res. is_err ( ) {
28
- let _ = cmd ! ( sh, "cargo fmt" ) . run ( ) ;
27
+ let _ = cmd ! ( sh, "rustup run stable cargo fmt" ) . run ( ) ;
29
28
}
30
29
res. unwrap ( )
31
30
}
Original file line number Diff line number Diff line change @@ -136,7 +136,7 @@ impl fmt::Display for Location {
136
136
}
137
137
138
138
fn ensure_rustfmt ( sh : & Shell ) {
139
- let version = cmd ! ( sh, "rustfmt --version" ) . read ( ) . unwrap_or_default ( ) ;
139
+ let version = cmd ! ( sh, "rustup run stable rustfmt --version" ) . read ( ) . unwrap_or_default ( ) ;
140
140
if !version. contains ( "stable" ) {
141
141
panic ! (
142
142
"Failed to run rustfmt from toolchain 'stable'. \
@@ -147,13 +147,15 @@ fn ensure_rustfmt(sh: &Shell) {
147
147
148
148
pub fn reformat ( text : String ) -> String {
149
149
let sh = Shell :: new ( ) . unwrap ( ) ;
150
- sh. set_var ( "RUSTUP_TOOLCHAIN" , "stable" ) ;
151
150
ensure_rustfmt ( & sh) ;
152
151
let rustfmt_toml = project_root ( ) . join ( "rustfmt.toml" ) ;
153
- let mut stdout = cmd ! ( sh, "rustfmt --config-path {rustfmt_toml} --config fn_single_line=true" )
154
- . stdin ( text)
155
- . read ( )
156
- . unwrap ( ) ;
152
+ let mut stdout = cmd ! (
153
+ sh,
154
+ "rustup run stable rustfmt --config-path {rustfmt_toml} --config fn_single_line=true"
155
+ )
156
+ . stdin ( text)
157
+ . read ( )
158
+ . unwrap ( ) ;
157
159
if !stdout. ends_with ( '\n' ) {
158
160
stdout. push ( '\n' ) ;
159
161
}
You can’t perform that action at this time.
0 commit comments