-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When snapshoting a TokenCursor, preserve the top frame of the stack #81352
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() {} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not actually sure, does it matter what exactly we put into the stack here, or putting any dummy frame making
stack.pop()
work without panic would be enough?I'm asking because
first()
is not the top of the stack, it's the bottom, but things still seem to work.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's a good point. I'll need to take a closer look at how this is working.