about summary refs log tree commit diff
path: root/src/librustc_driver/driver.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/librustc_driver/driver.rs')
-rw-r--r--src/librustc_driver/driver.rs45
1 files changed, 28 insertions, 17 deletions
diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs
index 0ac8d6ba734..91902b90673 100644
--- a/src/librustc_driver/driver.rs
+++ b/src/librustc_driver/driver.rs
@@ -10,6 +10,7 @@
 
 use rustc::session::Session;
 use rustc::session::config::{mod, Input, OutputFilenames};
+use rustc::session::search_paths::PathKind;
 use rustc::lint;
 use rustc::metadata::creader;
 use rustc::middle::{stability, ty, reachable};
@@ -177,21 +178,6 @@ pub fn phase_2_configure_and_expand(sess: &Session,
     *sess.crate_metadata.borrow_mut() =
         collect_crate_metadata(sess, krate.attrs[]);
 
-    time(time_passes, "gated feature checking", (), |_| {
-        let (features, unknown_features) =
-            syntax::feature_gate::check_crate(&sess.parse_sess.span_diagnostic, &krate);
-
-        for uf in unknown_features.iter() {
-            sess.add_lint(lint::builtin::UNKNOWN_FEATURES,
-                          ast::CRATE_NODE_ID,
-                          *uf,
-                          "unknown feature".to_string());
-        }
-
-        sess.abort_if_errors();
-        *sess.features.borrow_mut() = features;
-    });
-
     time(time_passes, "recursion limit", (), |_| {
         middle::recursion_limit::update_recursion_limit(sess, &krate);
     });
@@ -204,6 +190,23 @@ pub fn phase_2_configure_and_expand(sess: &Session,
     //
     // baz! should not use this definition unless foo is enabled.
 
+    time(time_passes, "gated macro checking", (), |_| {
+        let (features, unknown_features) =
+            syntax::feature_gate::check_crate_macros(sess.codemap(),
+                                                     &sess.parse_sess.span_diagnostic,
+                                                     &krate);
+        for uf in unknown_features.iter() {
+            sess.add_lint(lint::builtin::UNKNOWN_FEATURES,
+                          ast::CRATE_NODE_ID,
+                          *uf,
+                          "unknown feature".to_string());
+        }
+
+        // these need to be set "early" so that expansion sees `quote` if enabled.
+        *sess.features.borrow_mut() = features;
+        sess.abort_if_errors();
+    });
+
     krate = time(time_passes, "configuration 1", krate, |krate|
                  syntax::config::strip_unconfigured_items(sess.diagnostic(), krate));
 
@@ -266,7 +269,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
             let mut _old_path = String::new();
             if cfg!(windows) {
                 _old_path = os::getenv("PATH").unwrap_or(_old_path);
-                let mut new_path = sess.host_filesearch().get_dylib_search_paths();
+                let mut new_path = sess.host_filesearch(PathKind::All).get_dylib_search_paths();
                 new_path.extend(os::split_paths(_old_path[]).into_iter());
                 os::setenv("PATH", os::join_paths(new_path[]).unwrap());
             }
@@ -288,6 +291,14 @@ pub fn phase_2_configure_and_expand(sess: &Session,
         }
     );
 
+    // Needs to go *after* expansion to be able to check the results of macro expansion.
+    time(time_passes, "complete gated feature checking", (), |_| {
+        syntax::feature_gate::check_crate(sess.codemap(),
+                                          &sess.parse_sess.span_diagnostic,
+                                          &krate);
+        sess.abort_if_errors();
+    });
+
     // JBC: make CFG processing part of expansion to avoid this problem:
 
     // strip again, in case expansion added anything with a #[cfg].
@@ -541,7 +552,7 @@ pub fn phase_6_link_output(sess: &Session,
                            trans: &trans::CrateTranslation,
                            outputs: &OutputFilenames) {
     let old_path = os::getenv("PATH").unwrap_or_else(||String::new());
-    let mut new_path = sess.host_filesearch().get_tools_search_paths();
+    let mut new_path = sess.host_filesearch(PathKind::All).get_tools_search_paths();
     new_path.extend(os::split_paths(old_path[]).into_iter());
     os::setenv("PATH", os::join_paths(new_path[]).unwrap());