diff options
| author | bors <bors@rust-lang.org> | 2018-05-16 11:18:05 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-05-16 11:18:05 +0000 |
| commit | 2a3f5367a23a769a068c37460db336de427c4b48 (patch) | |
| tree | 8017b98f72aba661e56c0f0be9bf8a37f4b15f2f /src/libcore/num/mod.rs | |
| parent | 448cc578a903730d422f6e638641787d0dbd7bc7 (diff) | |
| parent | dab8c0ab28c317f7b9e350a0ba84fd51787f84d6 (diff) | |
| download | rust-2a3f5367a23a769a068c37460db336de427c4b48.tar.gz rust-2a3f5367a23a769a068c37460db336de427c4b48.zip | |
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`).
Diffstat (limited to 'src/libcore/num/mod.rs')
0 files changed, 0 insertions, 0 deletions
