summary refs log tree commit diff
path: root/src/libsyntax_ext/deriving/cmp
AgeCommit message (Collapse)AuthorLines
2016-07-19Run rustfmt on libsyntax_ext/deriving folderSrinivas Reddy Thatiparthy-264/+255
2016-06-26Rollup merge of #34436 - jseyfried:no_block_expr, r=eddybJeffrey Seyfried-1/+1
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-23Remove field `expr` of `ast::Block`Jeffrey Seyfried-1/+1
2016-06-23Move errors from libsyntax to its own crateJonathan Turner-4/+4
2016-05-12Improve derived implementations for enums with lots of fieldless variantsBjörn Steinbrink-0/+5
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-03-18Auto merge of #31977 - bluss:partial-eq-save, r=brsonbors-11/+25
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-17Re-add double underscores in derive (fixes #32292)Manish Goregaokar-8/+8
2016-03-14derive: improve hygiene for type parameters (see #2810)Alex Burka-1/+1
When deriving Hash, RustcEncodable and RustcDecodable, the syntax extension needs a type parameter to use in the inner method. They used to use __H, __S and __D respectively. If this conflicts with a type parameter already declared for the item, bad times result (see the test). There is no hygiene for type parameters, but this commit introduces a better heuristic by concatenating the names of all extant type parameters (and prepending __H).
2016-03-14derive: remove most __ strings FIXME(#2810)Alex Burka-8/+8
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-14fix FIXME(#6449) in #[derive(PartialOrd, Ord)]Alex Burka-55/+48
This replaces some `if`s with `match`es. This was originally not possible because using a global path in a match statement caused a "non-constant path in constant expr" ICE. The issue is long since closed, though you still hit it (as an error now, not an ICE) if you try to generate match patterns using pat_lit(expr_path). But it works when constructing the patterns more carefully.
2016-03-01derive: Emit only PartialOrd::partial_cmp for simple enumsUlrik Sverdrup-24/+17
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-29derive: Skip PartialEq::ne for any zero-field enum or structUlrik Sverdrup-17/+15
Also detect unit structs and enums with zero field struct variants.
2016-02-29derive: Avoid emitting PartialEq::ne for c-like enumsUlrik Sverdrup-5/+28
`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-02-11[breaking-change] don't glob export ast::BinOp_Oliver Schneider-14/+12
2016-02-11[breaking-change] don't glob export ast::UnOp variantsOliver Schneider-1/+1
2015-12-15Move built-in syntax extensions to a separate crateSeo Sanghyeon-0/+539