Skip to content

Commit 6f674fa

Browse files
committed
Add additional motivation
1 parent 1a2c1a3 commit 6f674fa

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

text/3698-declarative-derive-macros.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ syntax as a proc macro.
3131
The derive feature of the crate has [various uses in the
3232
ecosystem](https://github.com/search?q=macro_rules_attribute%3A%3Aderive&type=code).
3333

34+
`derive` macros have a standard syntax that Rust users have come to expect for
35+
defining traits; this motivates providing users a way to invoke that mechanism
36+
for declarative macros. An attribute or a `macro_name!` invocation could serve
37+
the same purpose, but that would be less evocative than `derive(Trait)` for
38+
the purposes of making the purpose of the macro clear, and would additionally
39+
give the macro more power to rewrite the underlying definition. Derive macros
40+
simplify tools like rust-analyzer, which can know that a derive macro will
41+
never change the underlying item definition.
42+
3443
# Guide-level explanation
3544
[guide-level-explanation]: #guide-level-explanation
3645

0 commit comments

Comments
 (0)