about summary refs log tree commit diff
path: root/src/libproc_macro
AgeCommit message (Collapse)AuthorLines
2018-07-25Deny bare_trait_objects globallyTatsuyuki Ishi-1/+0
2018-07-20proc_macro: avoid exposing internal details in formatting impls.Eduard-Mihai Burtescu-7/+37
2018-07-20proc_macro: move some implementation details to a rustc module.Eduard-Mihai Burtescu-258/+305
2018-07-20proc_macro: don't expose compiler-internal FileName in public API.Eduard-Mihai Burtescu-16/+7
2018-07-20proc_macro: clean up the implementation of quasi-quoting.Eduard-Mihai Burtescu-183/+96
2018-07-20proc_macro: don't try to reflect literals in quasi-quoting.Eduard-Mihai Burtescu-95/+16
2018-07-20proc_macro: don't use DiagnosticBuilder for building up Diagnostics.Eduard-Mihai Burtescu-25/+21
2018-07-16rustc: Stabilize much of the `proc_macro` featureAlex Crichton-108/+130
This commit stabilizes some of the `proc_macro` language feature as well as a number of APIs in the `proc_macro` crate as [previously discussed][1]. This means that on stable Rust you can now define custom procedural macros which operate as attributes attached to items or `macro_rules!`-like bang-style invocations. This extends the suite of currently stable procedural macros, custom derives, with custom attributes and custom bang macros. Note though that despite the stabilization in this commit procedural macros are still not usable on stable Rust. To stabilize that we'll need to stabilize at least part of the `use_extern_macros` feature. Currently you can define a procedural macro attribute but you can't import it to call it! A summary of the changes made in this PR (as well as the various consequences) is: * The `proc_macro` language and library features are now stable. * Other APIs not stabilized in the `proc_macro` crate are now named under a different feature, such as `proc_macro_diagnostic` or `proc_macro_span`. * A few checks in resolution for `proc_macro` being enabled have switched over to `use_extern_macros` being enabled. This means that code using `#![feature(proc_macro)]` today will likely need to move to `#![feature(use_extern_macros)]`. It's intended that this PR, once landed, will be followed up with an attempt to stabilize a small slice of `use_extern_macros` just for procedural macros to make this feature 100% usable on stable. [1]: https://internals.rust-lang.org/t/help-stabilize-a-subset-of-macros-2-0/7252
2018-07-14Clarify how the quote macro is loadedManish Goregaokar-0/+5
2018-07-12Deny bare trait objects in the rest of rustljedrz-0/+1
2018-07-08hygiene: Decouple transparencies from expansion IDsVadim Petrochenkov-12/+7
2018-06-30Address commentsVadim Petrochenkov-1/+4
2018-06-30Fortify dummy span checkingVadim Petrochenkov-3/+1
2018-06-30proc-macro: Use transparent marks for call-site hygieneVadim Petrochenkov-35/+55
2018-06-23hygiene: Do not reset expansion info for `quote!`Vadim Petrochenkov-3/+0
2018-06-01Update recursion limitsJohn Kåre Alsaker-0/+2
2018-05-26Auto merge of #51072 - petrochenkov:ifield, r=eddybbors-3/+3
Use `Ident`s for fields in HIR Continuation of https://github.com/rust-lang/rust/pull/49718, part of https://github.com/rust-lang/rust/issues/49300
2018-05-26Add `Ident::as_str` helperVadim Petrochenkov-3/+3
2018-05-25Rename TokenStream::empty to TokenStream::newDavid Tolnay-3/+3
There is no precedent for the `empty` name -- we do not have `Vec::empty` or `HashMap::empty` etc.
2018-05-17Fix rebaseVadim Petrochenkov-1/+1
2018-05-16Fix stability annotations for already stable bits of proc macro API 1.1Vadim Petrochenkov-5/+5
Remove unnecessary proc-macro-related `feature`s
2018-05-15Represent lifetimes as two joint tokens in proc macrosVadim Petrochenkov-16/+18
2018-05-15Address feedback, remove remaining review comments, add some more docsVadim Petrochenkov-53/+30
2018-05-15proc_macro: Validate inputs to `Punct::new` and `Ident::new`Vadim Petrochenkov-22/+47
2018-05-15proc_macro: Properly support raw identifiersVadim Petrochenkov-14/+13
2018-05-15TokenTree: Op -> Punct, Term -> IdentVadim Petrochenkov-113/+97
2018-05-15Extend documentation and add review commentsVadim Petrochenkov-38/+152
2018-05-10Auto merge of #49823 - Zoxc:term-str, r=alexcrichtonbors-3/+4
Remove usages of Term::as_str and mark it for removal Returning references to rustc internal data structures is a bad idea since their lifetimes are unrelated to the lifetimes of proc_macro values. See https://github.com/rust-lang/rust/pull/46972 and the `Taming thread-local storage` section of https://internals.rust-lang.org/t/parallelizing-rustc-using-rayon/6606 r? @alexcrichton
2018-05-04proc_macro: Explicitly make everything !Send/SyncAlex Crichton-1/+46
This commit adds explicit imp blocks to ensure that all publicly exported types (except simple enums) are not `Send` nor `Sync` in the `proc_macro` crate. cc #38356
2018-04-30Remove usages of Term::as_str and mark it for removalJohn Kåre Alsaker-3/+4
2018-04-26Fix review nitsbobtwinkles-1/+1
2018-04-23Implement parent() on `syntax_pos::Span`bobtwinkles-1/+1
... and reimplement proc_macro::Span::parent using it. This function turns out to be useful in the compiler as well
2018-04-12Change the hashcounts in raw `Lit` variants from usize to u16.Nicholas Nethercote-3/+3
This reduces the size of `Token` from 32 bytes to 24 bytes on 64-bit platforms.
2018-04-12Rollup merge of #49734 - alexcrichton:generalize-token-stream, r=nikomatsakiskennytm-2/+9
proc_macro: Generalize `FromIterator` impl While never intended to be stable we forgot that trait impls are insta-stable! This construction of `FromIterator` wasn't our first choice of how to stabilize the impl but our hands are tied at this point, so revert back to the original definition of `FromIterator` before #49597 Closes #49725
2018-04-08Move deny(warnings) into rustbuildMark Simulacrum-1/+0
This permits easier iteration without having to worry about warnings being denied. Fixes #49517
2018-04-07Auto merge of #49661 - alexcrichton:bump-bootstrap, r=nikomatsakisbors-1/+0
Bump the bootstrap compiler to 1.26.0 beta Holy cow that's a lot of `cfg(stage0)` removed and a lot of new stable language features!
2018-04-06Print proc_macro spans as a half-open rangeDavid Tolnay-1/+1
A span covering a single byte, such as for an operator `+` token, should print as e.g. `80..81` rather than `80...81`. The lo end of the range is inclusive and the hi end is exclusive.
2018-04-06proc_macro: Improve Debug representationsAlex Crichton-35/+63
This commit improves the `fmt::Debug` output of `proc_macro` data structures by primarily focusing on the representation exposed by `proc_macro` rather than the compiler's own internal representation. This cuts down quite a bit on assorted wrapper types and ensure a relatively clean output. Closes #49720
2018-04-06proc_macro: Generalize `FromIterator` implAlex Crichton-2/+9
While never intended to be stable we forgot that trait impls are insta-stable! This construction of `FromIterator` wasn't our first choice of how to stabilize the impl but our hands are tied at this point, so revert back to the original definition of `FromIterator` before #49597 Closes #49725
2018-04-06Remove more duplicated spansVadim Petrochenkov-7/+9
2018-04-06Use `Span` instead of `SyntaxContext` in `Ident`Vadim Petrochenkov-1/+1
2018-04-05Bump the bootstrap compiler to 1.26.0 betaAlex Crichton-1/+0
Holy cow that's a lot of `cfg(stage0)` removed and a lot of new stable language features!
2018-04-04Tweak doc comment expansionAlex Crichton-1/+7
* Expand `!` tokens for inner doc comments * Trim leading doc comment decoration in the string literal Both of these should help bring the expansion inline with what `macro_rules!` already does. Closes #49655 Closes #49656
2018-04-02proc_macro: Reorganize public APIAlex Crichton-240/+645
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/
2018-03-31proc_macro: Tweak doc comments and negative literalsAlex Crichton-51/+80
This commit tweaks the tokenization of a doc comment to use `#[doc = "..."]` like `macro_rules!` does (instead of treating it as a `Literal` token). Additionally it fixes treatment of negative literals in the compiler, for exapmle `Literal::i32(-1)`. The current fix is a bit of a hack around the current compiler implementation, providing a fix at the proc-macro layer rather than the libsyntax layer.
2018-03-26Stabilize i128_typeMark Mansi-1/+1
2018-03-18Initial implementation of RFC 2151, Raw IdentifiersLymia Aluysia-2/+9
2018-03-17syntax: Make `_` an identifierVadim Petrochenkov-2/+0
2018-03-02Impl !Send and !Sync for SourceFileJohn Kåre Alsaker-0/+6
2018-03-02Replace Rc with Lrc for shared dataJohn Kåre Alsaker-3/+5