mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
add test to reproduce #137662 (using ty decl macro fragment in an attr) and fix it
This commit is contained in:
@@ -473,6 +473,15 @@ fn next(&mut self) -> Option<MetaItemOrLitParser<'a>> {
|
||||
{
|
||||
self.inside_delimiters.next();
|
||||
return Some(MetaItemOrLitParser::Lit(lit));
|
||||
} else if let Some(TokenTree::Delimited(.., Delimiter::Invisible(_), inner_tokens)) =
|
||||
self.inside_delimiters.peek()
|
||||
{
|
||||
self.inside_delimiters.next();
|
||||
return MetaItemListParserContext {
|
||||
inside_delimiters: inner_tokens.iter().peekable(),
|
||||
dcx: self.dcx,
|
||||
}
|
||||
.next();
|
||||
}
|
||||
|
||||
// or a path.
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// tests for #137662: using a ty or (or most other) fragment inside an attr macro wouldn't work
|
||||
// because of a missing code path. With $repr: tt it did work.
|
||||
//@ check-pass
|
||||
|
||||
macro_rules! foo {
|
||||
{
|
||||
$repr:ty
|
||||
} => {
|
||||
#[repr($repr)]
|
||||
pub enum Foo {
|
||||
Bar = 0i32,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foo! {
|
||||
i32
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
Reference in New Issue
Block a user