@@ -6,26 +6,21 @@ extern crate rustc;
66extern crate rustc_codegen_utils;
77extern crate rustc_driver;
88extern crate rustc_errors;
9+ extern crate rustc_interface;
910extern crate rustc_metadata;
1011extern crate syntax;
1112
12- use rustc:: session:: config:: { self , ErrorOutputType , Input } ;
13- use rustc:: session:: { early_error, Session } ;
14- use rustc_codegen_utils:: codegen_backend:: CodegenBackend ;
15- use rustc_driver:: driver:: CompileController ;
16- use rustc_driver:: {
17- enable_save_analysis, run_compiler, Compilation , CompilerCalls , RustcDefaultCalls ,
18- } ;
19- use rustc_metadata:: cstore:: CStore ;
20- use syntax:: ast;
13+ use rustc:: session:: config:: ErrorOutputType ;
14+ use rustc:: session:: early_error;
15+ use rustc_driver:: { run_compiler, Callbacks } ;
16+ use rustc_interface:: interface;
2117
2218use std:: env;
23- use std:: path:: PathBuf ;
2419use std:: process;
2520
2621pub fn run ( ) {
2722 drop ( env_logger:: init ( ) ) ;
28- let result = rustc_driver:: run ( || {
23+ let result = rustc_driver:: report_ices_to_stderr_if_any ( || {
2924 let args = env:: args_os ( )
3025 . enumerate ( )
3126 . map ( |( i, arg) | {
@@ -38,64 +33,17 @@ pub fn run() {
3833 } )
3934 . collect :: < Vec < _ > > ( ) ;
4035
41- run_compiler ( & args, Box :: new ( ShimCalls ) , None , None )
42- } ) ;
43- process:: exit ( result as i32 ) ;
36+ run_compiler ( & args, & mut ShimCalls , None , None )
37+ } )
38+ . and_then ( |result| result) ;
39+ process:: exit ( result. is_err ( ) as i32 ) ;
4440}
4541
4642struct ShimCalls ;
4743
48- impl < ' a > CompilerCalls < ' a > for ShimCalls {
49- fn early_callback (
50- & mut self ,
51- a : & getopts:: Matches ,
52- b : & config:: Options ,
53- c : & ast:: CrateConfig ,
54- d : & rustc_errors:: registry:: Registry ,
55- e : ErrorOutputType ,
56- ) -> Compilation {
57- RustcDefaultCalls . early_callback ( a, b, c, d, e)
58- }
59-
60- fn late_callback (
61- & mut self ,
62- a : & CodegenBackend ,
63- b : & getopts:: Matches ,
64- c : & Session ,
65- d : & CStore ,
66- e : & Input ,
67- f : & Option < PathBuf > ,
68- g : & Option < PathBuf > ,
69- ) -> Compilation {
70- RustcDefaultCalls . late_callback ( a, b, c, d, e, f, g)
71- }
72-
73- fn some_input ( & mut self , a : Input , b : Option < PathBuf > ) -> ( Input , Option < PathBuf > ) {
74- RustcDefaultCalls . some_input ( a, b)
75- }
76-
77- fn no_input (
78- & mut self ,
79- a : & getopts:: Matches ,
80- b : & config:: Options ,
81- c : & ast:: CrateConfig ,
82- d : & Option < PathBuf > ,
83- e : & Option < PathBuf > ,
84- f : & rustc_errors:: registry:: Registry ,
85- ) -> Option < ( Input , Option < PathBuf > ) > {
86- RustcDefaultCalls . no_input ( a, b, c, d, e, f)
87- }
88-
89- fn build_controller (
90- self : Box < Self > ,
91- a : & Session ,
92- b : & getopts:: Matches ,
93- ) -> CompileController < ' a > {
94- let mut result = Box :: new ( RustcDefaultCalls ) . build_controller ( a, b) ;
95-
96- result. continue_parse_after_error = true ;
97- enable_save_analysis ( & mut result) ;
98-
99- result
44+ impl Callbacks for ShimCalls {
45+ fn config ( & mut self , config : & mut interface:: Config ) {
46+ config. opts . debugging_opts . continue_parse_after_error = true ;
47+ config. opts . debugging_opts . save_analysis = true ;
10048 }
10149}
0 commit comments