99#![ feature( rustc_private) ]
1010#![ feature( assert_matches) ]
1111
12- extern crate rustc_driver;
1312extern crate rustc_hir;
14- extern crate rustc_interface;
1513extern crate rustc_middle;
16- extern crate rustc_session;
1714extern crate rustc_smir;
1815
19- use rustc_driver:: { Callbacks , Compilation , RunCompiler } ;
2016use rustc_hir:: def:: DefKind ;
21- use rustc_interface:: { interface, Queries } ;
2217use rustc_middle:: ty:: TyCtxt ;
23- use rustc_session:: EarlyErrorHandler ;
2418use rustc_smir:: { rustc_internal, stable_mir} ;
2519use std:: assert_matches:: assert_matches;
2620use std:: io:: Write ;
@@ -130,8 +124,8 @@ fn get_item<'a>(
130124
131125/// This test will generate and analyze a dummy crate using the stable mir.
132126/// 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.
135129fn main ( ) {
136130 let path = "input.rs" ;
137131 generate_input ( & path) . unwrap ( ) ;
@@ -142,29 +136,7 @@ fn main() {
142136 CRATE_NAME . to_string( ) ,
143137 path. to_string( ) ,
144138 ] ;
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 ( ) ;
168140}
169141
170142fn generate_input ( path : & str ) -> std:: io:: Result < ( ) > {
0 commit comments