-> Option<ast::Crate> {
let time_passes = sess.time_passes();
- *sess.crate_types.borrow_mut() =
- collect_crate_types(sess, &krate.attrs);
- *sess.crate_metadata.borrow_mut() =
- collect_crate_metadata(sess, &krate.attrs);
-
- time(time_passes, "recursion limit", (), |_| {
- middle::recursion_limit::update_recursion_limit(sess, &krate);
- });
-
- // strip before expansion to allow macros to depend on
- // configuration variables e.g/ in
+ // strip before anything else because crate metadata may use #[cfg_attr]
+ // and so macros can depend on configuration variables, such as
//
// #[macro_use] #[cfg(foo)]
// mod bar { macro_rules! baz!(() => {{}}) }
krate = time(time_passes, "configuration 1", krate, |krate|
syntax::config::strip_unconfigured_items(sess.diagnostic(), krate));
+ *sess.crate_types.borrow_mut() =
+ collect_crate_types(sess, &krate.attrs);
+ *sess.crate_metadata.borrow_mut() =
+ collect_crate_metadata(sess, &krate.attrs);
+
+ time(time_passes, "recursion limit", (), |_| {
+ middle::recursion_limit::update_recursion_limit(sess, &krate);
+ });
+
time(time_passes, "gated macro checking", (), |_| {
let features =
syntax::feature_gate::check_crate_macros(sess.codemap(),
--- /dev/null
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// no-prefer-dynamic
+// compile-flags: --cfg foo
+
+#![cfg_attr(foo, crate_type="lib")]
+
+pub fn foo() {}
--- /dev/null
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// aux-build:crate-attributes-using-cfg_attr.rs
+
+extern crate crate_attributes_using_cfg_attr;
+
+pub fn main() {}