about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2014-12-20Print a friendly error for the if-let construct without an else blockBarosl Lee-2/+4
Fixes #19991.
2014-12-19auto merge of #19463 : kali/rust/master, r=alexcrichtonbors-2/+1
parse_ty() no longer takes a boolean parameter. quote_ty! implementation has not yet been modified accordingly. As a matter of fact, quote_ty! was not covered by tests. One test (called qquotes) references it, but it has been ignored for nearly one year and now need heavy refactoring. quote_token.rs seemed like a good place to test quote_ty!, many other quote_*! macros were asserted there.
2014-12-19Register new snapshotsAlex Crichton-60/+0
This does not yet start the movement to rustc-serialize. That detail is left to a future PR.
2014-12-19libsyntax: use `#[deriving(Copy)]`Jorge Aparicio-216/+77
2014-12-19ack parser.parse_ty change in quote_ty! (+ test)Mathieu Poumeyrol-2/+1
2014-12-19Make all predicates higher-ranked, not just trait references.Niko Matsakis-3/+16
2014-12-18syntax/ast_util: add `is_by_value_unop()`Jorge Aparicio-1/+9
2014-12-18librustc: Always parse `macro!()`/`macro![]` as expressions if notPatrick Walton-190/+294
followed by a semicolon. This allows code like `vec![1i, 2, 3].len();` to work. This breaks code that uses macros as statements without putting semicolons after them, such as: fn main() { ... assert!(a == b) assert!(c == d) println(...); } It also breaks code that uses macros as items without semicolons: local_data_key!(foo) fn main() { println("hello world") } Add semicolons to fix this code. Those two examples can be fixed as follows: fn main() { ... assert!(a == b); assert!(c == d); println(...); } local_data_key!(foo); fn main() { println("hello world") } RFC #378. Closes #18635. [breaking-change]
2014-12-17Test fixes and rebase conflictsAlex Crichton-1/+1
2014-12-17rollup merge of #19918: pnkfelix/ast-refactor-make-place-in-exprbox-an-optionAlex Crichton-5/+8
This is to allow us to migrate away from UnUniq in a followup commit, and thus unify the code paths related to all forms of `box`.
2014-12-17rollup merge of #19880: sanxiyn/assoc-resolve-lifetimeAlex Crichton-8/+11
Fix #18790. Fix #19862.
2014-12-17rollup merge of #19831: luqmana/deriving-whereAlex Crichton-5/+26
Fixes #19358.
2014-12-17rollup merge of #19821: bkoropoff/issue-19791Alex Crichton-0/+5
Normalize late-bound regions in bare functions, stack closures, and traits and include them in the generated hash. Closes #19791 r? @nikomatsakis (does my normalization make sense?) cc @alexcrichton
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-16AST refactor: make the place in ExprBox an option.Felix S. Klock II-5/+8
This is to allow us to migrate away from UnUniq in a followup commit, and thus unify the code paths related to all forms of `box`.
2014-12-16auto merge of #19777 : nikomatsakis/rust/warn-on-shadowing, r=acrichtobors-4/+4
per rfc 459 cc https://github.com/rust-lang/rust/issues/19390 One question is: should we start by warning, and only switch to hard error later? I think we discussed something like this in the meeting. r? @alexcrichton
2014-12-15Fix pretty printing of HRTB syntaxBrian Koropoff-0/+5
2014-12-15auto merge of #19448 : japaric/rust/binops-by-value, r=nikomatsakisbors-0/+70
- The following operator traits now take their arguments by value: `Add`, `Sub`, `Mul`, `Div`, `Rem`, `BitAnd`, `BitOr`, `BitXor`, `Shl`, `Shr`. This breaks all existing implementations of these traits. - The binary operation `a OP b` now "desugars" to `OpTrait::op_method(a, b)` and consumes both arguments. - `String` and `Vec` addition have been changed to reuse the LHS owned value, and to avoid internal cloning. Only the following asymmetric operations are available: `String + &str` and `Vec<T> + &[T]`, which are now a short-hand for the "append" operation. [breaking-change] --- This passes `make check` locally. I haven't touch the unary operators in this PR, but converting them to by value should be very similar to this PR. I can work on them after this gets the thumbs up. @nikomatsakis r? the compiler changes @aturon r? the library changes. I think the only controversial bit is the semantic change of the `Vec`/`String` `Add` implementation. cc #19148
2014-12-15Remove all shadowed lifetimes.Niko Matsakis-4/+4
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-15Resolve lifetimes in associated typesSeo Sanghyeon-8/+11
2014-12-15auto merge of #19778 : aochagavia/rust/ice, r=alexcrichtonbors-9/+10
Fixes #19734
2014-12-15auto merge of #19742 : vhbit/rust/copy-for-bitflags, r=alexcrichtonbors-1/+0
2014-12-14Parse `unsafe impl` but don't do anything particularly interesting with the ↵Niko Matsakis-16/+40
results.
2014-12-14Parse `unsafe trait` but do not do anything with it beyond parsing and ↵Niko Matsakis-13/+35
integrating into rustdoc etc.
2014-12-14Rename FnStyle trait to Unsafety.Niko Matsakis-93/+78
2014-12-14Remove `proc` types/expressions from the parser, compiler, andNiko Matsakis-141/+34
language. Recommend `move||` instead.
2014-12-14Adjust feature gates to allow for parenthetical notation to be usedNiko Matsakis-13/+0
with the fn traits
2014-12-14libsyntax: Output where clauses in pretty printer for structs.Luqman Aden-0/+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: convert `LockstepIterSize` binops to by valueJorge Aparicio-0/+24
2014-12-13libsyntax: convert `BytePos`/`CharPos` binops to by valueJorge Aparicio-0/+36
2014-12-13syntax/ast_util: add `is_by_value_binop()`Jorge Aparicio-0/+10
2014-12-13libsyntax: use tuple indexingJorge Aparicio-10/+10
2014-12-13libsyntax: use unboxed closuresJorge Aparicio-245/+377
2014-12-13libsyntax: fix falloutJorge Aparicio-2/+3
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-13Add `Copy` to bitflags-generated structuresValerii Hiora-1/+0
2014-12-12Fix #19734 (ICE)Adolfo Ochagavía-9/+10
2014-12-12Add support for equality constraints on associated typesNick Cameron-65/+290
2014-12-11Register new snapshotsAlex Crichton-13/+6
2014-12-09rollup merge of #19598: japaric/ordAlex Crichton-4/+25
cc #18755 r? @alexcrichton cc @bjz
2014-12-09auto merge of #19644 : pcwalton/rust/oibit3, r=nikomatsakisbors-7/+182
2014-12-08Revert "Register new snapshots"Alex Crichton-3/+3
This reverts commit 9b443289cf32cbcff16768614340f0c844675340.
2014-12-08Add a feature opt `opt_out_copy` that allows people to revert to the olderNiko Matsakis-0/+6
behavior temporarily. This feature will eventually transition to REJECTED.
2014-12-08librustc: Make `Copy` opt-in.Niko Matsakis-7/+176
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-08auto merge of #19560 : sfackler/rust/should-fail-reason, r=alexcrichtonbors-4/+30
The test harness will make sure that the panic message contains the specified string. This is useful to help make `#[should_fail]` tests a bit less brittle by decreasing the chance that the test isn't "accidentally" passing due to a panic occurring earlier than expected. The behavior is in some ways similar to JUnit's `expected` feature: `@Test(expected=NullPointerException.class)`. Without the message assertion, this test would pass even though it's not actually reaching the intended part of the code: ```rust #[test] #[should_fail(message = "out of bounds")] fn test_oob_array_access() { let idx: uint = from_str("13o").unwrap(); // oops, this will panic [1i32, 2, 3][idx]; } ```
2014-12-08core: make the public fmt API completely safe.Eduard Burtescu-25/+8
2014-12-08auto merge of #19378 : japaric/rust/no-as-slice, r=alexcrichtonbors-45/+43
Now that we have an overloaded comparison (`==`) operator, and that `Vec`/`String` deref to `[T]`/`str` on method calls, many `as_slice()`/`as_mut_slice()`/`to_string()` calls have become redundant. This patch removes them. These were the most common patterns: - `assert_eq(test_output.as_slice(), "ground truth")` -> `assert_eq(test_output, "ground truth")` - `assert_eq(test_output, "ground truth".to_string())` -> `assert_eq(test_output, "ground truth")` - `vec.as_mut_slice().sort()` -> `vec.sort()` - `vec.as_slice().slice(from, to)` -> `vec.slice(from_to)` --- Note that e.g. `a_string.push_str(b_string.as_slice())` has been left untouched in this PR, since we first need to settle down whether we want to favor the `&*b_string` or the `b_string[]` notation. This is rebased on top of #19167 cc @alexcrichton @aturon