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.
When snapshoting a TokenCursor, preserve the top frame of the stack
If we start capturing on the first token of a frame, we can legally pop the frame (e.g. we can capture something like '{ my_tokens } other_tokens'. As a result, we need to snapshot the frame at the top of the current stack, rather than just using an empty stack. Fixes taiki-e/pin-project#312
- Loading branch information
Showing
3 changed files
with
45 additions
and
3 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() {} |