forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clone entire
TokenCursor
when collecting tokens
Reverts PR rust-lang#80830 Fixes taiki-e/pin-project#312 We can have an arbitrary number of `None`-delimited group frames pushed on the stack due to proc-macro invocations, which can legally be exited. Attempting to account for this would add a lot of complexity for a tiny performance gain, so let's just use the original strategy.
- Loading branch information
Showing
3 changed files
with
41 additions
and
9 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
23 changes: 23 additions & 0 deletions
23
src/test/ui/proc-macro/auxiliary/nonterminal-recollect-attr.rs
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,23 @@ | ||
// force-host | ||
// no-prefer-dynamic | ||
|
||
#![crate_type = "proc-macro"] | ||
#![feature(proc_macro_quote)] | ||
|
||
extern crate proc_macro; | ||
use proc_macro::{TokenStream, quote}; | ||
|
||
#[proc_macro_attribute] | ||
pub fn first_attr(_: TokenStream, input: TokenStream) -> TokenStream { | ||
let recollected: TokenStream = input.into_iter().collect(); | ||
quote! { | ||
#[second_attr] | ||
$recollected | ||
} | ||
} | ||
|
||
#[proc_macro_attribute] | ||
pub fn second_attr(_: TokenStream, input: TokenStream) -> TokenStream { | ||
let _recollected: TokenStream = input.into_iter().collect(); | ||
TokenStream::new() | ||
} |
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,17 @@ | ||
// check-pass | ||
// aux-build:nonterminal-recollect-attr.rs | ||
|
||
extern crate nonterminal_recollect_attr; | ||
use nonterminal_recollect_attr::*; | ||
|
||
macro_rules! my_macro { | ||
($v:ident) => { | ||
#[first_attr] | ||
$v struct Foo { | ||
field: u8 | ||
} | ||
} | ||
} | ||
|
||
my_macro!(pub); | ||
fn main() {} |