about summary refs log tree commit diff
path: root/src/libsyntax_ext/deriving
AgeCommit message (Collapse)AuthorLines
2018-05-21Add E0665Guillaume Gomez-2/+13
2018-05-15Auto merge of #50011 - varkor:partialord-opt-ii, r=Manishearthbors-66/+101
Ensure derive(PartialOrd) is no longer accidentally exponential Previously, two comparison operations would be generated for each field, each of which could delegate to another derived PartialOrd. Now we use ordering and optional chaining to ensure each pair of fields is only compared once, addressing https://github.com/rust-lang/rust/issues/49650#issuecomment-379467572. Closes #49505. r? @Manishearth (sorry for changing it again so soon!) Close #50755
2018-05-02Remove Option from the return type of Attribute::name()Seiichi Uchida-6/+4
2018-04-26rustc_target: move in syntax::abi and flip dependency.Irina Popa-1/+1
2018-04-25Update comments to UFCS stylevarkor-11/+24
2018-04-25Use UFCSvarkor-11/+20
2018-04-25Fix handling of Nonevarkor-11/+11
2018-04-25Ensure derive(PartialOrd) is no longer accidentally exponentialvarkor-70/+83
Previously, two comparison operations would be generated for each field, each of which could delegate to another derived PartialOrd. Now we use ordering and optional chaining to ensure each pair of fields is only compared once.
2018-04-25Auto merge of #49986 - zofrex:better-derived-argument-names, r=Manishearthbors-32/+32
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-13/+13
2018-04-19Gensym remaining identifiersJames Sanderson-5/+5
2018-04-19Don't prepend deriving-generated attributes with _James Sanderson-3/+3
2018-04-15Provide better names for builtin deriving-generated attributesJames Sanderson-14/+14
2018-04-15Auto merge of #49881 - varkor:partialord-opt, r=Manishearthbors-91/+212
Fix derive(PartialOrd) and optimise final field operation ```rust // Before (`lt` on 2-field struct) self.f1 < other.f1 || (!(other.f1 < self.f1) && (self.f2 < other.f2 || (!(other.f2 < self.f2) && (false) )) ) // After self.f1 < other.f1 || (!(other.f1 < self.f1) && self.f2 < other.f2 ) // Before (`le` on 2-field struct) self.f1 < other.f1 || (!(other.f1 < self.f1) && (self.f2 < other.f2 || (!(other.f2 < self.f2) && (true) )) ) // After self.f1 < other.f1 || (self.f1 == other.f1 && self.f2 <= other.f2 ) ``` (The big diff is mainly because of a past faulty rustfmt application that I corrected 😒) Fixes #49650 and fixes #49505.
2018-04-12Abstract cs_eq for partial_eqvarkor-50/+27
2018-04-12Improve the comment for cs_fold1varkor-2/+9
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-11Add cs_fold1 for better derivesvarkor-17/+92
2018-04-11Fix derive(PartialOrd) implementationvarkor-6/+10
2018-04-11Implementation of `#[repr(packed(n))]` RFC 1399.Cameron Hart-3/+7
2018-04-06Rename `ast::Variant_::name` into `ident` + Fix rebaseVadim Petrochenkov-7/+5
2018-04-06Get rid of `SpannedIdent`Vadim Petrochenkov-6/+4
2018-04-06Rename `PathSegment::identifier` to `ident`Vadim Petrochenkov-2/+2
2018-04-06Use `Span` instead of `SyntaxContext` in `Ident`Vadim Petrochenkov-4/+3
2018-04-03expand macro invocations in `extern {}` blocksAustin Bonander-0/+1
2018-04-02Expand attribute macros on statements and expressions.Austin Bonander-1/+3
Retains the `stmt_expr_attributes` feature requirement for attributes on expressions. closes #41475 cc #38356
2018-03-22Optimise decode return expression for unit structsvarkor-5/+5
2018-03-22Use FunctionRetTy::Default rather than an explicit TyKind::Infer for ↵varkor-1/+1
lambda-building This prevents explicit `-> _` return type annotations for closures generated by `lambda`.
2018-03-17Rename `Span::empty` to `Span::shrink_to_lo`, add `Span::shrink_to_hi`Vadim Petrochenkov-2/+2
2018-03-11Fix hygene issue when deriving DebugPhlosioneer-1/+1
The code for several of the core traits doesn't use hygenic macros. This isn't a problem, except for the Debug trait, which is the only one that uses a variable, named "builder". Variables can't share names with unit structs, so attempting to [derive(Debug)] on any type while a unit struct with the name "builder" was in scope would result in an error. This commit just changes the name of the variable to "__debug_trait_builder", because I couldn't figure out how to get a list of all unit structs in-scope from within the derive expansion function. If someone wants to have a unit struct with the exact name "__debug_trait_builder", they'll just have to do it without a [derive(Debug)].
2018-03-02Replace Rc with Lrc for shared dataJohn KÃ¥re Alsaker-2/+2
2018-02-18Replace dummy spans with empty spansSeiichi Uchida-2/+2
2018-02-18Change ast::Visibility to Spanned typeSeiichi Uchida-2/+2
2018-02-01Auto merge of #47540 - Manishearth:suggestion, r=nrcbors-2/+14
Add approximate suggestions for rustfix This adds `span_approximate_suggestion()` that lets you emit a suggestion marked as "non-machine applicable" in the JSON output. UI users see no difference. This is for when rustc and clippy wish to emit suggestions which will make sense to the reader (e.g. they may have placeholders like `<type>`) but are not source-applicable, so that rustfix/etc can ignore these. fixes #39254
2018-01-29Add internal-only rustc_serialize_exclude_null attribute for making the ↵Manish Goregaokar-2/+14
field only exist in the json if the flag is passed
2018-01-29rustc: replace "lvalue" terminology with "place" in the code.Eduard-Mihai Burtescu-2/+2
2018-01-26Do not capture stderr in the compiler. Instead just panic silently for fatal ↵John Kåre Alsaker-3/+3
errors
2018-01-16Implement repr(transparent)Robin Kruppe-1/+3
2018-01-07Rename ReprExtern to ReprC, and similarily rename a few other fields and ↵Robin Kruppe-1/+1
locals that mentioned "extern repr"
2018-01-04rustc: use {U,I}size instead of {U,I}s shorthands.Eduard-Mihai Burtescu-2/+2
2017-12-22Auto merge of #46732 - estebank:silence-recovered-blocks, r=petrochenkovbors-0/+1
Do not emit type errors on recovered blocks When a parse error occurs on a block, the parser will recover and create a block with the statements collected until that point. Now a flag stating that a recovery has been performed in this block is propagated so that the type checker knows that the type of the block (which will be identified as `()`) shouldn't be checked against the expectation to reduce the amount of irrelevant diagnostic errors shown to the user. Fix #44579.
2017-12-21Do not emit type errors on recovered blocksEsteban Küber-0/+1
When a parse error occurs on a block, the parser will recover and create a block with the statements collected until that point. Now a flag stating that a recovery has been performed in this block is propagated so that the type checker knows that the type of the block (which will be identified as `()`) shouldn't be checked against the expectation to reduce the amount of irrelevant diagnostic errors shown to the user.
2017-12-21Add GenericParam, refactor Generics in ast, hir, rustdocJonas Platte-99/+138
The Generics now contain one Vec of an enum for the generic parameters, rather than two separate Vec's for lifetime and type parameters. Additionally, places that previously used Vec<LifetimeDef> now use Vec<GenericParam> instead.
2017-12-09Use hygiene to access the injected crate (`core` or `std`) from builtin macros.Jeffrey Seyfried-86/+76
2017-12-01Auto merge of #45997 - estebank:pub-ident, r=nikomatsakisbors-1/+7
Account for missing keyword in fn/struct definition Fix #38911.
2017-11-26limit packed copy-out to non-generic Copy structsAriel Ben-Yehuda-7/+19
2017-11-26fix #[derive] implementation for repr(packed) structsAriel Ben-Yehuda-16/+64
Fix the derive implementation for repr(packed) structs to move the fields out instead of calling functions on references to each subfield. That's it, `#[derive(PartialEq)]` on a packed struct now does: ```Rust fn eq(&self, other: &Self) { let field_0 = self.0; let other_field_0 = other.0; &field_0 == &other_field_0 } ``` Instead of ```Rust fn eq(&self, other: &Self) { let ref field_0 = self.0; let ref other_field_0 = other.0; &*field_0 == &*other_field_0 } ``` Taking (unaligned) references to each subfield is undefined, unsound and is an error with MIR effectck, so it had to be prevented. This causes a borrowck error when a `repr(packed)` struct has a non-Copy field (and therefore is a [breaking-change]), but I don't see a sound way to avoid that error.
2017-11-25Fix proc_macro output with struct parse errorEsteban Küber-1/+7