about summary refs log tree commit diff
path: root/src/libsyntax_ext
AgeCommit message (Collapse)AuthorLines
2016-09-10Improve `Eq` derivingVadim Petrochenkov-33/+37
2016-09-10Improve shallow `Clone` derivingVadim Petrochenkov-77/+129
2016-09-09Add ExpnId to expanded procedural macro codeDavid Tolnay-4/+16
2016-09-07Avoid instaiblity errors in code generated by ↵Jeffrey Seyfried-1/+10
`syntax_ext::deriving::call_intrinsic()`.
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-04Replace `_, _` with `..`Vadim Petrochenkov-7/+8
2016-09-03Support deriving some traits for unionsVadim Petrochenkov-1/+10
2016-09-02rustc: Implement custom derive (macros 1.1)Alex Crichton-133/+565
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]
2016-08-30Future proof `libsyntax_ext` for `union`.Jeffrey Seyfried-0/+14
2016-08-28Rollup merge of #35917 - jseyfried:remove_attr_ext_traits, r=nrcJeffrey Seyfried-2/+0
syntax: Remove traits `AttrMetaMethods`, `AttributeMethods`, and `AttrNestedMetaItemMethods`
2016-08-28Rollup merge of #35850 - SergioBenitez:master, r=nrcJeffrey Seyfried-5/+5
Implement RFC#1559: allow all literals in attributes Implemented rust-lang/rfcs#1559, tracked by #34981.
2016-08-28Rollup merge of #35728 - petrochenkov:empderive, r=manishearthJeffrey Seyfried-30/+36
Fix #[derive] for empty tuple structs/variants This was missing from https://github.com/rust-lang/rust/pull/35138
2016-08-28Rollup merge of #35480 - KiChjang:e0379-bonus, r=nikomatsakisJeffrey Seyfried-2/+3
Move E0379 check from typeck to ast validation Part of #35233. Extension of #35338, #35364. Fixes #35404.
2016-08-27Change Constness to Spanned<Constness>Keith Yeung-2/+3
2016-08-25Refactor away `AttrMetaMethods`.Jeffrey Seyfried-2/+0
2016-08-25Refactor away `AttrNestedMetaItemMethods`.Jeffrey Seyfried-1/+1
2016-08-25Implement RFC#1559: allow all literals in attributes.Sergio Benitez-5/+5
2016-08-18Add Span field for Generics structsGuillaume Gomez-3/+6
2016-08-18Split `AstBuilder::pat_enum` into `pat_tuple_struct` and `pat_path`Vadim Petrochenkov-22/+28
2016-08-18Fix #[derive] for empty tuple structs/variantsVadim Petrochenkov-8/+8
2016-08-12run rustfmt on libsyntax_ext folderSrinivas Reddy Thatiparthy-247/+273
2016-07-30Rollup merge of #35106 - xen0n:issue-35082, r=alexcrichtonManish Goregaokar-1/+3
syntax_ext: format: fix ICE with bad named arguments Fixes #35082 by guarding against a new case of malformed invocation not previously covered. r? @alexcrichton
2016-07-29syntax_ext: format: fix ICE with bad named argumentsWang Xuerui-1/+3
2016-07-25General MetaItem encapsulation rewrites.cgswords-10/+9
2016-07-19Run rustfmt on libsyntax_ext/deriving folderSrinivas Reddy Thatiparthy-927/+932
2016-07-14syntax_ext: format: better code documentationWang Xuerui-12/+46
2016-07-14syntax_ext: format: de-duplicate argument objectsWang Xuerui-12/+31
2016-07-14syntax_ext: format: process counts uniquely and separatelyWang Xuerui-11/+62
2016-07-14syntax_ext: format: allow multiple formats for one argumentWang Xuerui-69/+57
This commit removed the restriction of only allowing one type per argument. This is achieved by adding mappings between macro arguments and format placeholders, then taking the mapping into consideration when emitting the Arguments expression. syntax_ext: format: fix implicit positional arguments syntax_ext: format: don't panic if no args given for implicit positional args Check the list lengths before use. Fixes regression of `compile-fail/macro-backtrace-println.rs`. syntax_ext: format: also map CountIsParam indices to expanded args syntax_ext: format: fix ICE in case of malformed format args
2016-07-14syntax_ext: format: rename variants of ArgumentType for clarityWang Xuerui-7/+7
2016-07-14syntax_ext: format: resolve named arguments earlyWang Xuerui-85/+62
Converts named argument references into indices, right after verification as suggested by @alexcrichton. This drastically simplifies the whole process!
2016-07-14syntax_ext: format: separate verification and translation of piecesWang Xuerui-5/+11
2016-07-14format: remove all implicit ref handling outside of libfmt_macrosWang Xuerui-17/+12
format: beautifully get rid of ArgumentNext and CountIsNextParam Now that CountIsNextParam and ArgumentNext are resolved during parse, the need for handling them outside of libfmt_macros is obviated. Note: *one* instance of implicit reference handling still remains, and that's for implementing `all_args_simple`. It's trivial enough though, so in this case it may be tolerable.
2016-07-06Correct inline assembly clobber formatting.CensoredUsername-0/+3
Fixes the formatting for inline assembly clobbers used in the book. As this causes llvm to silently ignore the clobber an error is also added to catch cases in which the wrong formatting was used. Additionally a test case is added to confirm that this error works.
2016-07-03prefer `if let` to match with `None => {}` arm in some placesZack M. Davis-29/+17
This is a spiritual succesor to #34268/8531d581, in which we replaced a number of matches of None to the unit value with `if let` conditionals where it was judged that this made for clearer/simpler code (as would be recommended by Manishearth/rust-clippy's `single_match` lint). The same rationale applies to matches of None to the empty block.
2016-06-29Disallow `derive` on items with type macrosJeffrey Seyfried-4/+14
2016-06-26Rollup merge of #34436 - jseyfried:no_block_expr, r=eddybJeffrey Seyfried-16/+14
To allow these braced macro invocation, this PR removes the optional expression from `ast::Block` and instead uses a `StmtKind::Expr` at the end of the statement list. Currently, braced macro invocations in blocks can expand into statements (and items) except when they are last in a block, in which case they can only expand into expressions. For example, ```rust macro_rules! make_stmt { () => { let x = 0; } } fn f() { make_stmt! {} //< This is OK... let x = 0; //< ... unless this line is commented out. } ``` Fixes #34418.
2016-06-26Rollup merge of #34339 - jseyfried:thin_vec, r=petrochenkov,ManishearthJeffrey Seyfried-3/+3
Generalize and abstract `ThinAttributes` to `ThinVec<Attribute>`.
2016-06-26Rollup merge of #34316 - jseyfried:refactor_ast_stmt, r=eddybJeffrey Seyfried-8/+11
Refactor away `ast::Decl`, refactor `ast::Stmt`, and rename `ast::ExprKind::Again` to `ast::ExprKind::Continue`.
2016-06-26Rollup merge of #33943 - jseyfried:libsyntax_cleanup, r=nrcJeffrey Seyfried-2/+2
Miscellaneous low priority cleanup in `libsyntax`.
2016-06-26Rollup merge of #34385 - cgswords:tstream, r=nrcJeffrey Seyfried-14/+19
syntax-[breaking-change] cc #31645 (Only breaking because ast::TokenTree is now tokenstream::TokenTree.) This pull request refactors TokenTrees into their own file as src/libsyntax/tokenstream.rs, moving them out of src/libsyntax/ast.rs, in order to prepare for an accompanying TokenStream implementation (per RFC 1566).
2016-06-23Refactor away duplicate method `ecx.block_all()`Jeffrey Seyfried-1/+1
2016-06-23Remove field `expr` of `ast::Block`Jeffrey Seyfried-18/+17
2016-06-23Move errors from libsyntax to its own crateJonathan Turner-27/+34
2016-06-21Refactored tokentrees into their own files in preparation for tokenstreams. ↵cgswords-14/+19
Modified tests to point to the new file now.
2016-06-19Generalize and abstract `ThinAttributes`Jeffrey Seyfried-3/+3
2016-06-17Fix falloutJeffrey Seyfried-8/+13
2016-06-16Simplify gated cfg checkingJeffrey Seyfried-8/+1
2016-06-14Remove the type parameter from `syntax::visit::Visitor`Jeffrey Seyfried-2/+2
2016-05-31simplify HR subtyping back to what we did beforeNiko Matsakis-1/+1
A lot of the refactors, however, seem helpful, so leave those in, particularly since we may want to make this change in the future.