rust/src/librustc_resolve
bors 3fc30d884a Auto merge of #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 (https://github.com/rust-lang/rust/pull/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)]` (https://github.com/rust-lang/rust/issues/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]` (https://github.com/rust-lang/rust/issues/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: https://github.com/rust-lang/rust/pull/57921
cc https://github.com/rust-lang/rust/issues/44690
Tracking issues: #66079 (`register_tool`), #66080 (`register_attr`)
Closes https://github.com/rust-lang/rust/issues/29642
2019-11-10 15:53:35 +00:00
..
late Auto merge of #65421 - estebank:variants, r=petrochenkov 2019-10-28 13:41:13 +00:00
build_reduced_graph.rs Auto merge of #66070 - petrochenkov:regattr, r=matthewjasper 2019-11-10 15:53:35 +00:00
Cargo.toml bump smallvec to 1.0 2019-11-04 15:59:09 +01:00
check_unused.rs use American spelling for pluralize! 2019-11-05 15:10:24 -05:00
diagnostics.rs Support registering attributes and attribute tools using crate-level attributes 2019-11-09 17:50:51 +03:00
error_codes.rs Add long error explanation for E0578 2019-10-31 14:27:16 +01:00
late.rs Rollup merge of #66188 - Centril:fnsig, r=davidtwco 2019-11-08 16:50:41 +01:00
lib.rs Auto merge of #66070 - petrochenkov:regattr, r=matthewjasper 2019-11-10 15:53:35 +00:00
macros.rs Auto merge of #66070 - petrochenkov:regattr, r=matthewjasper 2019-11-10 15:53:35 +00:00
resolve_imports.rs duplicate_macro_exports -> error 2019-11-06 11:10:37 +01:00