From 0ea66f35a95e3662498881398298dcc553294d5a Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Fri, 8 Apr 2016 22:47:55 +0000 Subject: [PATCH] Avoid gated feature checking unconfigured items --- src/librustc_driver/driver.rs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 67c52bb6c36d..b6e7080f16c7 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -625,21 +625,6 @@ pub fn phase_2_configure_and_expand(sess: &Session, ret }); - // Needs to go *after* expansion to be able to check the results - // of macro expansion. This runs before #[cfg] to try to catch as - // much as possible (e.g. help the programmer avoid platform - // specific differences) - time(time_passes, "complete gated feature checking 1", || { - sess.track_errors(|| { - let features = syntax::feature_gate::check_crate(sess.codemap(), - &sess.parse_sess.span_diagnostic, - &krate, - &attributes, - sess.opts.unstable_features); - *sess.features.borrow_mut() = features; - }) - })?; - // JBC: make CFG processing part of expansion to avoid this problem: // strip again, in case expansion added anything with a #[cfg]. @@ -662,6 +647,19 @@ pub fn phase_2_configure_and_expand(sess: &Session, krate })?; + // Needs to go *after* expansion to be able to check the results + // of macro expansion. + time(time_passes, "complete gated feature checking 1", || { + sess.track_errors(|| { + let features = syntax::feature_gate::check_crate(sess.codemap(), + &sess.parse_sess.span_diagnostic, + &krate, + &attributes, + sess.opts.unstable_features); + *sess.features.borrow_mut() = features; + }) + })?; + krate = time(time_passes, "maybe building test harness", || { syntax::test::modify_for_testing(&sess.parse_sess, &sess.opts.cfg, krate, sess.diagnostic()) });