about summary refs log tree commit diff
path: root/src/libsyntax_ext
AgeCommit message (Collapse)AuthorLines
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.
2016-05-28Use the span of `#[derive_Eq]` for `#[structural_match]`Jeffrey Seyfried-42/+14
2016-05-28Refactor away `set_expn_info`Jeffrey Seyfried-9/+2
2016-05-28Fix spans of generated `#[derive_*]` attributesJeffrey Seyfried-45/+44
2016-05-25Add a new AST-only type variant `ImplicitSelf`Vadim Petrochenkov-3/+0
2016-05-25Remove ExplicitSelf from ASTVadim Petrochenkov-30/+22
2016-05-23Auto merge of #33735 - jseyfried:concat_idents_in_ty_positions, r=nrcbors-18/+32
Allow `concat_idents!` in type positions as well as in expression positions This allows the `concat_idents!` macro in type positions as well as in expression positions. r? @nrc
2016-05-19Allow `concat_idents!` in type positions as well as in expression positionsJeffrey Seyfried-18/+32
2016-05-18Rollup merge of #33666 - xen0n:no-more-nest-levels, r=nikomatsakisManish Goregaokar-21/+5
syntax_ext: format: nest_level's are no more Just noticed this while working on #33642 and here's a quick fix, shouldn't touch anything else. It's some historic code indeed...
2016-05-16syntax_ext: format: remove reference to methods in commentWang Xuerui-1/+1
2016-05-16syntax_ext: format: nest_level's are no moreWang Xuerui-20/+4
`nest_level` is long dead since cac7a2053aba7be214d5e58e13867089638a8f50 (PR #14831), so is `check_positional_ok()`. Let's bid them farewell.
2016-05-15Auto merge of #33505 - petrochenkov:self, r=nrcbors-3/+2
Remove ExplicitSelf from HIR `self` argument is already kept in the argument list and can be retrieved from there if necessary, so there's no need for the duplication. The same changes can be applied to AST, I'll make them in the next breaking batch. The first commit also improves parsing of method declarations and fixes https://github.com/rust-lang/rust/issues/33413. r? @eddyb
2016-05-14syntax: Refactor parsing of method declarationsVadim Petrochenkov-3/+2
Fix spans and expected token lists, fix #33413 + other cosmetic improvements Add test for #33413 Convert between `Arg` and `ExplicitSelf` precisely Simplify pretty-printing for methods
2016-05-12Improve derived implementations for enums with lots of fieldless variantsBjörn Steinbrink-7/+42
A number of trait methods like PartialEq::eq or Hash::hash don't actually need a distinct arm for each variant, because the code within the arm only depends on the number and types of the fields in the variants. We can easily exploit this fact to create less and better code for enums with multiple variants that have no fields at all, the extreme case being C-like enums. For nickel.rs and its by now infamous 800 variant enum, this reduces optimized compile times by 25% and non-optimized compile times by 40%. Also peak memory usage is down by almost 40% (310MB down to 190MB). To be fair, most other crates don't benefit nearly as much, because they don't have as huge enums. The crates in the Rust distribution that I measured saw basically no change in compile times (I only tried optimized builds) and only 1-2% reduction in peak memory usage.
2016-05-03Remove unused trait imports introduced while in reviewSeo Sanghyeon-1/+1
2016-05-02fix rebase flawsNiko Matsakis-3/+3
2016-04-27Auto merge of #32791 - LeoTestard:feature-gate-clean, r=nikomatsakisbors-30/+64
Feature gate clean This PR does a bit of cleaning in the feature-gate-handling code of libsyntax. It also fixes two bugs (#32782 and #32648). Changes include: * Change the way the existing features are declared in `feature_gate.rs`. The array of features and the `Features` struct are now defined together by a single macro. `featureck.py` has been updated accordingly. Note: there are now three different arrays for active, removed and accepted features instead of a single one with a `Status` item to tell wether a feature is active, removed, or accepted. This is mainly due to the way I implemented my macro in the first time and I can switch back to a single array if needed. But an advantage of the way it is now is that when an active feature is used, the parser only searches through the list of active features. It goes through the other arrays only if the feature is not found. I like to think that error checking (in this case, checking that an used feature is active) does not slow down compilation of valid code. :) But this is not very important... * Feature-gate checking pass now use the `Features` structure instead of looking through a string vector. This should speed them up a bit. The construction of the `Features` struct should be faster too since it is build directly when parsing features instead of calling `has_feature` dozens of times. * The MacroVisitor pass has been removed, it was mostly useless since the `#[cfg]-stripping` phase happens before (fixes #32648). The features that must actually be checked before expansion are now checked at the time they are used. This also allows us to check attributes that are generated by macro expansion and not visible to MacroVisitor, but are also removed by macro expansion and thus not visible to PostExpansionVisitor either. This fixes #32782. Note that in order for `#[derive_*]` to be feature-gated but still accepted when generated by `#[derive(Trait)]`, I had to do a little bit of trickery with spans that I'm not totally confident into. Please review that part carefully. (It's in `libsyntax_ext/deriving/mod.rs`.):: Note: this is a [breaking change], since programs with feature-gated attributes on macro-generated macro invocations were not rejected before. For example: ```rust macro_rules! bar ( () => () ); macro_rules! foo ( () => ( #[allow_internal_unstable] //~ ERROR allow_internal_unstable side-steps bar!(); ); ); ``` foo!();
2016-04-26Auto merge of #31414 - durka:clone-copy, r=alexcrichtonbors-32/+96
special-case #[derive(Copy, Clone)] with a shallow clone If a type is Copy then its Clone implementation can be a no-op. Currently `#[derive(Clone)]` generates a deep clone anyway. This can lead to lots of code bloat. This PR detects the case where Copy and Clone are both being derived (the general case of "is this type Copy" can't be determined by a syntax extension) and generates the shallow Clone impl. Right now this can only be done if there are no type parameters (see https://github.com/rust-lang/rust/issues/31085#issuecomment-178988663), but this restriction can be removed after specialization. Fixes #31085.
2016-04-26shallow Clone for #[derive(Copy,Clone)]Alex Burka-32/+96
Changes #[derive(Copy, Clone)] to use a faster impl of Clone when both derives are present, and there are no generics in the type. The faster impl is simply returning *self (which works because the type is also Copy). See the comments in libsyntax_ext/deriving/clone.rs for more details. There are a few types which are Copy but not Clone, in violation of the definition of Copy. These include large arrays and tuples. The very existence of these types is arguably a bug, but in order for this optimization not to change the applicability of #[derive(Copy, Clone)], the faster Clone impl also injects calls to a new function, core::clone::assert_receiver_is_clone, to verify that all members are actually Clone. This is not a breaking change, because pursuant to RFC 1521, any type that implements Copy should not do any observable work in its Clone impl.
2016-04-24Remove some old code from libsyntaxVadim Petrochenkov-8/+7