1
1
use std:: env;
2
- use std:: ffi:: { OsStr , OsString } ;
2
+ use std:: ffi:: OsString ;
3
3
use std:: path:: Path ;
4
4
use std:: process:: { Command , Output } ;
5
5
@@ -21,6 +21,8 @@ pub struct Rustc {
21
21
cmd : Command ,
22
22
}
23
23
24
+ crate :: impl_common_helpers!( Rustc ) ;
25
+
24
26
fn setup_common ( ) -> Command {
25
27
let rustc = env:: var ( "RUSTC" ) . unwrap ( ) ;
26
28
let mut cmd = Command :: new ( rustc) ;
@@ -133,12 +135,6 @@ impl Rustc {
133
135
self
134
136
}
135
137
136
- /// Generic command argument provider. Use `.arg("-Zname")` over `.arg("-Z").arg("arg")`.
137
- pub fn arg < S : AsRef < OsStr > > ( & mut self , arg : S ) -> & mut Self {
138
- self . cmd . arg ( arg) ;
139
- self
140
- }
141
-
142
138
/// Specify the crate type.
143
139
pub fn crate_type ( & mut self , crate_type : & str ) -> & mut Self {
144
140
self . cmd . arg ( "--crate-type" ) ;
@@ -153,49 +149,6 @@ impl Rustc {
153
149
self
154
150
}
155
151
156
- /// Generic command arguments provider. Use `.arg("-Zname")` over `.arg("-Z").arg("arg")`.
157
- pub fn args < S : AsRef < OsStr > > ( & mut self , args : & [ S ] ) -> & mut Self {
158
- self . cmd . args ( args) ;
159
- self
160
- }
161
-
162
- pub fn env ( & mut self , name : impl AsRef < OsStr > , value : impl AsRef < OsStr > ) -> & mut Self {
163
- self . cmd . env ( name, value) ;
164
- self
165
- }
166
-
167
- // Command inspection, output and running helper methods
168
-
169
- /// Get the [`Output`][std::process::Output] of the finished `rustc` process.
170
- pub fn output ( & mut self ) -> Output {
171
- self . cmd . output ( ) . unwrap ( )
172
- }
173
-
174
- /// Run the constructed `rustc` command and assert that it is successfully run.
175
- #[ track_caller]
176
- pub fn run ( & mut self ) -> Output {
177
- let caller_location = std:: panic:: Location :: caller ( ) ;
178
- let caller_line_number = caller_location. line ( ) ;
179
-
180
- let output = self . cmd . output ( ) . unwrap ( ) ;
181
- if !output. status . success ( ) {
182
- handle_failed_output ( & format ! ( "{:#?}" , self . cmd) , output, caller_line_number) ;
183
- }
184
- output
185
- }
186
-
187
- #[ track_caller]
188
- pub fn run_fail ( & mut self ) -> Output {
189
- let caller_location = std:: panic:: Location :: caller ( ) ;
190
- let caller_line_number = caller_location. line ( ) ;
191
-
192
- let output = self . cmd . output ( ) . unwrap ( ) ;
193
- if output. status . success ( ) {
194
- handle_failed_output ( & format ! ( "{:#?}" , self . cmd) , output, caller_line_number) ;
195
- }
196
- output
197
- }
198
-
199
152
#[ track_caller]
200
153
pub fn run_fail_assert_exit_code ( & mut self , code : i32 ) -> Output {
201
154
let caller_location = std:: panic:: Location :: caller ( ) ;
@@ -207,10 +160,4 @@ impl Rustc {
207
160
}
208
161
output
209
162
}
210
-
211
- /// Inspect what the underlying [`Command`] is up to the current construction.
212
- pub fn inspect ( & mut self , f : impl FnOnce ( & Command ) ) -> & mut Self {
213
- f ( & self . cmd ) ;
214
- self
215
- }
216
163
}
0 commit comments