diff options
| author | bors <bors@rust-lang.org> | 2015-01-01 15:51:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-01-01 15:51:08 +0000 |
| commit | 39d74026663597a8d4ad0ab04e6d117bf9fd6ad4 (patch) | |
| tree | 0d444a5841d9d9b6d01c2c47c50e378ff6e9ea5f /src/librustc_driver | |
| parent | c594959cdff07b5545747809bb045bfa2868ebcc (diff) | |
| parent | 41da99dff417eadf8f296a93529d9810f79e1d1b (diff) | |
| download | rust-39d74026663597a8d4ad0ab04e6d117bf9fd6ad4.tar.gz rust-39d74026663597a8d4ad0ab04e6d117bf9fd6ad4.zip | |
auto merge of #20190 : cmr/rust/gate-macro-args, r=alexcrichton
Uses the same approach as https://github.com/rust-lang/rust/pull/17286 (and subsequent changes making it more correct), where the visitor will skip any pieces of the AST that are from "foreign code", where the spans don't line up, indicating that that piece of code is due to a macro expansion. If this breaks your code, read the error message to determine which feature gate you should add to your crate. Closes #18102 [breaking-change]
Diffstat (limited to 'src/librustc_driver')
| -rw-r--r-- | src/librustc_driver/driver.rs | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 9084e745bfb..91902b90673 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -178,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); }); @@ -205,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)); @@ -289,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]. |
