From 04ecee158c2c56f4a6d81ad17ac3547848ec1e4c Mon Sep 17 00:00:00 2001 From: Austin Bonander Date: Sun, 15 Jan 2017 22:58:17 -0800 Subject: [PATCH] Move "completed feature gate checking" pass to after "name resolution" pass so proc-macro-attribute feature gate check can use resolve --- src/librustc_driver/driver.rs | 22 +++++++++---------- src/test/compile-fail/const-fn-stability.rs | 3 +++ .../compile-fail/feature-gate-no-debug.rs | 2 ++ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index f34d1203a3d20..d8c68c340b68f 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -737,17 +737,6 @@ pub fn phase_2_configure_and_expand(sess: &Session, "checking for inline asm in case the target doesn't support it", || no_asm::check_crate(sess, &krate)); - // Needs to go *after* expansion to be able to check the results of macro expansion. - time(time_passes, "complete gated feature checking", || { - sess.track_errors(|| { - syntax::feature_gate::check_crate(&krate, - &sess.parse_sess, - &sess.features.borrow(), - &attributes, - sess.opts.unstable_features); - }) - })?; - time(sess.time_passes(), "early lint checks", || lint::check_ast_crate(sess, &krate)); @@ -765,6 +754,17 @@ pub fn phase_2_configure_and_expand(sess: &Session, Ok(()) })?; + // Needs to go *after* expansion to be able to check the results of macro expansion. + time(time_passes, "complete gated feature checking", || { + sess.track_errors(|| { + syntax::feature_gate::check_crate(&krate, + &sess.parse_sess, + &sess.features.borrow(), + &attributes, + sess.opts.unstable_features); + }) + })?; + // Lower ast -> hir. let hir_forest = time(sess.time_passes(), "lowering ast -> hir", || { let hir_crate = lower_crate(sess, &krate, &mut resolver); diff --git a/src/test/compile-fail/const-fn-stability.rs b/src/test/compile-fail/const-fn-stability.rs index 436244525e1c2..d093364497a92 100644 --- a/src/test/compile-fail/const-fn-stability.rs +++ b/src/test/compile-fail/const-fn-stability.rs @@ -16,7 +16,9 @@ const fn foo() -> usize { 0 } //~ ERROR const fn is unstable trait Foo { const fn foo() -> u32; //~ ERROR const fn is unstable + //~| ERROR trait fns cannot be declared const const fn bar() -> u32 { 0 } //~ ERROR const fn is unstable + //~| ERROR trait fns cannot be declared const } impl Foo { @@ -25,6 +27,7 @@ impl Foo { impl Foo for u32 { const fn foo() -> u32 { 0 } //~ ERROR const fn is unstable + //~| ERROR trait fns cannot be declared const } static FOO: usize = foo(); diff --git a/src/test/compile-fail/feature-gate-no-debug.rs b/src/test/compile-fail/feature-gate-no-debug.rs index e185056026c3c..9815db6550d66 100644 --- a/src/test/compile-fail/feature-gate-no-debug.rs +++ b/src/test/compile-fail/feature-gate-no-debug.rs @@ -8,5 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![allow(deprecated)] + #[no_debug] //~ ERROR the `#[no_debug]` attribute is fn main() {}