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