Commit b551aa8
committed
feature: add the "Recursively add derive" assist
This introduces a new assist that adds the derive attributes from a struct or enum to the types of
its fields, recursively. It is recursive in the sense that the fields of field types are also
considered.
The derive attributes will be copied over if the field type meets the following criteria:
* It resides within the same workspace as the "top-level" type, to avoid editing the crate registry.
* It does not already have the same derive attribute.
* It does not have a manual implementation of the trait.
The last criteria is a bit of a guess since it isn't possible to know what trait implementation(s) a
derive macro generates. If a trait has the same name as the derive macro and the top-level type
(which already has the derive attribute) implements it, it'll be used to check for manual impls.
This seems to work well in practice.1 parent f39206f commit b551aa8
File tree
6 files changed
+1210
-0
lines changed- crates
- hir/src
- ide-assists/src
- handlers
- tests
6 files changed
+1210
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
409 | 409 | | |
410 | 410 | | |
411 | 411 | | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
412 | 426 | | |
413 | 427 | | |
414 | 428 | | |
| |||
2997 | 3011 | | |
2998 | 3012 | | |
2999 | 3013 | | |
| 3014 | + | |
| 3015 | + | |
| 3016 | + | |
| 3017 | + | |
| 3018 | + | |
| 3019 | + | |
| 3020 | + | |
3000 | 3021 | | |
3001 | 3022 | | |
3002 | 3023 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
102 | 109 | | |
103 | 110 | | |
104 | 111 | | |
| |||
0 commit comments