add test to reproduce #137662 (using ty decl macro fragment in an att… · rust-lang/rust@41dd80a (original) (raw)
File tree
2 files changed
lines changed
- compiler/rustc_attr_parsing/src
2 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -473,6 +473,15 @@ impl<'a> MetaItemListParserContext<'a> { | ||
473 | 473 | { |
474 | 474 | self.inside_delimiters.next(); |
475 | 475 | return Some(MetaItemOrLitParser::Lit(lit)); |
476 | +} else if let Some(TokenTree::Delimited(.., Delimiter::Invisible(_), inner_tokens)) = | |
477 | +self.inside_delimiters.peek() | |
478 | +{ | |
479 | +self.inside_delimiters.next(); | |
480 | +return MetaItemListParserContext { | |
481 | +inside_delimiters: inner_tokens.iter().peekable(), | |
482 | +dcx: self.dcx, | |
483 | +} | |
484 | +.next(); | |
476 | 485 | } |
477 | 486 | |
478 | 487 | // or a path. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
1 | +// tests for #137662: using a ty or (or most other) fragment inside an attr macro wouldn't work | |
2 | +// because of a missing code path. With $repr: tt it did work. | |
3 | +//@ check-pass | |
4 | + | |
5 | +macro_rules! foo { | |
6 | +{ | |
7 | + $repr:ty | |
8 | +} => { | |
9 | + #[repr($repr)] | |
10 | +pub enum Foo { | |
11 | +Bar = 0i32, | |
12 | +} | |
13 | +} | |
14 | +} | |
15 | + | |
16 | +foo! { | |
17 | +i32 | |
18 | +} | |
19 | + | |
20 | +fn main() {} |