add test to reproduce #137662 (using ty decl macro fragment in an attr) and fix it
This commit is contained in:
parent
96cfc75584
commit
41dd80aeaa
2 changed files with 29 additions and 0 deletions
|
@ -473,6 +473,15 @@ impl<'a> MetaItemListParserContext<'a> {
|
||||||
{
|
{
|
||||||
self.inside_delimiters.next();
|
self.inside_delimiters.next();
|
||||||
return Some(MetaItemOrLitParser::Lit(lit));
|
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.
|
// or a path.
|
||||||
|
|
20
tests/ui/attributes/decl_macro_ty_in_attr_macro.rs
Normal file
20
tests/ui/attributes/decl_macro_ty_in_attr_macro.rs
Normal file
|
@ -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() {}
|
Loading…
Add table
Add a link
Reference in a new issue