summary refs log tree commit diff
path: root/src/libsyntax_ext/deriving
AgeCommit message (Collapse)AuthorLines
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
2017-10-17Lifting Generics from MethodSig to TraitItem and ImplItem since we want to ↵Sunjay Varma-1/+2
support generics in each variant of TraitItem and ImplItem
2017-09-21only set non-ADT derive error once per attribute, not per traitZack M. Davis-4/+7
A slight eccentricity of this change is that now non-ADT-derive errors prevent derive-macro-not-found errors from surfacing (see changes to the gating-of-derive compile-fail tests). Resolves #43927.
2017-08-30Make fields of `Span` privateVadim Petrochenkov-11/+11
2017-08-17Rollup merge of #43891 - Fourchaux:master, r=steveklabnikCorey Farwell-1/+1
Fix typos & us spellings Fixing some typos and non en-US spellings. (Update of PR https://github.com/rust-lang/rust/pull/42812 )
2017-08-15use field init shorthand EVERYWHEREZack M. Davis-44/+44
Like #43008 (f668999), but _much more aggressive_.
2017-08-15Fix typos & us spellingsFourchaux-1/+1
2017-07-29Rollup merge of #43501 - topecongiro:span-to-whereclause, r=nrcMark Simulacrum-0/+1
Add Span to ast::WhereClause This PR adds `Span` field to `ast::WhereClause`. The motivation here is to make rustfmt's life easier when recovering comments before and after where clause. r? @nrc
2017-07-28syntax: Capture a `TokenStream` when parsing itemsAlex Crichton-0/+2
This is then later used by `proc_macro` to generate a new `proc_macro::TokenTree` which preserves span information. Unfortunately this isn't a bullet-proof approach as it doesn't handle the case when there's still other attributes on the item, especially inner attributes. Despite this the intention here is to solve the primary use case for procedural attributes, attached to functions as outer attributes, likely bare. In this situation we should be able to now yield a lossless stream of tokens to preserve span information.
2017-07-29Add Span to ast::WhereClausetopecongiro-0/+1
2017-07-05Merge remote-tracking branch 'origin/master' into proc_macro_apiAlex Crichton-8/+9
2017-06-28Auto merge of #42709 - stepancheg:discriminant-hash, r=jseyfriedbors-8/+9
deriv(Hash) for single-variant enum should not hash discriminant Fixes #39137
2017-06-26Simplify `hygiene::Mark` application, andJeffrey Seyfried-11/+4
remove variant `Token::SubstNt` in favor of `quoted::TokenTree::MetaVar`.
2017-06-23Removed as many "```ignore" as possible.kennytm-9/+15
Replaced by adding extra imports, adding hidden code (`# ...`), modifying examples to be runnable (sorry Homura), specifying non-Rust code, and converting to should_panic, no_run, or compile_fail. Remaining "```ignore"s received an explanation why they are being ignored.
2017-06-16deriv(Hash) for single-variant enum should not hash discriminantStepan Koltsov-8/+9
Fixes #39137
2017-05-25Hygienize lifetimes.Jeffrey Seyfried-6/+6
2017-05-25Hygienize `librustc_resolve`.Jeffrey Seyfried-1/+1
2017-05-12Remove some unused macros from the rust codebaseest31-6/+0
Removes unused macros from: * libcore * libcollections The last use of these two macros was removed in commit b64c9d56700e2c41207166fe8709711ff02488ff when the char_range_at_reverse function was been removed. * librustc_errors Their last use was removed by commits 2f2c3e178325dc1837badcd7573c2c0905fab979 and 11dc974a38fd533aa692cea213305056cd3a6902. * libsyntax_ext * librustc_trans Also, put the otry macro in back/msvc/mod.rs under the same cfg argument as the places that use it.
2017-04-24support `default impl` for specializationGianni Ciccarelli-0/+1
this commit implements the first step of the `default impl` feature: all items in a `default impl` are (implicitly) `default` and hence specializable. In order to test this feature I've copied all the tests provided for the `default` method implementation (in run-pass/specialization and compile-fail/specialization directories) and moved the `default` keyword from the item to the impl. See referenced issue for further info
2017-04-21Implementation of repr struct alignment RFC 1358.Cameron Hart-1/+1
The main changes around rustc::ty::Layout::struct and rustc_trans:adt: * Added primitive_align field which stores alignment before repr align * Always emit field padding when generating the LLVM struct fields * Added methods for adjusting field indexes from the layout index to the LLVM struct field index The main user of this information is rustc_trans::adt::struct_llfields which determines the LLVM fields to be used by LLVM, including padding fields.
2017-03-29Merge `ExpnId` and `SyntaxContext`.Jeffrey Seyfried-34/+20
2017-03-14Refactor `Attribute` to use `Path` and `TokenStream` instead of `MetaItem`.Jeffrey Seyfried-4/+6
2017-03-10Refactor out `ast::ItemKind::MacroDef`.Jeffrey Seyfried-1/+1
2017-02-25rustc_typeck: hook up collect and item/body check to on-demand.Eduard-Mihai Burtescu-1/+1
2017-02-12Allow using inert attributes from `proc_macro_derive`s with ↵Jeffrey Seyfried-5/+3
`#![feature(proc_macro)]`.
2017-02-05Move derive macro expansion into the MacroExpanderJosh Driver-244/+9
This removes the expand_derives function, and sprinkles the functionality throughout the Invocation Collector, Expander and Resolver.
2017-02-05Rename CustomDerive to ProcMacroDerive for macros 1.1Josh Driver-11/+11
2017-02-05Make builtin derives a SyntaxExtensionJosh Driver-21/+23
This allows builtin derives to be registered and resolved, just like other derive types.