summary refs log tree commit diff
path: root/src/libsyntax_ext/deriving/generic
AgeCommit message (Collapse)AuthorLines
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/+28
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-04-26Auto merge of #31414 - durka:clone-copy, r=alexcrichtonbors-0/+2
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-0/+2
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
2016-04-24syntax: Merge keywords and remaining special idents in one listVadim Petrochenkov-6/+5
Simplify the macro used for generation of keywords Make `Keyword::ident` private
2016-04-24syntax: Make static/super/self/Self keywords + special ident cleanupVadim Petrochenkov-6/+6
2016-04-06Rollup merge of #32570 - eddyb:tis-but-a-front, r=nikomatsakisManish Goregaokar-3/+1
r? @nikomatsakis Conflicts: src/librustc_save_analysis/lib.rs src/libsyntax/ast_util.rs
2016-04-06Move span into `StructField`Vadim Petrochenkov-4/+4
2016-04-06Get rid of ast::StructFieldKindVadim Petrochenkov-44/+11
2016-04-06syntax: dismantle ast_util.Eduard Burtescu-3/+1
2016-03-27deriving: factor out discriminant_value constructionAlex Burka-27/+11
2016-03-21Auto merge of #32253 - durka:derive-31886, r=alexcrichtonbors-1/+1
derive: assume enum repr defaults to isize derive: assume enum repr defaults to isize Fixes #31886. Spawned from #32139. r? @alexcrichton
2016-03-18Auto merge of #31977 - bluss:partial-eq-save, r=brsonbors-0/+18
derive: Avoid emitting provided PartialEq, PartialOrd methods for c-like enums derive: Avoid emitting provided PartialEq, PartialOrd method for c-like enums `ne` is completely symmetrical with the method `eq`, and we can save rust code size and compilation time here if we only emit one of them when possible. One case where it's easy to recognize is when it's a C-like enum. Most other cases can not omit ne, because any value field may have a custom PartialEq implementation.
2016-03-18derive: assume enum repr defaults to isizeAlex Burka-1/+1
It was originally intended to be i32, but it isn't. Fixes #31886.
2016-03-17Re-add double underscores in derive (fixes #32292)Manish Goregaokar-35/+35
2016-03-15Auto merge of #32251 - durka:derive-2810, r=alexcrichtonbors-40/+40
derive: clean up hygiene derive: clean up hygiene Fixes #2810. Spawned from #32139. r? @alexcrichton
2016-03-15Auto merge of #32250 - durka:derive-31574, r=alexcrichtonbors-11/+18
derive: use intrinsics::unreachable over unreachable!() derive: use intrinsics::unreachable over unreachable!() Fixes #31574. Spawned from #32139. r? @alexcrichton
2016-03-14Add `default` as contextual keyword, and parse it for impl items.Aaron Turon-0/+2
2016-03-14derive: remove most __ strings FIXME(#2810)Alex Burka-40/+40
This changes local variable names in all derives to remove leading double-underscores. As far as I can tell, this doesn't break anything because there is no user code in these generated functions except for struct, field and type parameter names, and this doesn't cause shadowing of those. But I am still a bit nervous.
2016-03-14derive: emit intrinsics::unreachable for impls on empty enumsAlex Burka-11/+18
fixes #31574
2016-03-01derive: Emit only PartialOrd::partial_cmp for simple enumsUlrik Sverdrup-0/+18
Using the same logic as for `PartialEq`, when possible define only `partial_cmp` and leave `lt, le, gt, ge` to their default implementations. This works well for c-like enums.
2016-02-22Fix #[derive] for empty structs with bracesVadim Petrochenkov-8/+13
2016-02-13Rename ast::Pat_ and its variantsVadim Petrochenkov-3/+3
2016-02-12Use more autoderef in libsyntax_extJonas Schievink-2/+2
2016-02-11Remove some unnecessary indirection from AST structuresVadim Petrochenkov-10/+10
2016-02-11[breaking-change] don't glob export ast::Visibility variantsOliver 'ker' Schneider-2/+2
2016-02-11[breaking-change] don't glob export ast::Mutablity variantsOliver 'ker' Schneider-8/+11
2016-02-11[breaking-change] don't glob export ast::Item_ variantsOliver 'ker' Schneider-8/+8
2016-02-11[breaking-change] don't pub export ast::Ty_ variantsOliver Schneider-3/+3
2016-02-11[breaking-change] don't glob export ast::{UintTy, IntTy} variantsOliver Schneider-11/+11
2016-02-11[breaking-change] don't glob export ast::Expr_ variantsOliver Schneider-4/+4
2016-02-11[breaking-change] don't glob export ast::ExplicitSelf_ variantsOliver Schneider-4/+4
2016-02-11[breaking-change] don't glob import/export syntax::abi enum variantsOliver Schneider-3/+2
2016-02-11[breaking-change] don't glob export ast::BlockCheckMode variantsOliver Schneider-2/+2
2016-02-11[breaking-change] don't glob export ast::BinOp_Oliver Schneider-4/+4
2015-12-21Auto merge of #30460 - Ms2ger:BindingMode, r=alexcrichtonbors-1/+1
2015-12-20Stop re-exporting the ast::BindingMode variants.Ms2ger-1/+1
2015-12-18Rollup merge of #30420 - petrochenkov:owned2, r=nrcManish Goregaokar-7/+5
Part of https://github.com/rust-lang/rust/pull/30095 not causing mysterious segfaults. r? @nrc
2015-12-18Deprecate name `OwnedSlice` and don't use itVadim Petrochenkov-7/+5
2015-12-17move error handling from libsyntax/diagnostics.rs to libsyntax/errors/*Nick Cameron-2/+2
Also split out emitters into their own module.
2015-12-15Move built-in syntax extensions to a separate crateSeo Sanghyeon-0/+1918