rust/src/test/run-pass-fulldeps
Alex Crichton e6947ecf4d Rollup merge of #49597 - alexcrichton:proc-macro-v2, r=petrochenkov
proc_macro: Reorganize public API

This commit is a reorganization of the `proc_macro` crate's public user-facing
API. This is the result of a number of discussions at the recent Rust All-Hands
where we're hoping to get the `proc_macro` crate into ship shape for
stabilization of a subset of its functionality in the Rust 2018 release.

The reorganization here is motivated by experiences from the `proc-macro2`,
`quote`, and `syn` crates on crates.io (and other crates which depend on them).
The main focus is future flexibility along with making a few more operations
consistent and/or fixing bugs. A summary of the changes made from today's
`proc_macro` API is:

* The `TokenNode` enum has been removed and the public fields of `TokenTree`
  have also been removed. Instead the `TokenTree` type is now a public enum
  (what `TokenNode` was) and each variant is an opaque struct which internally
  contains `Span` information. This makes the various tokens a bit more
  consistent, require fewer wrappers, and otherwise provides good
  future-compatibility as opaque structs are easy to modify later on.

* `Literal` integer constructors have been expanded to be unambiguous as to what
  they're doing and also allow for more future flexibility. Previously
  constructors like `Literal::float` and `Literal::integer` were used to create
  unsuffixed literals and the concrete methods like `Literal::i32` would create
  a suffixed token. This wasn't immediately clear to all users (the
  suffixed/unsuffixed aspect) and having *one* constructor for unsuffixed
  literals required us to pick a largest type which may not always be true. To
  fix these issues all constructors are now of the form
  `Literal::i32_unsuffixed` or `Literal::i32_suffixed` (for all integral types).
  This should allow future compatibility as well as being immediately clear
  what's suffixed and what isn't.

* Each variant of `TokenTree` internally contains a `Span` which can also be
  configured via `set_span`. For example `Literal` and `Term` now both
  internally contain a `Span` rather than having it stored in an auxiliary
  location.

* Constructors of all tokens are called `new` now (aka `Term::intern` is gone)
  and most do not take spans. Manufactured tokens typically don't have a fresh
  span to go with them and the span is purely used for error-reporting
  **except** the span for `Term`, which currently affects hygiene. The default
  spans for all these constructed tokens is `Span::call_site()` for now.

  The `Term` type's constructor explicitly requires passing in a `Span` to
  provide future-proofing against possible hygiene changes. It's intended that a
  first pass of stabilization will likely only stabilize `Span::call_site()`
  which is an explicit opt-in for "I would like no hygiene here please". The
  intention here is to make this explicit in procedural macros to be
  forwards-compatible with a hygiene-specifying solution.

* Some of the conversions for `TokenStream` have been simplified a little.

* The `TokenTreeIter` iterator was renamed to `token_stream::IntoIter`.

Overall the hope is that this is the "final pass" at the API of `TokenStream`
and most of `TokenTree` before stabilization. Explicitly left out here is any
changes to `Span`'s API which will likely need to be re-evaluated before
stabilization.

All changes in this PR have already been reflected to the [`proc-macro2`],
`quote`, and `syn` crates. New versions of all these crates have also been
published to crates.io.

Once this lands in nightly I plan on making an internals post again summarizing
the changes made here and also calling on all macro authors to give the APIs a
spin and see how they work. Hopefully pending no major issues we can then have
an FCP to stabilize later this cycle!

[`proc-macro2`]: https://docs.rs/proc-macro2/0.3.1/proc_macro2/

Closes #49596
2018-04-05 11:18:16 -07:00
..
auxiliary Rollup merge of #49597 - alexcrichton:proc-macro-v2, r=petrochenkov 2018-04-05 11:18:16 -07:00
proc-macro Rollup merge of #49597 - alexcrichton:proc-macro-v2, r=petrochenkov 2018-04-05 11:18:16 -07:00
ast_stmt_expr_attr.rs Remove all unstable placement features 2018-04-03 11:02:34 +02:00
compiler-calls.rs
create-dir-all-bare.rs
custom-derive-partial-eq.rs
derive-no-std-not-supported.rs
derive-totalsum-attr.rs
derive-totalsum.rs
deriving-encodable-decodable-box.rs
deriving-encodable-decodable-cell-refcell.rs
deriving-global.rs
dropck_tarena_sound_drop.rs
empty-struct-braces-derive.rs
extern-mod-syntax.rs
issue_24106.rs
issue-2804.rs
issue-4016.rs
issue-4036.rs
issue-11881.rs
issue-13560.rs
issue-14021.rs
issue-15149.rs
issue-15778-pass.rs
issue-15924.rs
issue-16723.rs
issue-16822.rs
issue-16992.rs
issue-18502.rs
issue-18763-quote-token-tree.rs
issue-24972.rs
issue-35829.rs Remove unused imports 2018-03-17 14:03:37 +01:00
issue-40663.rs
linkage-visibility.rs
llvm-pass-plugin.rs
lto-syntax-extension.rs
macro-crate-does-hygiene-work.rs
macro-crate-multi-decorator-literals.rs
macro-crate-multi-decorator.rs
macro-crate.rs
macro-quote-cond.rs
macro-quote-test.rs
mbe_matching_test_macro.rs
myriad-closures.rs
outlive-expansion-phase.rs
plugin-args-1.rs
plugin-args-2.rs
plugin-args-3.rs
plugin-lib-ok-in-plugin.rs
plugin-plus-extern-crate.rs
pprust-expr-roundtrip.rs Remove all unstable placement features 2018-04-03 11:02:34 +02:00
proc_macro.rs
qquote.rs Remove syntax and syntax_pos thread locals 2018-03-14 11:56:01 +01:00
quote-tokens.rs
quote-unused-sp-no-warning.rs
regions-mock-tcx.rs
rename-directory.rs
roman-numerals-macro.rs
rustc_encodable_hygiene.rs
stdio-from.rs
switch-stdout.rs
syntax-extension-with-dll-deps.rs