diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs index 6dd29e795932..94d962a43738 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -133,6 +133,7 @@ pub fn diagnostics_registry() -> Registry { Registry::new(&rustc_error_codes::DIAGNOSTICS) } +/// This is the primary entry point for rustc. pub struct RunCompiler<'a, 'b> { at_args: &'a [String], callbacks: &'b mut (dyn Callbacks + Send), @@ -146,6 +147,9 @@ impl<'a, 'b> RunCompiler<'a, 'b> { pub fn new(at_args: &'a [String], callbacks: &'b mut (dyn Callbacks + Send)) -> Self { Self { at_args, callbacks, file_loader: None, emitter: None, make_codegen_backend: None } } + + /// Set a custom codegen backend. + /// /// Used by cg_clif. pub fn set_make_codegen_backend( &mut self, @@ -156,11 +160,17 @@ impl<'a, 'b> RunCompiler<'a, 'b> { self.make_codegen_backend = make_codegen_backend; self } + + /// Emit diagnostics to the specified location. + /// /// Used by RLS. pub fn set_emitter(&mut self, emitter: Option>) -> &mut Self { self.emitter = emitter; self } + + /// Load files from sources other than the file system. + /// /// Used by RLS. pub fn set_file_loader( &mut self, @@ -169,6 +179,8 @@ impl<'a, 'b> RunCompiler<'a, 'b> { self.file_loader = file_loader; self } + + /// Parse args and run the compiler. pub fn run(self) -> interface::Result<()> { run_compiler( self.at_args, @@ -179,8 +191,6 @@ impl<'a, 'b> RunCompiler<'a, 'b> { ) } } -// Parse args and run the compiler. This is the primary entry point for rustc. -// The FileLoader provides a way to load files from sources other than the file system. fn run_compiler( at_args: &[String], callbacks: &mut (dyn Callbacks + Send),