Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upproc_macro_derive(attributes(path::to)) both does and doesn't work #55168
Comments
This comment has been minimized.
This comment has been minimized.
|
This may be an accidental regression from #50030, similarly to #53489. This cannot work without significant work and introducing an entirely new entity into name resolution ("derive helper modules" or something), so |
Havvy
added
A-attributes
A-macros
C-bug
labels
Oct 18, 2018
This comment has been minimized.
This comment has been minimized.
I don't think you can do this, as these work for attributes within the type on stable 1.32: use repro_derive::Example;
#[derive(Example)]
#[example::attr] // Does not work
struct Demo {
#[example::attr] // Works
field: i32,
}
fn main() {}extern crate proc_macro;
use proc_macro::TokenStream;
#[proc_macro_derive(Example, attributes(example::attr))]
pub fn example_derive(_input: TokenStream) -> TokenStream {
TokenStream::new()
} |
This comment has been minimized.
This comment has been minimized.
|
Oh god. Self-assigning, I should be able to fix it this weekend. |
petrochenkov
self-assigned this
Feb 27, 2019
petrochenkov
added
the
regression-from-stable-to-stable
label
Feb 27, 2019
This comment has been minimized.
This comment has been minimized.
|
Is there any suggested way to have my desired syntax of #[derive(Example)]
#[example::attr]
struct Demo {
#[example::attr]
field: i32,
} |
This comment has been minimized.
This comment has been minimized.
|
@shepmaster Actually, the derive macro itself could be able to introduce "tool modules" into scope (like |
This comment has been minimized.
This comment has been minimized.
|
@petrochenkov Is there a reason we cannot let From a user facing perspective at least, @shepmaster's #55168 (comment) example seems reasonable and "expected". |
petrochenkov
referenced this issue
Mar 3, 2019
Merged
Do not accidentally treat multi-segment meta-items as single-segment #58899
This comment has been minimized.
This comment has been minimized.
|
Fixed in #58899
I'd prefer to see crater results first. |
CAD97 commentedOct 18, 2018
I would expect either for this to work or for
#[proc_macro_derive(attributes(..))]to reject a path and only accept an ident, as specifying a path here doesn't work.