-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.
Description
Issue:
#[rustfmt::skip]
mod issue {
struct SomeType<T>(std::marker::PhantomData<T>);
macro_rules! test {
($ty:ty) => {
impl<$ty,> SomeType<$ty> {}
};
}
// Works fine
impl<T,> SomeType<T> {}
// error: expected one of `>` or `as`, found `,`
// --> src\lib.rs:7:21
// |
// 7 | impl<$ty,> SomeType<$ty> {}
// | ^ expected one of `>` or `as`
// ...
// 12 | test!(T);
// | -------- in this macro invocation
test!(T);
macro_rules! test2 {
($ty:ty) => {
impl<$ty> SomeType<$ty> {}
};
}
// Works fine
impl<T> SomeType<T> {}
// error: expected `::`, found `SomeType`
// --> src\lib.rs:17:23
// |
// 17 | impl<$ty> SomeType<$ty> {}
// | ^^^^^^^^ expected `::`
// ...
// 22 | test2!(T);
// | --------- in this macro invocation
test2!(T);
}The macro should behave exactly like its manual expansion would; I've inlined the reported problems into the code.
Meta
The error happens in both stable and nightly toolchains, on linux and windows
rustc --version --verbose:
rustc 1.82.0 (f6e511eec 2024-10-15)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: x86_64-pc-windows-msvc
release: 1.82.0
LLVM version: 19.1.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.