-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 #50911 (comment). 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
- Loading branch information
Showing
10 changed files
with
160 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// aux-build:attr_proc_macro.rs | ||
// compile-flags:--test | ||
|
||
#![feature(test)] | ||
|
||
extern crate test; | ||
extern crate attr_proc_macro; | ||
use attr_proc_macro::*; | ||
|
||
#[attr_proc_macro] // OK | ||
#[derive(Clone)] | ||
struct Before; | ||
|
||
#[derive(Clone)] | ||
#[attr_proc_macro] //~ ERROR macro attributes must be placed before `#[derive]` | ||
struct After; | ||
|
||
#[attr_proc_macro] //~ ERROR macro attributes cannot be used together with `#[test]` or `#[bench]` | ||
#[test] | ||
fn test_before() {} | ||
|
||
#[test] | ||
#[attr_proc_macro] //~ ERROR macro attributes cannot be used together with `#[test]` or `#[bench]` | ||
fn test_after() {} | ||
|
||
#[attr_proc_macro] //~ ERROR macro attributes cannot be used together with `#[test]` or `#[bench]` | ||
#[bench] | ||
fn bench_before(b: &mut test::Bencher) {} | ||
|
||
#[bench] | ||
#[attr_proc_macro] //~ ERROR macro attributes cannot be used together with `#[test]` or `#[bench]` | ||
fn bench_after(b: &mut test::Bencher) {} |
Oops, something went wrong.