9
9
#![ feature( rustc_private) ]
10
10
#![ feature( assert_matches) ]
11
11
12
- extern crate rustc_driver;
13
12
extern crate rustc_hir;
14
- extern crate rustc_interface;
15
13
extern crate rustc_middle;
16
- extern crate rustc_session;
17
14
extern crate rustc_smir;
18
15
19
- use rustc_driver:: { Callbacks , Compilation , RunCompiler } ;
20
16
use rustc_hir:: def:: DefKind ;
21
- use rustc_interface:: { interface, Queries } ;
22
17
use rustc_middle:: ty:: TyCtxt ;
23
- use rustc_session:: EarlyErrorHandler ;
24
18
use rustc_smir:: { rustc_internal, stable_mir} ;
25
19
use std:: assert_matches:: assert_matches;
26
20
use std:: io:: Write ;
@@ -130,8 +124,8 @@ fn get_item<'a>(
130
124
131
125
/// This test will generate and analyze a dummy crate using the stable mir.
132
126
/// For that, it will first write the dummy crate into a file.
133
- /// It will invoke the compiler using a custom Callback implementation, which will
134
- /// invoke Stable MIR APIs after the compiler has finished its analysis .
127
+ /// Then it will create a `StableMir` using custom arguments and then
128
+ /// it will run the compiler.
135
129
fn main ( ) {
136
130
let path = "input.rs" ;
137
131
generate_input ( & path) . unwrap ( ) ;
@@ -142,29 +136,7 @@ fn main() {
142
136
CRATE_NAME . to_string( ) ,
143
137
path. to_string( ) ,
144
138
] ;
145
- rustc_driver:: catch_fatal_errors ( || {
146
- RunCompiler :: new ( & args, & mut SMirCalls { } ) . run ( ) . unwrap ( ) ;
147
- } )
148
- . unwrap ( ) ;
149
- }
150
-
151
- struct SMirCalls { }
152
-
153
- impl Callbacks for SMirCalls {
154
- /// Called after analysis. Return value instructs the compiler whether to
155
- /// continue the compilation afterwards (defaults to `Compilation::Continue`)
156
- fn after_analysis < ' tcx > (
157
- & mut self ,
158
- _handler : & EarlyErrorHandler ,
159
- _compiler : & interface:: Compiler ,
160
- queries : & ' tcx Queries < ' tcx > ,
161
- ) -> Compilation {
162
- queries. global_ctxt ( ) . unwrap ( ) . enter ( |tcx| {
163
- rustc_smir:: rustc_internal:: run ( tcx, || test_stable_mir ( tcx) ) ;
164
- } ) ;
165
- // No need to keep going.
166
- Compilation :: Stop
167
- }
139
+ rustc_internal:: StableMir :: new ( args, test_stable_mir) . run ( ) ;
168
140
}
169
141
170
142
fn generate_input ( path : & str ) -> std:: io:: Result < ( ) > {
0 commit comments