rust/src/libsyntax/ext
Alex Crichton 79630d4fdf rustc: Tweak custom attribute capabilities
This commit starts to lay some groundwork for the stabilization of custom
attribute invocations and general procedural macros. It applies a number of
changes discussed on [internals] as well as a [recent issue][issue], namely:

* The path used to specify a custom attribute must be of length one and cannot
  be a global path. This'll help future-proof us against any ambiguities and
  give us more time to settle the precise syntax. In the meantime though a bare
  identifier can be used and imported to invoke a custom attribute macro. A new
  feature gate, `proc_macro_path_invoc`, was added to gate multi-segment paths
  and absolute paths.

* The set of items which can be annotated by a custom procedural attribute has
  been restricted. Statements, expressions, and modules are disallowed behind
  two new feature gates: `proc_macro_expr` and `proc_macro_mod`.

* The input to procedural macro attributes has been restricted and adjusted.
  Today an invocation like `#[foo(bar)]` will receive `(bar)` as the input token
  stream, but after this PR it will only receive `bar` (the delimiters were
  removed). Invocations like `#[foo]` are still allowed and will be invoked in
  the same way as `#[foo()]`. This is a **breaking change** for all nightly
  users as the syntax coming in to procedural macros will be tweaked slightly.

* Procedural macros (`foo!()` style) can only be expanded to item-like items by
  default. A separate feature gate, `proc_macro_non_items`, is required to
  expand to items like expressions, statements, etc.

Closes #50038

[internals]: https://internals.rust-lang.org/t/help-stabilize-a-subset-of-macros-2-0/7252
[issue]: https://github.com/rust-lang/rust/issues/50038
2018-04-20 19:56:16 -07:00
..
tt Auto merge of #49719 - mark-i-m:no_sep, r=petrochenkov 2018-04-16 00:06:10 +00:00
base.rs Add error codes for libsyntax_ext 2018-04-14 17:25:35 +02:00
build.rs Auto merge of #49993 - nnethercote:shrink-Token, r=alexcrichton 2018-04-18 14:44:54 +00:00
derive.rs Rename PathSegment::identifier to ident 2018-04-06 11:46:26 +03:00
expand.rs rustc: Tweak custom attribute capabilities 2018-04-20 19:56:16 -07:00
placeholders.rs expand macro invocations in extern {} blocks 2018-04-03 13:16:11 -07:00
quote.rs Change the hashcounts in raw Lit variants from usize to u16. 2018-04-12 20:12:42 +10:00
source_util.rs Replace Rc with Lrc for shared data 2018-03-02 10:48:52 +01:00