about summary refs log tree commit diff
path: root/src/doc/rustc-dev-guide/examples/rustc-driver-example.rs
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2025-01-22 14:00:36 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2025-01-23 09:38:58 +0000
commit974db1a6e444e2b053f49a8d3242db335669acef (patch)
tree77c12157528b8c9b4ae0115dc090593da64a6bcb /src/doc/rustc-dev-guide/examples/rustc-driver-example.rs
parent4f9b9a43c1c64781a19edeb58b4022df9ac0aafb (diff)
downloadrust-974db1a6e444e2b053f49a8d3242db335669acef.tar.gz
rust-974db1a6e444e2b053f49a8d3242db335669acef.zip
Remove set_make_codegen_backend and set_file_loader
They can both be set inside the config callback too.
Diffstat (limited to 'src/doc/rustc-dev-guide/examples/rustc-driver-example.rs')
-rw-r--r--src/doc/rustc-dev-guide/examples/rustc-driver-example.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/doc/rustc-dev-guide/examples/rustc-driver-example.rs b/src/doc/rustc-dev-guide/examples/rustc-driver-example.rs
index 576bbcea965..b77172841da 100644
--- a/src/doc/rustc-dev-guide/examples/rustc-driver-example.rs
+++ b/src/doc/rustc-dev-guide/examples/rustc-driver-example.rs
@@ -19,7 +19,7 @@ use std::path::Path;
 use rustc_ast_pretty::pprust::item_to_string;
 use rustc_data_structures::sync::Lrc;
 use rustc_driver::{Compilation, RunCompiler};
-use rustc_interface::interface::Compiler;
+use rustc_interface::interface::{Compiler, Config};
 use rustc_middle::ty::TyCtxt;
 
 struct MyFileLoader;
@@ -51,6 +51,10 @@ fn main() {
 struct MyCallbacks;
 
 impl rustc_driver::Callbacks for MyCallbacks {
+    fn config(&mut self, config: &mut Config) {
+        config.file_loader = Some(Box::new(MyFileLoader));
+    }
+
     fn after_crate_root_parsing(
         &mut self,
         _compiler: &Compiler,
@@ -83,10 +87,5 @@ impl rustc_driver::Callbacks for MyCallbacks {
 }
 
 fn main() {
-    match RunCompiler::new(&["main.rs".to_string()], &mut MyCallbacks) {
-        mut compiler => {
-            compiler.set_file_loader(Some(Box::new(MyFileLoader)));
-            compiler.run();
-        }
-    }
+    RunCompiler::new(&["main.rs".to_string()], &mut MyCallbacks).run();
 }