about summary refs log tree commit diff
path: root/src/libsyntax/ext/deriving/encodable.rs
AgeCommit message (Collapse)AuthorLines
2015-12-15Move built-in syntax extensions to a separate crateSeo Sanghyeon-288/+0
2015-08-29Allow #[derive()] to generate unsafe trait implsMichael Layzell-0/+1
2015-08-03syntax: Implement #![no_core]Alex Crichton-2/+3
This commit is an implementation of [RFC 1184][rfc] which tweaks the behavior of the `#![no_std]` attribute and adds a new `#![no_core]` attribute. The `#![no_std]` attribute now injects `extern crate core` at the top of the crate as well as the libcore prelude into all modules (in the same manner as the standard library's prelude). The `#![no_core]` attribute disables both std and core injection. [rfc]: https://github.com/rust-lang/rfcs/pull/1184
2015-07-28remove `get_ident` and `get_name`, make `as_str` soundOliver Schneider-4/+4
2015-05-22Let MultiItemDecorator take `&Annotatable` (fixes #25683)Manish Goregaokar-4/+4
2015-05-17Allow #[derive()] to generate unsafe methodsManish Goregaokar-0/+1
2015-05-12RebasingNick Cameron-1/+1
2015-04-30WIP refactor expansion of decorators and move derive to MultiDecoratorNick Cameron-8/+8
2015-04-21syntax: remove #![feature(box_syntax, box_patterns)]Erick Tryzelaar-3/+3
2015-04-18Auto merge of #23985 - erickt:derive-cleanup, r=ericktbors-19/+16
This extracts some of the minor cleanup patches from #23905.
2015-04-15syntax: Change deriving methods to take a `&mut FnMut(P<Item>)`Erick Tryzelaar-19/+16
This allows #[derive(...)]` to create more than one impl
2015-04-14Negative case of `len()` -> `is_empty()`Tamir Duberstein-1/+1
`s/([^\(\s]+\.)len\(\) [(?:!=)>] 0/!$1is_empty()/g`
2015-03-20don't use Result::ok just to be able to use unwrap/unwrap_orOliver Schneider-3/+3
2015-03-03Switched to Box::new in many places.Felix S. Klock II-2/+2
Many of the modifications putting in `Box::new` calls also include a pointer to Issue 22405, which tracks going back to `box <expr>` if possible in the future. (Still tried to use `Box<_>` where it sufficed; thus some tests still have `box_syntax` enabled, as they use a mix of `box` and `Box::new`.) Precursor for overloaded-`box` and placement-`in`; see Issue 22181.
2015-03-03Accommodate simple cases of arith-overflow in `rustc` related crates.Felix S. Klock II-1/+1
2015-03-03Add `core::num::wrapping` and fix overflow errors.James Miller-19/+18
Many of the core rust libraries have places that rely on integer wrapping behaviour. These places have been altered to use the wrapping_* methods: * core::hash::sip - A number of macros * core::str - The `maximal_suffix` method in `TwoWaySearcher` * rustc::util::nodemap - Implementation of FnvHash * rustc_back::sha2 - A number of macros and other places * rand::isaac - Isaac64Rng, changed to use the Wrapping helper type Some places had "benign" underflow. This is when underflow or overflow occurs, but the unspecified value is not used due to other conditions. * collections::bit::Bitv - underflow when `self.nbits` is zero. * collections::hash::{map,table} - Underflow when searching an empty table. Did cause undefined behaviour in this case due to an out-of-bounds ptr::offset based on the underflowed index. However the resulting pointers would never be read from. * syntax::ext::deriving::encodable - Underflow when calculating the index of the last field in a variant with no fields. These cases were altered to avoid the underflow, often by moving the underflowing operation to a place where underflow could not happen. There was one case that relied on the fact that unsigned arithmetic and two's complement arithmetic are identical with wrapping semantics. This was changed to use the wrapping_* methods. Finally, the calculation of variant discriminants could overflow if the preceeding discriminant was `U64_MAX`. The logic in `rustc::middle::ty` for this was altered to avoid the overflow completely, while the remaining places were changed to use wrapping methods. This is because `rustc::middle::ty::enum_variants` now throws an error when the calculated discriminant value overflows a `u64`. This behaviour can be triggered by the following code: ``` enum Foo { A = U64_MAX, B } ``` This commit also implements the remaining integer operators for Wrapped<T>.
2015-02-20Remove remaining uses of `[]`. This time I tried to use deref coercions ↵Niko Matsakis-1/+1
where possible.
2015-02-07Don't use std:: paths in syntax extensions when compiling a #![no_std] crateKeegan McAllister-1/+7
Fixes #16803. Fixes #14342. Fixes half of #21827 -- slice syntax is still broken.
2015-02-07Use path helper macros in derivingKeegan McAllister-1/+1
2015-01-25Associated types support for deriving::generic::TraitDefDzmitry Malyshau-1/+3
2015-01-21rollup merge of #21340: pshc/libsyntax-no-more-intsAlex Crichton-7/+7
Collaboration with @rylev! I didn't change `int` in the [quasi-quoter](https://github.com/pshc/rust/blob/99ae1a30f3ca28c0f7e431620560d30e44627124/src/libsyntax/ext/quote.rs#L328), because I'm not sure if there will be adverse effects. Addresses #21095.
2015-01-17libsyntax: rename functions from uint to usizePaul Collier-6/+6
2015-01-17libsyntax: uint types to usizePaul Collier-1/+1
2015-01-17s/deriving/derives in Comments/DocsEarl St Sauver-1/+1
There are a large number of places that incorrectly refer to deriving in comments, instead of derives. Fixes #20984
2015-01-07use slicing sugarJorge Aparicio-1/+1
2015-01-07Replace full slice notation with index callsNick Cameron-1/+1
2015-01-05syntax: remove remaining boxed closuresJorge Aparicio-1/+1
2015-01-04serialize: Use assoc types + less old_orphan_checkAlex Crichton-16/+16
This commit moves the libserialize crate (and will force the hand of the rustc-serialize crate) to not require the `old_orphan_check` feature gate as well as using associated types wherever possible. Concretely, the following changes were made: * The error type of `Encoder` and `Decoder` is now an associated type, meaning that these traits have no type parameters. * The `Encoder` and `Decoder` type parameters on the `Encodable` and `Decodable` traits have moved to the corresponding method of the trait. This movement alleviates the dependency on `old_orphan_check` but implies that implementations can no longer be specialized for the type of encoder/decoder being implemented. Due to the trait definitions changing, this is a: [breaking-change]
2015-01-03sed -i -s 's/#\[deriving(/#\[derive(/g' **/*.rsJorge Aparicio-4/+4
2014-12-26Accept `?Sized` as well as `Sized?`Nick Cameron-2/+2
Includes a bit of refactoring to store `?` unbounds as bounds with a modifier, rather than in their own world, in the AST at least.
2014-12-22rollup merge of #20033: alexcrichton/deprecate-serialiseAlex Crichton-2/+23
This commit completes the deprecation story for the in-tree serialization library. The compiler will now emit a warning whenever it encounters `deriving(Encodable)` or `deriving(Decodable)`, and the library itself is now marked `#[unstable]` for when feature staging is enabled. All users of serialization can migrate to the `rustc-serialize` crate on crates.io which provides the exact same interface as the libserialize library in-tree. The new deriving modes are named `RustcEncodable` and `RustcDecodable` and require `extern crate "rustc-serialize" as rustc_serialize` at the crate root in order to expand correctly. To migrate all crates, add the following to your `Cargo.toml`: [dependencies] rustc-serialize = "0.1.1" And then add the following to your crate root: extern crate "rustc-serialize" as rustc_serialize; Finally, rename `Encodable` and `Decodable` deriving modes to `RustcEncodable` and `RustcDecodable`. [breaking-change]
2014-12-22serialize: Fully deprecate the libraryAlex Crichton-2/+23
This commit completes the deprecation story for the in-tree serialization library. The compiler will now emit a warning whenever it encounters `deriving(Encodable)` or `deriving(Decodable)`, and the library itself is now marked `#[unstable]` for when feature staging is enabled. All users of serialization can migrate to the `rustc-serialize` crate on crates.io which provides the exact same interface as the libserialize library in-tree. The new deriving modes are named `RustcEncodable` and `RustcDecodable` and require `extern crate "rustc-serialize" as rustc_serialize` at the crate root in order to expand correctly. To migrate all crates, add the following to your `Cargo.toml`: [dependencies] rustc-serialize = "0.1.1" And then add the following to your crate root: extern crate "rustc-serialize" as rustc_serialize; Finally, rename `Encodable` and `Decodable` deriving modes to `RustcEncodable` and `RustcDecodable`. [breaking-change]
2014-12-21Fallout of std::str stabilizationAlex Crichton-2/+1
2014-12-13libsyntax: use unboxed closuresJorge Aparicio-5/+7
2014-11-16Complete the removal of ty_nil, ast::LitNil, ast::TyBot and ast::TyUniqJakub Bukaj-3/+3
[breaking-change] This will break any uses of macros that assumed () being a valid literal.
2014-11-15Improve examples for syntax::ext::deriving::encodableBarosl Lee-31/+40
The examples in the documentation for syntax::ext::deriving::encodable are outdated, and do not work. To fix this, the following changes are applied: - emit_field() -> emit_struct_field() - read_field() -> read_struct_field() - Use Result to report errors - Add the mut keyword to Encoder/Decoder - Prefer Encodable::encode() to emit_uint
2014-09-14syntax: fix fallout from using ptr::P.Eduard Burtescu-13/+14
2014-08-01Fix misspelled comments.Joseph Crail-1/+1
2014-07-11Removed dead structures after changes to PartialOrd/Ord derivings.Felix S. Klock II-1/+0
Remove the `NonMatchesExplode` variant now that no deriving impl uses it. Removed `EnumNonMatching` entirely. Remove now irrelevant `on_matching` field and `HandleNonMatchingEnums` type. Removed unused `EnumNonMatchFunc` type def. Drive-by: revise `EnumNonMatchCollapsedFunc` doc. Made all calls to `expand_enum_method_body` go directly to `build_enum_match_tuple`. Alpha-rename `enum_nonmatch_g` back to `enum_nonmatch_f` to reduce overall diff noise. Inline sole call of `some_ordering_const`. Inline sole call of `ordering_const`. Removed a bunch of code that became dead after the above changes.
2014-07-11Revise the `const_nonmatching` flag with more info about author's intent.Felix S. Klock II-1/+1
In particular, I want authors of deriving modes to understand what they are opting into (namely quadratic code size or worse) when they select NonMatchesExplode.
2014-07-09syntax: doc comments all the thingsCorey Richardson-73/+70
2014-07-08Change DST syntax: type -> Sized?Nick Cameron-3/+2
closes #13367 [breaking-change] Use `Sized?` to indicate a dynamically sized type parameter or trait (used to be `type`). E.g., ``` trait Tr for Sized? {} fn foo<Sized? X: Share>(x: X) {} ```
2014-06-11syntax: Move the AST from @T to Gc<T>Alex Crichton-4/+6
2014-06-02auto merge of #14509 : klutzy/rust/de-pub-use-glob, r=alexcrichtonbors-0/+1
This patchset removes `pub use` usage except for `test/`. cc #11870
2014-06-02syntax: Remove use of `pub use` globsklutzy-0/+1
`quote_expr!` now injects two more (priv) `use` globs. This may cause extra unused_imports warning.
2014-06-02Fix deriving Encodable trait for unit structsPiotr Jawniak-0/+8
Closes #14021
2014-05-27std: Remove String's to_ownedRicho Healey-3/+3
2014-05-22libstd: Remove `~str` from all `libstd` modules except `fmt` and `str`.Patrick Walton-1/+2
2014-05-02Replace most ~exprs with 'box'. #11779Brian Anderson-6/+6
2014-04-23auto merge of #13704 : edwardw/rust/doc-hidden, r=alexcrichtonbors-1/+1
Closes #13698