forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The special case was failing to handle invisible delimiters on one path. Fixes rust-lang#128895.
- Loading branch information
1 parent
fac7753
commit 46b4c5a
Showing
3 changed files
with
64 additions
and
4 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
44 changes: 44 additions & 0 deletions
44
tests/ui/proc-macro/auxiliary/parse-invis-delim-issue-128895.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,44 @@ | ||
//@ force-host | ||
//@ no-prefer-dynamic | ||
|
||
#![crate_type = "proc-macro"] | ||
|
||
extern crate proc_macro; | ||
|
||
use proc_macro::*; | ||
|
||
// This proc macro ignores its input and returns this token stream | ||
// | ||
// impl <«A1»: Comparable> Comparable for («A1»,) {} | ||
// | ||
// where `«`/`»` are invisible delimiters. This was being misparsed in bug | ||
// #128895. | ||
#[proc_macro] | ||
pub fn main(_input: TokenStream) -> TokenStream { | ||
let a1 = TokenTree::Group( | ||
Group::new( | ||
Delimiter::None, | ||
std::iter::once(TokenTree::Ident(Ident::new("A1", Span::call_site()))).collect(), | ||
) | ||
); | ||
vec![ | ||
TokenTree::Ident(Ident::new("impl", Span::call_site())), | ||
TokenTree::Punct(Punct::new('<', Spacing::Alone)), | ||
a1.clone(), | ||
TokenTree::Punct(Punct::new(':', Spacing::Alone)), | ||
TokenTree::Ident(Ident::new("Comparable", Span::call_site())), | ||
TokenTree::Punct(Punct::new('>', Spacing::Alone)), | ||
TokenTree::Ident(Ident::new("Comparable", Span::call_site())), | ||
TokenTree::Ident(Ident::new("for", Span::call_site())), | ||
TokenTree::Group( | ||
Group::new( | ||
Delimiter::Parenthesis, | ||
vec![ | ||
a1.clone(), | ||
TokenTree::Punct(Punct::new(',', Spacing::Alone)), | ||
].into_iter().collect::<TokenStream>(), | ||
) | ||
), | ||
TokenTree::Group(Group::new(Delimiter::Brace, TokenStream::new())), | ||
].into_iter().collect::<TokenStream>() | ||
} |
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,14 @@ | ||
//@ aux-build:parse-invis-delim-issue-128895.rs | ||
//@ check-pass | ||
|
||
#![no_std] // Don't load unnecessary hygiene information from std | ||
extern crate std; | ||
|
||
#[macro_use] | ||
extern crate parse_invis_delim_issue_128895; | ||
|
||
trait Comparable {} | ||
|
||
parse_invis_delim_issue_128895::main!(); | ||
|
||
fn main() {} |