@@ -23,8 +23,6 @@ use rustc_metadata::cstore::CStore;
23
23
use rustc_driver:: { Compilation , CompilerCalls , RustcDefaultCalls } ;
24
24
use rustc_driver:: driver:: { CompileState , CompileController } ;
25
25
use rustc:: session:: config:: { self , Input , ErrorOutputType } ;
26
- use rustc:: hir:: { self , itemlikevisit} ;
27
- use rustc:: ty:: TyCtxt ;
28
26
use rustc_codegen_utils:: codegen_backend:: CodegenBackend ;
29
27
use syntax:: ast;
30
28
@@ -115,43 +113,12 @@ fn after_analysis<'a, 'tcx>(
115
113
116
114
let tcx = state. tcx . unwrap ( ) ;
117
115
118
- if std:: env:: args ( ) . any ( |arg| arg == "--test" ) {
119
- struct Visitor < ' a , ' tcx : ' a > {
120
- tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
121
- state : & ' a CompileState < ' a , ' tcx > ,
122
- validate : bool ,
123
- } ;
124
- impl < ' a , ' tcx : ' a , ' hir > itemlikevisit:: ItemLikeVisitor < ' hir > for Visitor < ' a , ' tcx > {
125
- fn visit_item ( & mut self , i : & ' hir hir:: Item ) {
126
- if let hir:: ItemKind :: Fn ( .., body_id) = i. node {
127
- if i. attrs . iter ( ) . any ( |attr| {
128
- attr. name ( ) == "test"
129
- } )
130
- {
131
- let did = self . tcx . hir . body_owner_def_id ( body_id) ;
132
- println ! (
133
- "running test: {}" ,
134
- self . tcx. def_path_debug_str( did) ,
135
- ) ;
136
- miri:: eval_main ( self . tcx , did, self . validate ) ;
137
- self . state . session . abort_if_errors ( ) ;
138
- }
139
- }
140
- }
141
- fn visit_trait_item ( & mut self , _trait_item : & ' hir hir:: TraitItem ) { }
142
- fn visit_impl_item ( & mut self , _impl_item : & ' hir hir:: ImplItem ) { }
143
- }
144
- state. hir_crate . unwrap ( ) . visit_all_item_likes (
145
- & mut Visitor { tcx, state, validate }
146
- ) ;
147
- } else if let Some ( ( entry_node_id, _, _) ) = * state. session . entry_fn . borrow ( ) {
148
- let entry_def_id = tcx. hir . local_def_id ( entry_node_id) ;
149
- miri:: eval_main ( tcx, entry_def_id, validate) ;
150
-
151
- state. session . abort_if_errors ( ) ;
152
- } else {
153
- println ! ( "no main function found, assuming auxiliary build" ) ;
154
- }
116
+ let ( entry_node_id, _, _) = state. session . entry_fn . borrow ( ) . expect ( "no main function found!" ) ;
117
+ let entry_def_id = tcx. hir . local_def_id ( entry_node_id) ;
118
+
119
+ miri:: eval_main ( tcx, entry_def_id, validate) ;
120
+
121
+ state. session . abort_if_errors ( ) ;
155
122
}
156
123
157
124
fn init_early_loggers ( ) {
0 commit comments