Document a few things

This commit is contained in:
bjorn3 2021-03-28 18:48:52 +02:00
parent b5e049de08
commit 2fa7175293

View File

@ -133,6 +133,7 @@ pub fn diagnostics_registry() -> Registry {
Registry::new(&rustc_error_codes::DIAGNOSTICS) Registry::new(&rustc_error_codes::DIAGNOSTICS)
} }
/// This is the primary entry point for rustc.
pub struct RunCompiler<'a, 'b> { pub struct RunCompiler<'a, 'b> {
at_args: &'a [String], at_args: &'a [String],
callbacks: &'b mut (dyn Callbacks + Send), 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 { 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 } Self { at_args, callbacks, file_loader: None, emitter: None, make_codegen_backend: None }
} }
/// Set a custom codegen backend.
///
/// Used by cg_clif. /// Used by cg_clif.
pub fn set_make_codegen_backend( pub fn set_make_codegen_backend(
&mut self, &mut self,
@ -156,11 +160,17 @@ impl<'a, 'b> RunCompiler<'a, 'b> {
self.make_codegen_backend = make_codegen_backend; self.make_codegen_backend = make_codegen_backend;
self self
} }
/// Emit diagnostics to the specified location.
///
/// Used by RLS. /// Used by RLS.
pub fn set_emitter(&mut self, emitter: Option<Box<dyn Write + Send>>) -> &mut Self { pub fn set_emitter(&mut self, emitter: Option<Box<dyn Write + Send>>) -> &mut Self {
self.emitter = emitter; self.emitter = emitter;
self self
} }
/// Load files from sources other than the file system.
///
/// Used by RLS. /// Used by RLS.
pub fn set_file_loader( pub fn set_file_loader(
&mut self, &mut self,
@ -169,6 +179,8 @@ impl<'a, 'b> RunCompiler<'a, 'b> {
self.file_loader = file_loader; self.file_loader = file_loader;
self self
} }
/// Parse args and run the compiler.
pub fn run(self) -> interface::Result<()> { pub fn run(self) -> interface::Result<()> {
run_compiler( run_compiler(
self.at_args, 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( fn run_compiler(
at_args: &[String], at_args: &[String],
callbacks: &mut (dyn Callbacks + Send), callbacks: &mut (dyn Callbacks + Send),