Skip to content

Commit

Permalink
Move "completed feature gate checking" pass to after "name resolution…
Browse files Browse the repository at this point in the history
…" pass so proc-macro-attribute feature gate check can use resolve
  • Loading branch information
abonander committed Jan 17, 2017
1 parent 6843961 commit 04ecee1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,17 +737,6 @@ pub fn phase_2_configure_and_expand<F>(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));
Expand All @@ -765,6 +754,17 @@ pub fn phase_2_configure_and_expand<F>(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);
Expand Down
3 changes: 3 additions & 0 deletions src/test/compile-fail/const-fn-stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/feature-gate-no-debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

0 comments on commit 04ecee1

Please sign in to comment.