@@ -6,26 +6,21 @@ extern crate rustc;
6
6
extern crate rustc_codegen_utils;
7
7
extern crate rustc_driver;
8
8
extern crate rustc_errors;
9
+ extern crate rustc_interface;
9
10
extern crate rustc_metadata;
10
11
extern crate syntax;
11
12
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;
21
17
22
18
use std:: env;
23
- use std:: path:: PathBuf ;
24
19
use std:: process;
25
20
26
21
pub fn run ( ) {
27
22
drop ( env_logger:: init ( ) ) ;
28
- let result = rustc_driver:: run ( || {
23
+ let result = rustc_driver:: report_ices_to_stderr_if_any ( || {
29
24
let args = env:: args_os ( )
30
25
. enumerate ( )
31
26
. map ( |( i, arg) | {
@@ -38,64 +33,17 @@ pub fn run() {
38
33
} )
39
34
. collect :: < Vec < _ > > ( ) ;
40
35
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 ) ;
44
40
}
45
41
46
42
struct ShimCalls ;
47
43
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 ;
100
48
}
101
49
}
0 commit comments