mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Rollup merge of #137758 - jdonszelmann:fix-137662, r=nnethercote
fix usage of ty decl macro fragments in attributes See the test case. Due to one missing code path (and also the changes in #137517), using $ty or other specific fragments as part of an attr wouldn't work. $tt used to work since it wouldn't be parsed anywhere along the way. Closes #137662
This commit is contained in:
commit
34d273b4bf
@ -473,6 +473,15 @@ impl<'a> MetaItemListParserContext<'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.
|
||||
|
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…
Reference in New Issue
Block a user