Skip to content

Commit ee7c1f4

Browse files
committed
Remove RunCompiler
It has become nothing other than a wrapper around run_compiler.
1 parent 11475b5 commit ee7c1f4

File tree

9 files changed

+16
-32
lines changed

9 files changed

+16
-32
lines changed

compiler/rustc_driver_impl/src/lib.rs

+2-18
Original file line numberDiff line numberDiff line change
@@ -207,23 +207,7 @@ pub fn diagnostics_registry() -> Registry {
207207
}
208208

209209
/// 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)) {
227211
let mut default_early_dcx = EarlyDiagCtxt::new(ErrorOutputType::default());
228212

229213
// Throw away the first argument, the name of the binary.
@@ -1516,7 +1500,7 @@ pub fn main() -> ! {
15161500
install_ctrlc_handler();
15171501

15181502
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);
15201504
Ok(())
15211505
});
15221506

compiler/rustc_smir/src/rustc_internal/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ macro_rules! optional {
316316
#[doc(hidden)]
317317
macro_rules! run_driver {
318318
($args:expr, $callback:expr $(, $with_tcx:ident)?) => {{
319-
use rustc_driver::{Callbacks, Compilation, RunCompiler};
319+
use rustc_driver::{Callbacks, Compilation, run_compiler};
320320
use rustc_middle::ty::TyCtxt;
321321
use rustc_interface::interface;
322322
use stable_mir::CompilerError;
@@ -347,7 +347,7 @@ macro_rules! run_driver {
347347
/// Runs the compiler against given target and tests it with `test_function`
348348
pub fn run(&mut self) -> Result<C, CompilerError<B>> {
349349
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);
351351
Ok(())
352352
});
353353
match (compiler_result, self.result.take()) {

src/doc/rustc-dev-guide/examples/rustc-driver-example.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::path::Path;
1818

1919
use rustc_ast_pretty::pprust::item_to_string;
2020
use rustc_data_structures::sync::Lrc;
21-
use rustc_driver::{Compilation, RunCompiler};
21+
use rustc_driver::{Compilation, run_compiler};
2222
use rustc_interface::interface::{Compiler, Config};
2323
use rustc_middle::ty::TyCtxt;
2424

@@ -87,5 +87,5 @@ impl rustc_driver::Callbacks for MyCallbacks {
8787
}
8888

8989
fn main() {
90-
RunCompiler::new(&["main.rs".to_string()], &mut MyCallbacks).run();
90+
run_compiler(&["main.rs".to_string()], &mut MyCallbacks);
9191
}

src/doc/rustc-dev-guide/examples/rustc-driver-interacting-with-the-ast.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::path::Path;
1818

1919
use rustc_ast_pretty::pprust::item_to_string;
2020
use rustc_data_structures::sync::Lrc;
21-
use rustc_driver::{Compilation, RunCompiler};
21+
use rustc_driver::{Compilation, run_compiler};
2222
use rustc_interface::interface::{Compiler, Config};
2323
use rustc_middle::ty::TyCtxt;
2424

@@ -94,5 +94,5 @@ impl rustc_driver::Callbacks for MyCallbacks {
9494
}
9595

9696
fn main() {
97-
RunCompiler::new(&["main.rs".to_string()], &mut MyCallbacks).run();
97+
run_compiler(&["main.rs".to_string()], &mut MyCallbacks);
9898
}

src/doc/rustc-dev-guide/src/rustc-driver/intro.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The [`rustc_driver`] is essentially `rustc`'s `main` function.
66
It acts as the glue for running the various phases of the compiler in the correct order,
77
using the interface defined in the [`rustc_interface`] crate. Where possible, using [`rustc_driver`] rather than [`rustc_interface`] is recommended.
88

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].
1010
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.
1111
[`Callbacks`][cb] is a `trait` that allows for custom compiler configuration,
1212
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]
4040
[cb]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver/trait.Callbacks.html
4141
[example]: https://github.com/rust-lang/rustc-dev-guide/blob/master/examples/rustc-interface-example.rs
4242
[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
4444
[rdi_rc]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_driver_impl/fn.run_compiler.html
4545
[stupid-stats]: https://github.com/nrc/stupid-stats
4646
[`nightly-rustc`]: https://doc.rust-lang.org/nightly/nightly-rustc/

src/tools/clippy/src/driver.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ pub fn main() {
236236
let mut args: Vec<String> = orig_args.clone();
237237
pass_sysroot_env_if_given(&mut args, sys_root_env);
238238

239-
rustc_driver::RunCompiler::new(&args, &mut DefaultCallbacks).run();
239+
rustc_driver::run_compiler(&args, &mut DefaultCallbacks);
240240
return Ok(());
241241
}
242242

@@ -295,9 +295,9 @@ pub fn main() {
295295
let clippy_enabled = !cap_lints_allow && relevant_package && !info_query;
296296
if clippy_enabled {
297297
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 });
299299
} else {
300-
rustc_driver::RunCompiler::new(&args, &mut RustcCallbacks { clippy_args_var }).run();
300+
rustc_driver::run_compiler(&args, &mut RustcCallbacks { clippy_args_var });
301301
}
302302
Ok(())
303303
}))

src/tools/miri/src/bin/miri.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ fn run_compiler_and_exit(
374374
) -> ! {
375375
// Invoke compiler, and handle return code.
376376
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);
378378
Ok(())
379379
});
380380
std::process::exit(exit_code)

tests/ui-fulldeps/compiler-calls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn main() {
2525
let mut count = 1;
2626
let args = vec!["compiler-calls".to_string(), "foo.rs".to_string()];
2727
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 });
2929
Ok(())
3030
})
3131
.ok();

tests/ui-fulldeps/obtain-borrowck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn main() {
4747
rustc_args.push("-Zpolonius".to_owned());
4848
let mut callbacks = CompilerCalls::default();
4949
// 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);
5151
Ok(())
5252
});
5353
std::process::exit(exit_code);

0 commit comments

Comments
 (0)