@@ -13,7 +13,6 @@ use back::link;
1313use back:: write;
1414use driver:: session:: Session ;
1515use driver:: config;
16- use front;
1716use lint;
1817use llvm:: { ContextRef , ModuleRef } ;
1918use metadata:: common:: LinkMeta ;
@@ -166,7 +165,7 @@ pub fn phase_1_parse_input(sess: &Session, cfg: ast::CrateConfig, input: &Input)
166165 }
167166
168167 if sess. show_span ( ) {
169- front :: show_span:: run ( sess, & krate) ;
168+ syntax :: show_span:: run ( sess. diagnostic ( ) , & krate) ;
170169 }
171170
172171 krate
@@ -194,11 +193,29 @@ pub fn phase_2_configure_and_expand(sess: &Session,
194193 * sess. crate_metadata . borrow_mut ( ) =
195194 collect_crate_metadata ( sess, krate. attrs . as_slice ( ) ) ;
196195
197- time ( time_passes, "gated feature checking" , ( ) , |_|
198- front:: feature_gate:: check_crate ( sess, & krate) ) ;
196+ time ( time_passes, "gated feature checking" , ( ) , |_| {
197+ let ( features, unknown_features) =
198+ syntax:: feature_gate:: check_crate ( & sess. parse_sess . span_diagnostic , & krate) ;
199+
200+ for uf in unknown_features. iter ( ) {
201+ sess. add_lint ( lint:: builtin:: UNKNOWN_FEATURES ,
202+ ast:: CRATE_NODE_ID ,
203+ * uf,
204+ "unknown feature" . to_string ( ) ) ;
205+ }
206+
207+ sess. abort_if_errors ( ) ;
208+ * sess. features . borrow_mut ( ) = features;
209+ } ) ;
210+
211+ let any_exe = sess. crate_types . borrow ( ) . iter ( ) . any ( |ty| {
212+ * ty == config:: CrateTypeExecutable
213+ } ) ;
199214
200215 krate = time ( time_passes, "crate injection" , krate, |krate|
201- front:: std_inject:: maybe_inject_crates_ref ( sess, krate) ) ;
216+ syntax:: std_inject:: maybe_inject_crates_ref ( krate,
217+ sess. opts . alt_std_name . clone ( ) ,
218+ any_exe) ) ;
202219
203220 // strip before expansion to allow macros to depend on
204221 // configuration variables e.g/ in
@@ -209,7 +226,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
209226 // baz! should not use this definition unless foo is enabled.
210227
211228 krate = time ( time_passes, "configuration 1" , krate, |krate|
212- front :: config:: strip_unconfigured_items ( krate) ) ;
229+ syntax :: config:: strip_unconfigured_items ( krate) ) ;
213230
214231 let mut addl_plugins = Some ( addl_plugins) ;
215232 let Plugins { macros, registrars }
@@ -219,7 +236,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
219236 let mut registry = Registry :: new ( & krate) ;
220237
221238 time ( time_passes, "plugin registration" , ( ) , |_| {
222- if sess. features . rustc_diagnostic_macros . get ( ) {
239+ if sess. features . borrow ( ) . rustc_diagnostic_macros {
223240 registry. register_macro ( "__diagnostic_used" ,
224241 diagnostics:: plugin:: expand_diagnostic_used) ;
225242 registry. register_macro ( "__register_diagnostic" ,
@@ -271,7 +288,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
271288 os:: setenv ( "PATH" , os:: join_paths ( new_path. as_slice ( ) ) . unwrap ( ) ) ;
272289 }
273290 let cfg = syntax:: ext:: expand:: ExpansionConfig {
274- deriving_hash_type_parameter : sess. features . default_type_params . get ( ) ,
291+ deriving_hash_type_parameter : sess. features . borrow ( ) . default_type_params ,
275292 crate_name : crate_name. to_string ( ) ,
276293 } ;
277294 let ret = syntax:: ext:: expand:: expand_crate ( & sess. parse_sess ,
@@ -290,13 +307,16 @@ pub fn phase_2_configure_and_expand(sess: &Session,
290307
291308 // strip again, in case expansion added anything with a #[cfg].
292309 krate = time ( time_passes, "configuration 2" , krate, |krate|
293- front :: config:: strip_unconfigured_items ( krate) ) ;
310+ syntax :: config:: strip_unconfigured_items ( krate) ) ;
294311
295312 krate = time ( time_passes, "maybe building test harness" , krate, |krate|
296- front:: test:: modify_for_testing ( sess, krate) ) ;
313+ syntax:: test:: modify_for_testing ( & sess. parse_sess ,
314+ & sess. opts . cfg ,
315+ krate,
316+ sess. diagnostic ( ) ) ) ;
297317
298318 krate = time ( time_passes, "prelude injection" , krate, |krate|
299- front :: std_inject:: maybe_inject_prelude ( sess , krate) ) ;
319+ syntax :: std_inject:: maybe_inject_prelude ( krate) ) ;
300320
301321 time ( time_passes, "checking that all macro invocations are gone" , & krate, |krate|
302322 syntax:: ext:: expand:: check_for_macros ( & sess. parse_sess , krate) ) ;
0 commit comments