What's the story with rust attributes?

I'm trying to find a good description of the story with (history behind) the development process for rust attributes. How do they become conceived, when is it desirable to consider making one, and finally how to create them?

It seems quite clear that they are only developed at a level that would be similar to modifying the rust compiler code and would therefore be something, even if you had the necessary skills (tall order) you would be out of your mind to undertake the project to develop one; Unless, say, you expected to lobby your work to the community and obtained confidence the work to eventually might be adopted by the rust community in general.

Short of that, I'm still curious about the many invaluable rust crates out there that have them, and what sort of effort did they do to accompish their goal. E.g. tokio, serde, structopt, actix, axum. Are all these crates developed in part by authors of rust itself?

I expect that the history is complicated, so anyone who can point me to a good doc on it or any light on the topic I would appreciate it.

Those are attribute macros. You write them using the proc_macro library. They can be distributed through crates.io, just like any normal library, and don't need to be baked into the compiler.


Thanks for the information. I kept looking in the indexes in the Rust books under attributes, I had not taken the plunge on writing macros yet so must have overlooked that part. Something I really need to do just to get a feel how these things are all put together.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.