Commit 3fc30d8
committed
Auto merge of rust-lang#66070 - petrochenkov:regattr, r=matthewjasper
Support registering inert attributes and attribute tools using crate-level attributes
And remove `#[feature(custom_attribute)]`.
(`rustc_plugin::Registry::register_attribute` is not removed yet, I'll do it in a follow up PR.)
```rust
#![register_attr(my_attr)]
#![register_tool(my_tool)]
#[my_attr] // OK
#[my_tool::anything] // OK
fn main() {}
```
---
Some tools (`rustfmt` and `clippy`) used in tool attributes are hardcoded in the compiler.
We need some way to introduce them without hardcoding as well.
This PR introduces a way to do it with a crate level attribute.
The previous attempt to introduce them through command line (rust-lang#57921) met some resistance.
This probably needs to go through an RFC before stabilization.
However, I'd prefer to land *this* PR without an RFC to able to remove `#[feature(custom_attribute)]` and `Registry::register_attribute` while also providing a replacement.
---
`register_attr` is a direct replacement for `#![feature(custom_attribute)]` (rust-lang#29642), except it doesn't rely on implicit fallback from unresolved attributes to custom attributes (which was always hacky and is the primary reason for the removal of `custom_attribute`) and requires registering the attribute explicitly.
It's not clear whether it should go through stabilization or not.
It's quite possible that all the uses should migrate to `#![register_tool]` (rust-lang#66079) instead.
---
Details:
- The naming is `register_attr`/`register_tool` rather than some `register_attributes` (plural, no abbreviation) for consistency with already existing attributes like `cfg_attr`, or `feature`, etc.
---
Previous attempt: rust-lang#57921
cc rust-lang#44690
Tracking issues: rust-lang#66079 (`register_tool`), rust-lang#66080 (`register_attr`)
Closes rust-lang#29642File tree
33 files changed
+411
-118
lines changed- src
- librustc_plugin
- librustc_resolve
- librustc/hir
- libsyntax_pos
- libsyntax/feature_gate
- test
- ui-fulldeps
- ui
- attributes
- feature-gates
- proc-macro
- span
33 files changed
+411
-118
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | | - | |
46 | | - | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
| 332 | + | |
332 | 333 | | |
333 | | - | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
334 | 350 | | |
335 | 351 | | |
336 | 352 | | |
| |||
389 | 405 | | |
390 | 406 | | |
391 | 407 | | |
| 408 | + | |
392 | 409 | | |
393 | 410 | | |
394 | 411 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
105 | 104 | | |
106 | 105 | | |
107 | 106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
145 | | - | |
| 144 | + | |
146 | 145 | | |
147 | 146 | | |
148 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
400 | 400 | | |
401 | 401 | | |
402 | 402 | | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
403 | 411 | | |
404 | 412 | | |
405 | 413 | | |
| |||
439 | 447 | | |
440 | 448 | | |
441 | 449 | | |
442 | | - | |
443 | | - | |
| 450 | + | |
| 451 | + | |
444 | 452 | | |
445 | 453 | | |
446 | 454 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
78 | | - | |
79 | 77 | | |
80 | 78 | | |
81 | 79 | | |
| |||
102 | 100 | | |
103 | 101 | | |
104 | 102 | | |
| 103 | + | |
105 | 104 | | |
106 | 105 | | |
107 | 106 | | |
| |||
621 | 620 | | |
622 | 621 | | |
623 | 622 | | |
624 | | - | |
625 | 623 | | |
626 | 624 | | |
627 | 625 | | |
| |||
638 | 636 | | |
639 | 637 | | |
640 | 638 | | |
641 | | - | |
642 | | - | |
643 | 639 | | |
644 | 640 | | |
645 | 641 | | |
| |||
916 | 912 | | |
917 | 913 | | |
918 | 914 | | |
| 915 | + | |
| 916 | + | |
919 | 917 | | |
920 | 918 | | |
921 | 919 | | |
| |||
1138 | 1136 | | |
1139 | 1137 | | |
1140 | 1138 | | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
1141 | 1142 | | |
1142 | 1143 | | |
1143 | 1144 | | |
| |||
1207 | 1208 | | |
1208 | 1209 | | |
1209 | 1210 | | |
| 1211 | + | |
| 1212 | + | |
1210 | 1213 | | |
1211 | 1214 | | |
1212 | 1215 | | |
| |||
1484 | 1487 | | |
1485 | 1488 | | |
1486 | 1489 | | |
| 1490 | + | |
1487 | 1491 | | |
1488 | 1492 | | |
1489 | 1493 | | |
| |||
1528 | 1532 | | |
1529 | 1533 | | |
1530 | 1534 | | |
1531 | | - | |
| 1535 | + | |
1532 | 1536 | | |
1533 | 1537 | | |
1534 | 1538 | | |
1535 | 1539 | | |
| 1540 | + | |
1536 | 1541 | | |
1537 | 1542 | | |
1538 | 1543 | | |
| |||
1688 | 1693 | | |
1689 | 1694 | | |
1690 | 1695 | | |
1691 | | - | |
1692 | | - | |
1693 | | - | |
1694 | | - | |
1695 | | - | |
| 1696 | + | |
| 1697 | + | |
| 1698 | + | |
| 1699 | + | |
| 1700 | + | |
1696 | 1701 | | |
1697 | 1702 | | |
1698 | 1703 | | |
| |||
0 commit comments