about summary refs log tree commit diff
path: root/src/libsyntax/ext/deriving
AgeCommit message (Collapse)AuthorLines
2015-01-06core: split into fmt::Show and fmt::StringSean McArthur-2/+2
fmt::Show is for debugging, and can and should be implemented for all public types. This trait is used with `{:?}` syntax. There still exists #[derive(Show)]. fmt::String is for types that faithfully be represented as a String. Because of this, there is no way to derive fmt::String, all implementations must be purposeful. It is used by the default format syntax, `{}`. This will break most instances of `{}`, since that now requires the type to impl fmt::String. In most cases, replacing `{}` with `{:?}` is the correct fix. Types that were being printed specifically for users should receive a fmt::String implementation to fix this. Part of #20013 [breaking-change]
2015-01-07Replace full slice notation with index callsNick Cameron-32/+32
2015-01-07Change `std::kinds` to `std::markers`; flatten `std::kinds::marker`Nick Cameron-1/+1
[breaking-change]
2015-01-06syntax/rustc: implement isize/usizeCorey Richardson-1/+1
2015-01-05rollup merge of #20482: kmcallister/macro-reformAlex Crichton-7/+9
Conflicts: src/libflate/lib.rs src/libstd/lib.rs src/libstd/macros.rs src/libsyntax/feature_gate.rs src/libsyntax/parse/parser.rs src/libsyntax/show_span.rs src/test/auxiliary/macro_crate_test.rs src/test/compile-fail/lint-stability.rs src/test/run-pass/intrinsics-math.rs src/test/run-pass/tcp-connect-timeouts.rs
2015-01-05rollup merge of #20568: huonw/ungate-AT-globsAlex Crichton-13/+7
These aren't in their final form, but are all aiming to be part of 1.0, so at the very least encouraging usage now to find the bugs is nice. Also, the widespread roll-out of associated types in the standard library indicates they're getting good, and it's lame to have to activate a feature in essentially every crate ever.
2015-01-05rollup merge of #20554: huonw/mut-patternAlex Crichton-1/+1
Conflicts: src/librustc_typeck/check/_match.rs
2015-01-05Modernize macro_rules! invocationsKeegan McAllister-7/+9
macro_rules! is like an item that defines a macro. Other items don't have a trailing semicolon, or use a paren-delimited body. If there's an argument for matching the invocation syntax, e.g. parentheses for an expr macro, then I think that applies more strongly to the *inner* delimiters on the LHS, wrapping the individual argument patterns.
2015-01-05syntax: remove remaining boxed closuresJorge Aparicio-33/+29
2015-01-05Ungate default type parameters.Huon Wilson-13/+7
These are in scope for 1.0, and this is good to e.g. find as many bugs as possible.
2015-01-04serialize: Use assoc types + less old_orphan_checkAlex Crichton-30/+32
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-05Change `&` pat to only work with &T, and `&mut` with &mut T.Huon Wilson-1/+1
This implements RFC 179 by making the pattern `&<pat>` require matching against a variable of type `&T`, and introducing the pattern `&mut <pat>` which only works with variables of type `&mut T`. The pattern `&mut x` currently parses as `&(mut x)` i.e. a pattern match through a `&T` or a `&mut T` that binds the variable `x` to have type `T` and to be mutable. This should be rewritten as follows, for example, for &mut x in slice.iter() { becomes for &x in slice.iter() { let mut x = x; Due to this, this is a [breaking-change] Closes #20496.
2015-01-05auto merge of #20285 : FlaPer87/rust/oibit-send-and-friends, r=nikomatsakisbors-0/+1
This commit introduces the syntax for negative implementations of traits as shown below: `impl !Trait for Type {}` cc #13231 Part of RFC rust-lang/rfcs#127 r? @nikomatsakis
2015-01-04Add syntax for negative implementations of traitsFlavio Percoco-0/+1
This commit introduces the syntax for negative implmenetations of traits as shown below: `impl !Trait for Type {}` cc #13231 Part of RFC #3
2015-01-03Remove deprecated functionalityAlex Crichton-104/+0
This removes a large array of deprecated functionality, regardless of how recently it was deprecated. The purpose of this commit is to clean out the standard libraries and compiler for the upcoming alpha release. Some notable compiler changes were to enable warnings for all now-deprecated command line arguments (previously the deprecated versions were silently accepted) as well as removing deriving(Zero) entirely (the trait was removed). The distribution no longer contains the libtime or libregex_macros crates. Both of these have been deprecated for some time and are available externally.
2015-01-03sed -i -s 's/#\[deriving(/#\[derive(/g' **/*.rsJorge Aparicio-13/+13
2015-01-03sed -i -s 's/\bmod}/self}/g' **/*.rsJorge Aparicio-1/+1
2015-01-03sed -i -s 's/\bmod,/self,/g' **/*.rsJorge Aparicio-1/+1
2015-01-02Accept `derive` instead of `deriving`Nick Cameron-22/+32
[breaking-change] `deriving is still accepted, but gives a deprecation warning
2014-12-31syntax: unbox closures used in let bindingsJorge Aparicio-4/+4
2014-12-31syntax: unbox closures used in function argumentsJorge Aparicio-2/+2
2014-12-29rollup merge of #20194: nick29581/dst-syntaxAlex Crichton-14/+15
Part of #19607. r? @nikomatsakis
2014-12-27syntax: change format_args! to produce fmt::Arguments instead of calling a ↵Eduard Burtescu-4/+6
function with them.
2014-12-26Keep track of the whole error chainFlavio Percoco-2/+5
2014-12-26Accept `?Sized` as well as `Sized?`Nick Cameron-14/+15
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 #20056: MrFloya/iter_renameAlex Crichton-1/+1
Conflicts: src/libcollections/bit.rs src/libcore/str.rs
2014-12-22rollup merge of #20033: alexcrichton/deprecate-serialiseAlex Crichton-17/+58
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-22Renaming of the Iter types as in RFC #344Florian Wilkens-1/+1
libcore: slice::Items -> slice::Iter, slice::MutItems -> slice::IterMut libcollections: *::Items -> *::Iter, *::MoveItems -> *::IntoIter, *::MutItems -> *::IterMut This is of course a [breaking-change].
2014-12-22serialize: Fully deprecate the libraryAlex Crichton-17/+58
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-36/+31
2014-12-20Add support for multiple region bounds in where clausesJared Roesch-1/+1
2014-12-20Add parser support for generalized where clausesJared Roesch-2/+8
Implement support in the parser for generalized where clauses, as well as the conversion of ast::WherePredicates to ty::Predicate in `collect.rs`.
2014-12-19libsyntax: use `#[deriving(Copy)]`Jorge Aparicio-2/+1
2014-12-17Test fixes and rebase conflictsAlex Crichton-1/+1
2014-12-17rollup merge of #19831: luqmana/deriving-whereAlex Crichton-5/+25
Fixes #19358.
2014-12-17rollup merge of #19755: alexcrichton/rust-serializeAlex Crichton-2/+22
The primary focus of Rust's stability story at 1.0 is the standard library. All other libraries distributed with the Rust compiler are planned to be #[unstable] and therfore only accessible on the nightly channel of Rust. One of the more widely used libraries today is libserialize, Rust's current solution for encoding and decoding types. The current libserialize library, however, has a number of drawbacks: * The API is not ready to be stabilize as-is and we will likely not have enough resources to stabilize the API for 1.0. * The library is not necessarily the speediest implementations with alternatives being developed out-of-tree (e.g. serde from erickt). * It is not clear how the API of Encodable/Decodable can evolve over time while maintaining backwards compatibility. One of the major pros to the current libserialize, however, is `deriving(Encodable, Decodable)` as short-hands for enabling serializing and deserializing a type. This is unambiguously useful functionality, so we cannot simply deprecate the in-tree libserialize in favor of an external crates.io implementation. For these reasons, this commit starts off a stability story for libserialize by following these steps: 1. The deriving(Encodable, Decodable) modes will be deprecated in favor of a renamed deriving(RustcEncodable, RustcDecodable). 2. The in-tree libserialize will be deprecated in favor of an external rustc-serialize crate shipped on crates.io. The contents of the crate will be the same for now (but they can evolve separately). 3. At 1.0 serialization will be performed through deriving(RustcEncodable, RustcDecodable) and the rustc-serialize crate. The expansions for each deriving mode will change from `::serialize::foo` to `::rustc_serialize::foo`. This story will require that the compiler freezes its implementation of `RustcEncodable` deriving for all of time, but this should be a fairly minimal maintenance burden. Otherwise the crate in crates.io must always maintain the exact definition of its traits, but the implementation of json, for example, can continue to evolve in the semver-sense. The major goal for this stabilization effort is to pave the road for a new official serialization crate which can replace the current one, solving many of its downsides in the process. We are not assuming that this will exist for 1.0, hence the above measures. Some possibilities for replacing libserialize include: * If plugins have a stable API, then any crate can provide a custom `deriving` mode (will require some compiler work). This means that any new serialization crate can provide its own `deriving` with its own backing implementation, entirely obsoleting the current libserialize and fully replacing it. * Erick is exploring the possibility of code generation via preprocessing Rust source files in the near term until plugins are stable. This strategy would provide the same ergonomic benefit that `deriving` does today in theory. So, in summary, the current libserialize crate is being deprecated in favor of the crates.io-based rustc-serialize crate where the `deriving` modes are appropriately renamed. This opens up space for a later implementation of serialization in a more official capacity while allowing alternative implementations to be explored in the meantime. Concretely speaking, this change adds support for the `RustcEncodable` and `RustcDecodable` deriving modes. After a snapshot is made warnings will be turned on for usage of `Encodable` and `Decodable` as well as deprecating the in-tree libserialize crate to encurage users to use rustc-serialize instead.
2014-12-15rollup merge of #19812: frewsxcv/expansion-include-enumBrian Anderson-0/+1
In preparation for [removing the `std::cmp::Ordering` reexport](https://github.com/rust-lang/rust/issues/19253), this needs to be done to prevent errors like: ``` note: in expansion of #[deriving] note: expansion site error: unresolved name `std::cmp::Equal` #[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Show)] ^~~ ```
2014-12-14Parse `unsafe impl` but don't do anything particularly interesting with the ↵Niko Matsakis-1/+2
results.
2014-12-14Rename FnStyle trait to Unsafety.Niko Matsakis-1/+1
2014-12-14libsyntax: Make deriving also respect where bounds.Luqman Aden-5/+25
2014-12-13rustc: Start the deprecation of libserializeAlex Crichton-2/+22
The primary focus of Rust's stability story at 1.0 is the standard library. All other libraries distributed with the Rust compiler are planned to be #[unstable] and therfore only accessible on the nightly channel of Rust. One of the more widely used libraries today is libserialize, Rust's current solution for encoding and decoding types. The current libserialize library, however, has a number of drawbacks: * The API is not ready to be stabilize as-is and we will likely not have enough resources to stabilize the API for 1.0. * The library is not necessarily the speediest implementations with alternatives being developed out-of-tree (e.g. serde from erickt). * It is not clear how the API of Encodable/Decodable can evolve over time while maintaining backwards compatibility. One of the major pros to the current libserialize, however, is `deriving(Encodable, Decodable)` as short-hands for enabling serializing and deserializing a type. This is unambiguously useful functionality, so we cannot simply deprecate the in-tree libserialize in favor of an external crates.io implementation. For these reasons, this commit starts off a stability story for libserialize by following these steps: 1. The deriving(Encodable, Decodable) modes will be deprecated in favor of a renamed deriving(RustcEncodable, RustcDecodable). 2. The in-tree libserialize will be deprecated in favor of an external rustc-serialize crate shipped on crates.io. The contents of the crate will be the same for now (but they can evolve separately). 3. At 1.0 serialization will be performed through deriving(RustcEncodable, RustcDecodable) and the rustc-serialize crate. The expansions for each deriving mode will change from `::serialize::foo` to `::rustc_serialize::foo`. This story will require that the compiler freezes its implementation of `RustcEncodable` deriving for all of time, but this should be a fairly minimal maintenance burden. Otherwise the crate in crates.io must always maintain the exact definition of its traits, but the implementation of json, for example, can continue to evolve in the semver-sense. The major goal for this stabilization effort is to pave the road for a new official serialization crate which can replace the current one, solving many of its downsides in the process. We are not assuming that this will exist for 1.0, hence the above measures. Some possibilities for replacing libserialize include: * If plugins have a stable API, then any crate can provide a custom `deriving` mode (will require some compiler work). This means that any new serialization crate can provide its own `deriving` with its own backing implementation, entirely obsoleting the current libserialize and fully replacing it. * Erick is exploring the possibility of code generation via preprocessing Rust source files in the near term until plugins are stable. This strategy would provide the same ergonomic benefit that `deriving` does today in theory. So, in summary, the current libserialize crate is being deprecated in favor of the crates.io-based rustc-serialize crate where the `deriving` modes are appropriately renamed. This opens up space for a later implementation of serialization in a more official capacity while allowing alternative implementations to be explored in the meantime. Concretely speaking, this change adds support for the `RustcEncodable` and `RustcDecodable` deriving modes. After a snapshot is made warnings will be turned on for usage of `Encodable` and `Decodable` as well as deprecating the in-tree libserialize crate to encurage users to use rustc-serialize instead.
2014-12-13libsyntax: use unboxed closuresJorge Aparicio-111/+150
2014-12-13libsyntax: fix falloutJorge Aparicio-1/+1
2014-12-13Expansion should explicitly include enumCorey Farwell-0/+1
In preparation for removing the std::cmp::Ordering reexport, this needs to be done to prevent errors like: ``` note: in expansion of #[deriving] note: expansion site error: unresolved name `std::cmp::Equal` \#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Show)] ^~~ ```
2014-12-12Add support for equality constraints on associated typesNick Cameron-3/+4
2014-12-09rollup merge of #19598: japaric/ordAlex Crichton-4/+25
cc #18755 r? @alexcrichton cc @bjz
2014-12-08librustc: Make `Copy` opt-in.Niko Matsakis-0/+2
This change makes the compiler no longer infer whether types (structures and enumerations) implement the `Copy` trait (and thus are implicitly copyable). Rather, you must implement `Copy` yourself via `impl Copy for MyType {}`. A new warning has been added, `missing_copy_implementations`, to warn you if a non-generic public type has been added that could have implemented `Copy` but didn't. For convenience, you may *temporarily* opt out of this behavior by using `#![feature(opt_out_copy)]`. Note though that this feature gate will never be accepted and will be removed by the time that 1.0 is released, so you should transition your code away from using it. This breaks code like: #[deriving(Show)] struct Point2D { x: int, y: int, } fn main() { let mypoint = Point2D { x: 1, y: 1, }; let otherpoint = mypoint; println!("{}{}", mypoint, otherpoint); } Change this code to: #[deriving(Show)] struct Point2D { x: int, y: int, } impl Copy for Point2D {} fn main() { let mypoint = Point2D { x: 1, y: 1, }; let otherpoint = mypoint; println!("{}{}", mypoint, otherpoint); } This is the backwards-incompatible part of #13231. Part of RFC #3. [breaking-change]
2014-12-07syntax: use UFCS in the expansion of `#[deriving(Ord)]`Jorge Aparicio-4/+25
cc #18755
2014-12-05Utilize fewer reexportsCorey Farwell-6/+7
In regards to: https://github.com/rust-lang/rust/issues/19253#issuecomment-64836729 This commit: * Changes the #deriving code so that it generates code that utilizes fewer reexports (in particur Option::* and Result::*), which is necessary to remove those reexports in the future * Changes other areas of the codebase so that fewer reexports are utilized
2014-11-26rollup merge of #19329: steveklabnik/doc_style_cleanup2Alex Crichton-17/+7