diff options
| author | bors <bors@rust-lang.org> | 2018-09-17 18:13:26 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-09-17 18:13:26 +0000 |
| commit | 354a29a5f1feb55bd799f874786e013beddfd645 (patch) | |
| tree | 5d8b8dc7b289b1af380df5fdbe86751fe9f42693 /src/libsyntax_ext | |
| parent | 186fe091434b4c20c160b8098a56bb6a841bf6b1 (diff) | |
| parent | 229df02c0b85c33465d7191a6e085e964e56c1c9 (diff) | |
| download | rust-354a29a5f1feb55bd799f874786e013beddfd645.tar.gz rust-354a29a5f1feb55bd799f874786e013beddfd645.zip | |
Auto merge of #54277 - petrochenkov:afterder, r=alexcrichton
Temporarily prohibit proc macro attributes placed after derives ... and also proc macro attributes used together with `#[test]`/`#[bench]`. Addresses item 6 from https://github.com/rust-lang/rust/pull/50911#issuecomment-411605393. The end goal is straightforward predictable left-to-right expansion order for attributes. Right now derives are expanded last regardless of their relative ordering with macro attributes and right now it's simpler to temporarily prohibit macro attributes placed after derives than changing the expansion order. I'm not sure whether the new beta is already released or not, but if it's released, then this patch needs to be backported, so the solution needs to be minimal. How to fix broken code (derives): - Move macro attributes above derives. This won't change expansion order, they are expanded before derives anyway. Using attribute macros on same items with `#[test]` and `#[bench]` is prohibited for similar expansion order reasons, but this one is going to be reverted much sooner than restrictions on derives. How to fix broken code (test/bench): - Enable `#![feature(plugin)]` (don't ask why). r? @ghost
Diffstat (limited to 'src/libsyntax_ext')
| -rw-r--r-- | src/libsyntax_ext/test.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libsyntax_ext/test.rs b/src/libsyntax_ext/test.rs index be3485cfa7c..8ddfb1d9cba 100644 --- a/src/libsyntax_ext/test.rs +++ b/src/libsyntax_ext/test.rs @@ -49,7 +49,7 @@ pub fn expand_test_or_bench( // If we're not in test configuration, remove the annotated item if !cx.ecfg.should_test { return vec![]; } - let item = + let mut item = if let Annotatable::Item(i) = item { i } else { cx.parse_sess.span_diagnostic.span_fatal(item.span(), @@ -192,6 +192,12 @@ pub fn expand_test_or_bench( debug!("Synthetic test item:\n{}\n", pprust::item_to_string(&test_const)); + // Temporarily add another marker to the original item for error reporting + let marker2 = cx.attribute( + attr_sp, cx.meta_word(attr_sp, Symbol::intern("rustc_test_marker2")) + ); + item.attrs.push(marker2); + vec