File tree 2 files changed +12
-14
lines changed
2 files changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ use std::path::Path;
19
19
use rustc_ast_pretty:: pprust:: item_to_string;
20
20
use rustc_data_structures:: sync:: Lrc ;
21
21
use rustc_driver:: { Compilation , RunCompiler } ;
22
- use rustc_interface:: interface:: Compiler ;
22
+ use rustc_interface:: interface:: { Compiler , Config } ;
23
23
use rustc_middle:: ty:: TyCtxt ;
24
24
25
25
struct MyFileLoader ;
@@ -51,6 +51,10 @@ fn main() {
51
51
struct MyCallbacks ;
52
52
53
53
impl rustc_driver:: Callbacks for MyCallbacks {
54
+ fn config ( & mut self , config : & mut Config ) {
55
+ config. file_loader = Some ( Box :: new ( MyFileLoader ) ) ;
56
+ }
57
+
54
58
fn after_crate_root_parsing (
55
59
& mut self ,
56
60
_compiler : & Compiler ,
@@ -83,10 +87,5 @@ impl rustc_driver::Callbacks for MyCallbacks {
83
87
}
84
88
85
89
fn main ( ) {
86
- match RunCompiler :: new ( & [ "main.rs" . to_string ( ) ] , & mut MyCallbacks ) {
87
- mut compiler => {
88
- compiler. set_file_loader ( Some ( Box :: new ( MyFileLoader ) ) ) ;
89
- compiler. run ( ) ;
90
- }
91
- }
90
+ RunCompiler :: new ( & [ "main.rs" . to_string ( ) ] , & mut MyCallbacks ) . run ( ) ;
92
91
}
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ use std::path::Path;
19
19
use rustc_ast_pretty:: pprust:: item_to_string;
20
20
use rustc_data_structures:: sync:: Lrc ;
21
21
use rustc_driver:: { Compilation , RunCompiler } ;
22
- use rustc_interface:: interface:: Compiler ;
22
+ use rustc_interface:: interface:: { Compiler , Config } ;
23
23
use rustc_middle:: ty:: TyCtxt ;
24
24
25
25
struct MyFileLoader ;
@@ -51,6 +51,10 @@ fn main() {
51
51
struct MyCallbacks ;
52
52
53
53
impl rustc_driver:: Callbacks for MyCallbacks {
54
+ fn config ( & mut self , config : & mut Config ) {
55
+ config. file_loader = Some ( Box :: new ( MyFileLoader ) ) ;
56
+ }
57
+
54
58
fn after_crate_root_parsing (
55
59
& mut self ,
56
60
_compiler : & Compiler ,
@@ -90,10 +94,5 @@ impl rustc_driver::Callbacks for MyCallbacks {
90
94
}
91
95
92
96
fn main ( ) {
93
- match RunCompiler :: new ( & [ "main.rs" . to_string ( ) ] , & mut MyCallbacks ) {
94
- mut compiler => {
95
- compiler. set_file_loader ( Some ( Box :: new ( MyFileLoader ) ) ) ;
96
- compiler. run ( ) ;
97
- }
98
- }
97
+ RunCompiler :: new ( & [ "main.rs" . to_string ( ) ] , & mut MyCallbacks ) . run ( ) ;
99
98
}
You can’t perform that action at this time.
0 commit comments