rust/src/libsyntax_ext
Alex Crichton d4d276faaf Rollup merge of #38842 - abonander:proc_macro_attribute, r=jseyfried
Implement `#[proc_macro_attribute]`

This implements `#[proc_macro_attribute]` as described in https://github.com/rust-lang/rfcs/pull/1566

The following major (hopefully non-breaking) changes are included:

* Refactor `proc_macro::TokenStream` to use `syntax::tokenstream::TokenStream`.
    * `proc_macro::tokenstream::TokenStream` no longer emits newlines between items, this can be trivially restored if desired
    * `proc_macro::TokenStream::from_str` does not try to parse an item anymore, moved to `impl MultiItemModifier for CustomDerive` with more informative error message

* Implement `#[proc_macro_attribute]`, which expects functions of the kind `fn(TokenStream, TokenStream) -> TokenStream`
    * Reactivated `#![feature(proc_macro)]` and gated `#[proc_macro_attribute]` under it
    * `#![feature(proc_macro)]` and `#![feature(custom_attribute)]` are mutually exclusive
    * adding `#![feature(proc_macro)]` makes the expansion pass assume that any attributes that are not built-in, or introduced by existing syntax extensions, are proc-macro attributes

* Fix `feature_gate::find_lang_feature_issue()` to not use `unwrap()`

    * This change wasn't necessary for this PR, but it helped debugging a problem where I was using the wrong feature string.

* Move "completed feature gate checking" pass to after "name resolution" pass

    * This was necessary for proper feature-gating of `#[proc_macro_attribute]` invocations when the `proc_macro` feature flag isn't set.

Prototype/Litmus Test: [Implementation](https://github.com/abonander/anterofit/blob/proc_macro/service-attr/src/lib.rs#L13) -- [Usage](https://github.com/abonander/anterofit/blob/proc_macro/service-attr/examples/post_service.rs#L35)
2017-01-20 08:34:30 -08:00
..
deriving Rollup merge of #38842 - abonander:proc_macro_attribute, r=jseyfried 2017-01-20 08:34:30 -08:00
asm.rs Use Symbol instead of InternedString in the AST, HIR, and various other places. 2016-11-21 09:00:55 +00:00
Cargo.toml rustc: Rename rustc_macro to proc_macro 2016-10-06 11:07:23 -07:00
cfg.rs Move CrateConfig from Crate to ParseSess. 2016-10-29 07:52:58 +00:00
concat.rs Use Symbol instead of InternedString in the AST, HIR, and various other places. 2016-11-21 09:00:55 +00:00
concat_idents.rs Refactor how global paths are represented (for both ast and hir). 2016-12-22 06:14:35 +00:00
env.rs Use Symbol instead of InternedString in the AST, HIR, and various other places. 2016-11-21 09:00:55 +00:00
format.rs Use Symbol instead of InternedString in the AST, HIR, and various other places. 2016-11-21 09:00:55 +00:00
format_foreign.rs Add foreign formatting directive detection. 2016-11-11 15:23:15 +11:00
lib.rs Implement #[proc_macro_attribute] 2017-01-16 22:41:22 -08:00
log_syntax.rs make emit_feature_err take a ParseSess 2016-09-26 07:07:41 +02:00
proc_macro_impl.rs Implement #[proc_macro_attribute] 2017-01-16 22:41:22 -08:00
proc_macro_registrar.rs Implement #[proc_macro_attribute] 2017-01-16 22:41:22 -08:00
trace_macros.rs Move syntax::util::interner -> syntax::symbol, cleanup. 2016-11-20 23:40:20 +00:00