File tree 9 files changed +16
-32
lines changed
rustc_smir/src/rustc_internal
9 files changed +16
-32
lines changed Original file line number Diff line number Diff line change @@ -207,23 +207,7 @@ pub fn diagnostics_registry() -> Registry {
207
207
}
208
208
209
209
/// This is the primary entry point for rustc.
210
- pub struct RunCompiler <' a> {
211
- at_args: & ' a [ String ] ,
212
- callbacks: & ' a mut ( dyn Callbacks + Send ) ,
213
- }
214
-
215
- impl <' a> RunCompiler <' a> {
216
- pub fn new( at_args: & ' a [ String ] , callbacks: & ' a mut ( dyn Callbacks + Send ) ) -> Self {
217
- Self { at_args, callbacks }
218
- }
219
-
220
- /// Parse args and run the compiler.
221
- pub fn run( self ) {
222
- run_compiler( self . at_args, self . callbacks) ;
223
- }
224
- }
225
-
226
- fn run_compiler( at_args: & [ String ] , callbacks: & mut ( dyn Callbacks + Send ) ) {
210
+ pub fn run_compiler( at_args: & [ String ] , callbacks: & mut ( dyn Callbacks + Send ) ) {
227
211
let mut default_early_dcx = EarlyDiagCtxt :: new( ErrorOutputType :: default ( ) ) ;
228
212
229
213
// Throw away the first argument, the name of the binary.
@@ -1516,7 +1500,7 @@ pub fn main() -> ! {
1516
1500
install_ctrlc_handler( ) ;
1517
1501
1518
1502
let exit_code = catch_with_exit_code( || {
1519
- RunCompiler :: new ( & args:: raw_args( & early_dcx) ?, & mut callbacks) . run ( ) ;
1503
+ run_compiler ( & args:: raw_args( & early_dcx) ?, & mut callbacks) ;
1520
1504
Ok ( ( ) )
1521
1505
} ) ;
1522
1506
Original file line number Diff line number Diff line change @@ -316,7 +316,7 @@ macro_rules! optional {
316
316
#[ doc( hidden) ]
317
317
macro_rules! run_driver {
318
318
( $args: expr, $callback: expr $( , $with_tcx: ident) ?) => { {
319
- use rustc_driver:: { Callbacks , Compilation , RunCompiler } ;
319
+ use rustc_driver:: { Callbacks , Compilation , run_compiler } ;
320
320
use rustc_middle:: ty:: TyCtxt ;
321
321
use rustc_interface:: interface;
322
322
use stable_mir:: CompilerError ;
@@ -347,7 +347,7 @@ macro_rules! run_driver {
347
347
/// Runs the compiler against given target and tests it with `test_function`
348
348
pub fn run( & mut self ) -> Result <C , CompilerError <B >> {
349
349
let compiler_result = rustc_driver:: catch_fatal_errors( || -> interface:: Result :: <( ) > {
350
- RunCompiler :: new ( & self . args. clone( ) , self ) . run ( ) ;
350
+ run_compiler ( & self . args. clone( ) , self ) ;
351
351
Ok ( ( ) )
352
352
} ) ;
353
353
match ( compiler_result, self . result. take( ) ) {
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ use std::path::Path;
18
18
19
19
use rustc_ast_pretty:: pprust:: item_to_string;
20
20
use rustc_data_structures:: sync:: Lrc ;
21
- use rustc_driver:: { Compilation , RunCompiler } ;
21
+ use rustc_driver:: { Compilation , run_compiler } ;
22
22
use rustc_interface:: interface:: { Compiler , Config } ;
23
23
use rustc_middle:: ty:: TyCtxt ;
24
24
@@ -87,5 +87,5 @@ impl rustc_driver::Callbacks for MyCallbacks {
87
87
}
88
88
89
89
fn main ( ) {
90
- RunCompiler :: new ( & [ "main.rs" . to_string ( ) ] , & mut MyCallbacks ) . run ( ) ;
90
+ run_compiler ( & [ "main.rs" . to_string ( ) ] , & mut MyCallbacks ) ;
91
91
}
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ use std::path::Path;
18
18
19
19
use rustc_ast_pretty:: pprust:: item_to_string;
20
20
use rustc_data_structures:: sync:: Lrc ;
21
- use rustc_driver:: { Compilation , RunCompiler } ;
21
+ use rustc_driver:: { Compilation , run_compiler } ;
22
22
use rustc_interface:: interface:: { Compiler , Config } ;
23
23
use rustc_middle:: ty:: TyCtxt ;
24
24
@@ -94,5 +94,5 @@ impl rustc_driver::Callbacks for MyCallbacks {
94
94
}
95
95
96
96
fn main ( ) {
97
- RunCompiler :: new ( & [ "main.rs" . to_string ( ) ] , & mut MyCallbacks ) . run ( ) ;
97
+ run_compiler ( & [ "main.rs" . to_string ( ) ] , & mut MyCallbacks ) ;
98
98
}
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ The [`rustc_driver`] is essentially `rustc`'s `main` function.
6
6
It acts as the glue for running the various phases of the compiler in the correct order,
7
7
using the interface defined in the [ ` rustc_interface ` ] crate. Where possible, using [ ` rustc_driver ` ] rather than [ ` rustc_interface ` ] is recommended.
8
8
9
- The main entry point of [ ` rustc_driver ` ] is [ ` rustc_driver::RunCompiler ` ] [ rd_rc ] .
9
+ The main entry point of [ ` rustc_driver ` ] is [ ` rustc_driver::run_compiler ` ] [ rd_rc ] .
10
10
This builder accepts the same command-line args as rustc as well as an implementation of [ ` Callbacks ` ] [ cb ] and a couple of other optional options.
11
11
[ ` Callbacks ` ] [ cb ] is a ` trait ` that allows for custom compiler configuration,
12
12
as well as allowing custom code to run after different phases of the compilation.
@@ -40,7 +40,7 @@ specifically [`rustc_driver_impl::run_compiler`][rdi_rc]
40
40
[ cb ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/trait.Callbacks.html
41
41
[ example ] : https://github.com/rust-lang/rustc-dev-guide/blob/master/examples/rustc-interface-example.rs
42
42
[ i_rc ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/interface/fn.run_compiler.html
43
- [ rd_rc ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/struct.RunCompiler .html
43
+ [ rd_rc ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/fn.run_compiler .html
44
44
[ rdi_rc ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver_impl/fn.run_compiler.html
45
45
[ stupid-stats ] : https://github.com/nrc/stupid-stats
46
46
[ `nightly-rustc` ] : https://doc.rust-lang.org/nightly/nightly-rustc/
Original file line number Diff line number Diff line change @@ -236,7 +236,7 @@ pub fn main() {
236
236
let mut args: Vec < String > = orig_args. clone ( ) ;
237
237
pass_sysroot_env_if_given ( & mut args, sys_root_env) ;
238
238
239
- rustc_driver:: RunCompiler :: new ( & args, & mut DefaultCallbacks ) . run ( ) ;
239
+ rustc_driver:: run_compiler ( & args, & mut DefaultCallbacks ) ;
240
240
return Ok ( ( ) ) ;
241
241
}
242
242
@@ -295,9 +295,9 @@ pub fn main() {
295
295
let clippy_enabled = !cap_lints_allow && relevant_package && !info_query;
296
296
if clippy_enabled {
297
297
args. extend ( clippy_args) ;
298
- rustc_driver:: RunCompiler :: new ( & args, & mut ClippyCallbacks { clippy_args_var } ) . run ( ) ;
298
+ rustc_driver:: run_compiler ( & args, & mut ClippyCallbacks { clippy_args_var } ) ;
299
299
} else {
300
- rustc_driver:: RunCompiler :: new ( & args, & mut RustcCallbacks { clippy_args_var } ) . run ( ) ;
300
+ rustc_driver:: run_compiler ( & args, & mut RustcCallbacks { clippy_args_var } ) ;
301
301
}
302
302
Ok ( ( ) )
303
303
} ) )
Original file line number Diff line number Diff line change @@ -374,7 +374,7 @@ fn run_compiler_and_exit(
374
374
) -> ! {
375
375
// Invoke compiler, and handle return code.
376
376
let exit_code = rustc_driver:: catch_with_exit_code ( move || {
377
- rustc_driver:: RunCompiler :: new ( args, callbacks) . run ( ) ;
377
+ rustc_driver:: run_compiler ( args, callbacks) ;
378
378
Ok ( ( ) )
379
379
} ) ;
380
380
std:: process:: exit ( exit_code)
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ fn main() {
25
25
let mut count = 1 ;
26
26
let args = vec ! [ "compiler-calls" . to_string( ) , "foo.rs" . to_string( ) ] ;
27
27
rustc_driver:: catch_fatal_errors ( || -> interface:: Result < ( ) > {
28
- rustc_driver:: RunCompiler :: new ( & args, & mut TestCalls { count : & mut count } ) . run ( ) ;
28
+ rustc_driver:: run_compiler ( & args, & mut TestCalls { count : & mut count } ) ;
29
29
Ok ( ( ) )
30
30
} )
31
31
. ok ( ) ;
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ fn main() {
47
47
rustc_args. push ( "-Zpolonius" . to_owned ( ) ) ;
48
48
let mut callbacks = CompilerCalls :: default ( ) ;
49
49
// Call the Rust compiler with our callbacks.
50
- rustc_driver:: RunCompiler :: new ( & rustc_args, & mut callbacks) . run ( ) ;
50
+ rustc_driver:: run_compiler ( & rustc_args, & mut callbacks) ;
51
51
Ok ( ( ) )
52
52
} ) ;
53
53
std:: process:: exit ( exit_code) ;
You can’t perform that action at this time.
0 commit comments