about summary refs log tree commit diff
path: root/src/libsyntax_ext/deriving/custom.rs
AgeCommit message (Collapse)AuthorLines
2019-07-27Move proc macro server into libsyntaxVadim Petrochenkov-119/+0
2019-06-06syntax: Switch function parameter order in `TokenTree::token`Vadim Petrochenkov-1/+1
2019-06-06syntax: Use `Token` in `TokenTree::Token`Vadim Petrochenkov-1/+1
2019-06-06Always use token kinds through `token` module rather than `Token` typeVadim Petrochenkov-2/+2
2019-05-24Tweak macro parse errors when reaching EOF during macro call parseEsteban Küber-1/+1
- Add detail on origin of current parser when reaching EOF and stop saying "found <eof>" and point at the end of macro calls - Handle empty `cfg_attr` attribute - Reword empty `derive` attribute error
2019-03-16syntax: Do not accidentally treat multi-segment meta-items as single-segmentVadim Petrochenkov-3/+5
2019-02-18Remove `LazyTokenStream`.Nicholas Nethercote-1/+2
It's present within `Token::Interpolated` as an optimization, so that if a nonterminal is converted to a `TokenStream` multiple times, the first-computed value is saved and reused. But in practice it's not needed. `interpolated_to_tokenstream()` is a cold function: it's only called a few dozen times while compiling rustc itself, and a few hundred times across the entire `rustc-perf` suite. Furthermore, when it is called, it is almost always the first conversion, so no benefit is gained from it. So this commit removes `LazyTokenStream`, along with the now-unnecessary `Token::interpolated()`. As well as a significant simplification, the removal speeds things up slightly, mostly due to not having to `drop` the `LazyTokenStream` instances.
2019-02-13Cleanup importsTaiki Endo-1/+1
2019-02-13Rename rustc_errors dependency in rust 2018 cratesTaiki Endo-1/+1
2019-02-04libsyntax_ext => 2018Taiki Endo-7/+8
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-19Remove `eliminate_crate_var` and special pretty-printing for `$crate`Vadim Petrochenkov-1/+0
2018-11-30proc_macro: move the rustc server to syntax_ext.Eduard-Mihai Burtescu-1/+1
2018-11-30proc_macro: remove the __internal module.Eduard-Mihai Burtescu-7/+5
2018-11-30proc_macro: introduce a "bridge" between clients (proc macros) and servers ↵Eduard-Mihai Burtescu-28/+37
(compiler front-ends).
2018-10-26Remove redundant cloneShotaro Yamada-1/+1
2018-08-19mv (mod) codemap source_mapDonato Sciarra-1/+1
2018-06-18Add ability to apply custom derive to union types.Steve Pentland-3/+4
The Union item type has been included in the allowed types for a custom derive. Closes #50223
2018-05-02Remove Option from the return type of Attribute::name()Seiichi Uchida-5/+3
2018-04-03expand macro invocations in `extern {}` blocksAustin Bonander-0/+1
2018-04-02Expand attribute macros on statements and expressions.Austin Bonander-1/+3
Retains the `stmt_expr_attributes` feature requirement for attributes on expressions. closes #41475 cc #38356
2018-01-26Do not capture stderr in the compiler. Instead just panic silently for fatal ↵John Kåre Alsaker-3/+3
errors
2017-11-25Fix proc_macro output with struct parse errorEsteban Küber-1/+7
2017-06-26Simplify `hygiene::Mark` application, andJeffrey Seyfried-11/+4
remove variant `Token::SubstNt` in favor of `quoted::TokenTree::MetaVar`.
2017-03-14Refactor `Attribute` to use `Path` and `TokenStream` instead of `MetaItem`.Jeffrey Seyfried-3/+5
2017-02-12Allow using inert attributes from `proc_macro_derive`s with ↵Jeffrey Seyfried-5/+3
`#![feature(proc_macro)]`.
2017-02-05Move derive macro expansion into the MacroExpanderJosh Driver-4/+4
This removes the expand_derives function, and sprinkles the functionality throughout the Invocation Collector, Expander and Resolver.
2017-02-05Rename CustomDerive to ProcMacroDerive for macros 1.1Josh Driver-9/+9
2017-01-15Refactor `proc_macro::TokenStream` to use ↵Austin Bonander-2/+15
`syntax::tokenstream::TokenStream`; fix tests for changed semantics
2016-12-31Style fixesJosh Driver-2/+1
2016-12-31Stop macro calls in structs for proc_macro_derive from panicingJosh Driver-1/+4
2016-12-06annotate stricter lifetimes on LateLintPass methods to allow them to forward ↵Oliver Schneider-2/+1
to a Visitor
2016-11-20Refactor `MetaItemKind` to use `Name`s instead of `InternedString`s.Jeffrey Seyfried-6/+3
2016-11-10Elimite `$crate` before invokng custom derives.Jeffrey Seyfried-1/+1
2016-11-08Revert "Point macros 1.1 errors to the input item"Josh Driver-17/+3
This reverts commit 3784067edcbcd0614f6c4c88f6445ca17ae27ff6. Any errors in the derived output now point at the derive attribute instead of the item.
2016-11-08Allow proc_macro functions to whitelist specific attributesJosh Driver-11/+33
By using a second attribute `attributes(Bar)` on proc_macro_derive, whitelist any attributes with the name `Bar` in the deriving item. This allows a proc_macro function to use custom attribtues without a custom attribute error or unused attribute lint.
2016-10-06rustc: Rename rustc_macro to proc_macroAlex Crichton-1/+1
This commit blanket renames the `rustc_macro` infrastructure to `proc_macro`, which reflects the general consensus of #35900. A follow up PR to Cargo will be required to purge the `rustc-macro` name as well.
2016-09-23reviewer comments and rebasingNick Cameron-12/+1
2016-09-09Add ExpnId to expanded procedural macro codeDavid Tolnay-4/+16
2016-09-06Point macros 1.1 errors to the input itemDavid Tolnay-2/+3
Before: ```rust error[E0106]: missing lifetime specifier --> src/main.rs:10:10 | 10 | #[derive(Serialize, Deserialize)] | ^ expected lifetime parameter error[E0038]: the trait `T` cannot be made into an object --> src/main.rs:15:15 | 15 | #[derive(Serialize, Deserialize)] | ^^^^^^^^^^ the trait `T` cannot be made into an object ``` After: ```rust error[E0106]: missing lifetime specifier --> src/main.rs:11:1 | 11 | struct A { | ^ expected lifetime parameter error[E0038]: the trait `T` cannot be made into an object --> src/main.rs:16:1 | 16 | struct B<'a> { | ^ the trait `T` cannot be made into an object ```
2016-09-02rustc: Implement custom derive (macros 1.1)Alex Crichton-0/+97
This commit is an implementation of [RFC 1681] which adds support to the compiler for first-class user-define custom `#[derive]` modes with a far more stable API than plugins have today. [RFC 1681]: https://github.com/rust-lang/rfcs/blob/master/text/1681-macros-1.1.md The main features added by this commit are: * A new `rustc-macro` crate-type. This crate type represents one which will provide custom `derive` implementations and perhaps eventually flower into the implementation of macros 2.0 as well. * A new `rustc_macro` crate in the standard distribution. This crate will provide the runtime interface between macro crates and the compiler. The API here is particularly conservative right now but has quite a bit of room to expand into any manner of APIs required by macro authors. * The ability to load new derive modes through the `#[macro_use]` annotations on other crates. All support added here is gated behind the `rustc_macro` feature gate, both for the library support (the `rustc_macro` crate) as well as the language features. There are a few minor differences from the implementation outlined in the RFC, such as the `rustc_macro` crate being available as a dylib and all symbols are `dlsym`'d directly instead of having a shim compiled. These should only affect the implementation, however, not the public interface. This commit also ended up touching a lot of code related to `#[derive]`, making a few notable changes: * Recognized derive attributes are no longer desugared to `derive_Foo`. Wasn't sure how to keep this behavior and *not* expose it to custom derive. * Derive attributes no longer have access to unstable features by default, they have to opt in on a granular level. * The `derive(Copy,Clone)` optimization is now done through another "obscure attribute" which is just intended to ferry along in the compiler that such an optimization is possible. The `derive(PartialEq,Eq)` optimization was also updated to do something similar. --- One part of this PR which needs to be improved before stabilizing are the errors and exact interfaces here. The error messages are relatively poor quality and there are surprising spects of this such as `#[derive(PartialEq, Eq, MyTrait)]` not working by default. The custom attributes added by the compiler end up becoming unstable again when going through a custom impl. Hopefully though this is enough to start allowing experimentation on crates.io! syntax-[breaking-change]