rust/src/libsyntax
bors 2a3f5367a2 Auto merge of #50473 - petrochenkov:pmapi, r=alexcrichton
Review proc macro API 1.2

cc https://github.com/rust-lang/rust/issues/38356

Summary of applied changes:
- Documentation for proc macro API 1.2 is expanded.
- Renamed APIs: `Term` -> `Ident`, `TokenTree::Term` -> `TokenTree::Ident`, `Op` -> `Punct`, `TokenTree::Op` -> `TokenTree::Punct`, `Op::op` -> `Punct::as_char`.
- Removed APIs: `Ident::as_str`, use `Display` impl for `Ident` instead.
- New APIs (not stabilized in 1.2): `Ident::new_raw` for creating a raw identifier (I'm not sure `new_x` it's a very idiomatic name though).
- Runtime changes:
    - `Punct::new` now ensures that the input `char` is a valid punctuation character in Rust.
    - `Ident::new` ensures that the input `str` is a valid identifier in Rust.
    - Lifetimes in proc macros are now represented as two joint tokens - `Punct('\'', Spacing::Joint)` and `Ident("lifetime_name_without_quote")` similarly to multi-character operators.
- Stabilized APIs: None yet.

A bit of motivation for renaming (although it was already stated in the review comments):
- With my compiler frontend glasses on `Ident` is the single most appropriate name for this thing, *especially* if we are doing input validation on construction. `TokenTree::Ident` effectively wraps `token::Ident` or `ast::Ident + is_raw`, its meaning is "identifier" and it's already named `ident` in declarative macros.
- Regarding `Punct`, the motivation is that `Op` is actively misleading. The thing doesn't mean an operator, it's neither a subset of operators (there is non-operator punctuation in the language), nor superset (operators can be multicharacter while this thing is always a single character). So I named it `Punct` (first proposed in [the original RFC](https://github.com/rust-lang/rfcs/pull/1566), then [by @SimonSapin](https://github.com/rust-lang/rust/issues/38356#issuecomment-276676526)) , together with input validation it's now a subset of ASCII punctuation character category (`u8::is_ascii_punctuation`).
2018-05-16 11:18:05 +00:00
..
diagnostics Allow raw identifiers in diagnostic macros. 2018-03-18 13:27:56 -05:00
ext Represent lifetimes as two joint tokens in proc macros 2018-05-15 23:54:08 +03:00
parse Represent lifetimes as two joint tokens in proc macros 2018-05-15 23:54:08 +03:00
print Represent lifetimes as two joint tokens in proc macros 2018-05-15 23:54:08 +03:00
util AST/HIR: Merge field access expressions for named and numeric fields 2018-04-12 23:02:09 +03:00
ast.rs make it compile again 2018-05-02 12:05:13 +02:00
attr.rs Macros: Add a 'literal' fragment specifier 2018-05-13 19:17:02 +03:00
build.rs rustc: Add some build scripts for librustc crates 2017-07-22 22:04:13 -07:00
Cargo.toml rustc_target: move in syntax::abi and flip dependency. 2018-04-26 17:49:16 +03:00
codemap.rs CodeMap functions refactored. 2018-03-18 20:46:29 -03:00
config.rs Rename ast::Variant_::name into ident + Fix rebase 2018-04-06 11:48:19 +03:00
diagnostic_list.rs Auto merge of #50030 - flip1995:rfc2103, r=petrochenkov 2018-05-03 11:52:03 +00:00
edition.rs Rename the 2018 edition lint names 2018-05-10 11:28:11 -07:00
entry.rs Cleanup InternedString. 2016-11-21 09:00:56 +00:00
feature_gate.rs Feature gate trivial bounds 2018-05-15 11:43:57 +01:00
fold.rs Macros: Add a 'literal' fragment specifier 2018-05-13 19:17:02 +03:00
json.rs Approximate -> Applicability 2018-04-25 14:55:25 -07:00
lib.rs Add a Rayon thread pool 2018-05-13 01:28:20 +02:00
ptr.rs syntax: Rename P::unwrap into P::into_inner 2017-12-17 02:21:29 +03:00
README.md Replace many of the last references to readmes 2018-03-16 12:43:22 -05:00
show_span.rs use field init shorthand EVERYWHERE 2017-08-15 15:29:17 -07:00
std_inject.rs Reorder injection of std to get better compilation error 2018-04-16 12:28:30 -07:00
str.rs syntax: Copy unstable str::char_at into libsyntax 2015-04-21 10:23:53 -07:00
test.rs Fixed tidy errors. 2018-04-26 17:49:24 +03:00
test_snippet.rs Remove syntax and syntax_pos thread locals 2018-03-14 11:56:01 +01:00
tokenstream.rs proc_macro: Stay on the "use the cache" path more 2018-04-18 19:36:48 -07:00
visit.rs rustc_target: move in syntax::abi and flip dependency. 2018-04-26 17:49:16 +03:00

The syntax crate contains those things concerned purely with syntax that is, the AST ("abstract syntax tree"), parser, pretty-printer, lexer, macro expander, and utilities for traversing ASTs.

For more information about how these things work in rustc, see the rustc guide: