summary refs log tree commit diff
path: root/src/libsyntax_ext/deriving/cmp
AgeCommit message (Collapse)AuthorLines
2018-04-25Auto merge of #49986 - zofrex:better-derived-argument-names, r=Manishearthbors-12/+12
Provide better names for builtin deriving-generated attributes First attempt at fixing #49967 Not in love with any choices here, don't be shy if you aren't happy with anything :) I've tested that this produces nicer names in documentation, and that it no longer has issues conflicting with constants with the same name. (I guess we _could_ make a test for that... unsure if that would be valuable) In all cases I took the names from the methods as declared in the relevant trait. In some cases I had to prepend the names with _ otherwise there were errors about un-used variables. I'm uneasy with the inconsistency... do they all need to be like that? Is there a way to generate an alternate impl or use a different name (`_`?) in the cases where the arguments are not used? Lastly the gensym addition to Ident I implemented largely as suggested, but I want to point out it's a little circuitous (at least, as far as I understand it). `cx.ident_of(name)` is just `Ident::from_str`, so we create an Ident then another Ident from it. `Ident::with_empty_ctxt(Symbol::gensym(string))` may or may not be equivalent, I don't know if it's important to intern it _then_ gensym it. It seems like either we could use that, or if we do want a new method to make this convenient, it could be on Ident instead (`from_str_gensymed`?)
2018-04-19Fix some of the __names in the commentsJames Sanderson-6/+6
2018-04-19Gensym remaining identifiersJames Sanderson-2/+2
2018-04-19Don't prepend deriving-generated attributes with _James Sanderson-1/+1
2018-04-15Provide better names for builtin deriving-generated attributesJames Sanderson-4/+4
2018-04-12Abstract cs_eq for partial_eqvarkor-50/+27
2018-04-12Update partial_ord codegen summaryvarkor-3/+10
2018-04-11Remove redundant operation in derive[PartialEq]varkor-28/+58
2018-04-11Optimise the last field operations in derive[PartialOrd]varkor-51/+72
2018-04-11Fix derive(PartialOrd) implementationvarkor-6/+10
2017-12-09Use hygiene to access the injected crate (`core` or `std`) from builtin macros.Jeffrey Seyfried-8/+12
2017-08-30Make fields of `Span` privateVadim Petrochenkov-1/+1
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-7/+7
Like #43008 (f668999), but _much more aggressive_.
2017-03-29Merge `ExpnId` and `SyntaxContext`.Jeffrey Seyfried-1/+1
2016-11-20Move `syntax::util::interner` -> `syntax::symbol`, cleanup.Jeffrey Seyfried-11/+11
2016-11-20Refactor `MetaItemKind` to use `Name`s instead of `InternedString`s.Jeffrey Seyfried-11/+11
2016-10-31Changed most vec! invocations to use square bracesiirelu-4/+4
Most of the Rust community agrees that the vec! macro is clearer when called using square brackets [] instead of regular brackets (). Most of these ocurrences are from before macros allowed using different types of brackets. There is one left unchanged in a pretty-print test, as the pretty printer still wants it to have regular brackets.
2016-09-10Improve `Eq` derivingVadim Petrochenkov-19/+36
2016-08-30Future proof `libsyntax_ext` for `union`.Jeffrey Seyfried-0/+4
2016-08-28Rollup merge of #35850 - SergioBenitez:master, r=nrcJeffrey Seyfried-1/+1
Implement RFC#1559: allow all literals in attributes Implemented rust-lang/rfcs#1559, tracked by #34981.
2016-08-25Implement RFC#1559: allow all literals in attributes.Sergio Benitez-1/+1
2016-08-18Split `AstBuilder::pat_enum` into `pat_tuple_struct` and `pat_path`Vadim Petrochenkov-2/+2
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