about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
AgeCommit message (Collapse)AuthorLines
2014-10-18Parser: Fix spans of explicit self arg identsPhil Dawes-2/+8
2014-10-17auto merge of #16855 : P1start/rust/help-messages, r=brsonbors-0/+3
This adds ‘help’ diagnostic messages to rustc. This is used for anything that provides help to the user, particularly the `--explain` messages that were previously integrated into the relevant error message. They look like this: ``` match.rs:10:13: 10:14 error: unreachable pattern [E0001] match.rs:10 1 => {}, ^ match.rs:3:1: 3:38 note: in expansion of foo! match.rs:7:5: 20:2 note: expansion site match.rs:10:13: 10:14 help: pass `--explain E0001` to see a detailed explanation ``` (`help` is coloured cyan.) Adding these errors on a separate line stops the lines from being too long, as discussed in #16619.
2014-10-16libsyntax: Remove all uses of {:?}.Luqman Aden-5/+5
2014-10-13auto merge of #17733 : jgallagher/rust/while-let, r=alexcrichtonbors-1/+17
This is *heavily* based on `if let` (#17634) by @jakub- and @kballard This should close #17687
2014-10-13auto merge of #17757 : gamazeps/rust/issue17709, r=alexcrichtonbors-5/+14
I did not put the crate name in the error note, if that's necessary I'll look into it. Closes #17709
2014-10-11Remove `virtual` structs from the languageJakub Wieczorek-23/+7
2014-10-10Teach libsyntax about `while let`John Gallagher-1/+17
2014-10-09syntax: Convert statics to constantsAlex Crichton-4/+4
2014-10-09rustc: Add `const` globals to the languageAlex Crichton-5/+9
This change is an implementation of [RFC 69][rfc] which adds a third kind of global to the language, `const`. This global is most similar to what the old `static` was, and if you're unsure about what to use then you should use a `const`. The semantics of these three kinds of globals are: * A `const` does not represent a memory location, but only a value. Constants are translated as rvalues, which means that their values are directly inlined at usage location (similar to a #define in C/C++). Constant values are, well, constant, and can not be modified. Any "modification" is actually a modification to a local value on the stack rather than the actual constant itself. Almost all values are allowed inside constants, whether they have interior mutability or not. There are a few minor restrictions listed in the RFC, but they should in general not come up too often. * A `static` now always represents a memory location (unconditionally). Any references to the same `static` are actually a reference to the same memory location. Only values whose types ascribe to `Sync` are allowed in a `static`. This restriction is in place because many threads may access a `static` concurrently. Lifting this restriction (and allowing unsafe access) is a future extension not implemented at this time. * A `static mut` continues to always represent a memory location. All references to a `static mut` continue to be `unsafe`. This is a large breaking change, and many programs will need to be updated accordingly. A summary of the breaking changes is: * Statics may no longer be used in patterns. Statics now always represent a memory location, which can sometimes be modified. To fix code, repurpose the matched-on-`static` to a `const`. static FOO: uint = 4; match n { FOO => { /* ... */ } _ => { /* ... */ } } change this code to: const FOO: uint = 4; match n { FOO => { /* ... */ } _ => { /* ... */ } } * Statics may no longer refer to other statics by value. Due to statics being able to change at runtime, allowing them to reference one another could possibly lead to confusing semantics. If you are in this situation, use a constant initializer instead. Note, however, that statics may reference other statics by address, however. * Statics may no longer be used in constant expressions, such as array lengths. This is due to the same restrictions as listed above. Use a `const` instead. [breaking-change] [rfc]: https://github.com/rust-lang/rfcs/pull/246
2014-10-07auto merge of #17787 : bgamari/rust/fix-quote-method, r=huonwbors-0/+7
The previous fix introduced in 75d49c8203405ab0af7a2b8b8698af02868fdbc2 neglected to parse outer attributes as described in #17782.
2014-10-06syntax: Parse outer attributes in quote_method!Ben Gamari-0/+7
Fixes #17782.
2014-10-06Remove the #[allow(non_uppercase_statics)] attr from bitflags!P1start-19/+19
2014-10-04Changed `extern crate foo as bar;` error messageFelix Raimundo-5/+14
Closes #17709
2014-10-03rollup merge of #17729 : alexcrichton/issue-17718-startAlex Crichton-3/+21
2014-10-03Correct error message for invalid `ref`/`mut` bindingsP1start-3/+4
Closes #15914.
2014-10-02syntax: Enable parsing of `const` globalsAlex Crichton-3/+21
This rewrites them to the current `ItemStatic` production of the compiler, but I want to get this into a snapshot. It will be illegal to use a `static` in a pattern of a `match` statement, so all those current uses will need to be rewritten to `const` once it's implemented. This requires that the stage0 snapshot is able to parse `const`. cc #17718
2014-10-02syntax: remove ObsoleteManaged{Type,Expr}.Eduard Burtescu-14/+0
2014-10-02syntax: ast: remove TyBox and UnBox.Eduard Burtescu-5/+4
2014-10-01auto merge of #17584 : pcwalton/rust/range-patterns-dotdotdot, r=nick29581bors-8/+3
This breaks code that looks like: match foo { 1..3 => { ... } } Instead, write: match foo { 1...3 => { ... } } Closes #17295. r? @nick29581
2014-09-30Update based on PR feedbackKevin Ballard-1/+3
2014-09-30Produce a better error for irrefutable `if let` patternsKevin Ballard-2/+2
Modify ast::ExprMatch to include a new value of type ast::MatchSource, making it easy to tell whether the match was written literally or produced via desugaring. This allows us to customize error messages appropriately.
2014-09-30Teach libsyntax about `if let`Kevin Ballard-9/+26
2014-09-30librustc: Forbid `..` in range patterns.Patrick Walton-8/+3
This breaks code that looks like: match foo { 1..3 => { ... } } Instead, write: match foo { 1...3 => { ... } } Closes #17295. [breaking-change]
2014-09-26librustc: Eliminate the `ref` syntax for unboxed closure capture clausesPatrick Walton-3/+3
in favor of `move`. This breaks code that used `move` as an identifier, because it is now a keyword. Change such identifiers to not use the keyword `move`. Additionally, this breaks code that was counting on by-value or by-reference capture semantics for unboxed closures (behind the feature gate). Change `ref |:|` to `|:|` and `|:|` to `move |:|`. Part of RFC #63; part of issue #12831. [breaking-change]
2014-09-22librustc: Parse and resolve higher-rank lifetimes in traits.Patrick Walton-3/+23
They will ICE during typechecking if used, because they depend on trait reform. This is part of unboxed closures.
2014-09-21auto merge of #17415 : jakub-/rust/issue-17383, r=huonwbors-5/+7
Fixes #17383.
2014-09-21Fix the span for discriminators in non-C-like enumsJakub Wieczorek-5/+7
Fixes #17383.
2014-09-20libsyntax: Explicit error message for sugared doc comments.Mike Boutin-11/+28
Display an explicit message about items missing after sugared doc comment attributes. References #2789.
2014-09-19rollup merge of #17318 : nick29581/sliceAlex Crichton-9/+96
2014-09-19rollup merge of #17314 : eddyb/span-no-gcAlex Crichton-1/+1
2014-09-18librustc: Implement the syntax in the RFC for unboxed closure sugar.Patrick Walton-49/+27
Part of issue #16640. I am leaving this issue open to handle parsing of higher-rank lifetimes in traits. This change breaks code that used unboxed closures: * Instead of `F:|&: int| -> int`, write `F:Fn(int) -> int`. * Instead of `F:|&mut: int| -> int`, write `F:FnMut(int) -> int`. * Instead of `F:|: int| -> int`, write `F:FnOnce(int) -> int`. [breaking-change]
2014-09-19Implement slicing syntax.Nick Cameron-9/+96
`expr[]`, `expr[expr..]`, `expr[..expr]`,`expr[expr..expr]` Uses the Slice and SliceMut traits. Allows ... as well as .. in range patterns.
2014-09-18syntax: use an index in CodeMap instead of Gc for ExpnInfo.Eduard Burtescu-1/+1
2014-09-17librustc: Implement associated types behind a feature gate.Patrick Walton-94/+150
The implementation essentially desugars during type collection and AST type conversion time into the parameter scheme we have now. Only fully qualified names--e.g. `<T as Foo>::Bar`--are supported.
2014-09-17auto merge of #17343 : alexcrichton/rust/rollup, r=alexcrichtonbors-34/+31
2014-09-17auto merge of #16836 : P1start/rust/closure_ret_bang, r=alexcrichtonbors-10/+10
Fixes #13490.
2014-09-17rollup merge of #17290 : bkoropoff/issue-17283Alex Crichton-34/+31
2014-09-16Propagate restrictions against struct literals to the RHS of assignmentsBrian Koropoff-2/+3
This prevents confusing errors when accidentally using an assignment in an `if` expression. For example: ```rust fn main() { let x = 1u; if x = x { println!("{}", x); } } ``` Previously, this yielded: ``` test.rs:4:16: 4:17 error: expected `:`, found `!` test.rs:4 println!("{}", x); ^ ``` With this change, it now yields: ``` test.rs:3:8: 3:13 error: mismatched types: expected `bool`, found `()` (expected bool, found ()) test.rs:3 if x = x { ^~~~~ ``` Closes issue #17283
2014-09-16Convert restriction enum into bitflagsBrian Koropoff-32/+28
This makes having multiple restrictions at once cleaner. Also drop NO_DOUBLEBAR restriction since it is never used.
2014-09-16Fallout from renamingAaron Turon-11/+11
2014-09-14auto merge of #17163 : pcwalton/rust/impls-next-to-struct, r=alexcrichtonbors-0/+1
type they provide an implementation for. This breaks code like: mod foo { struct Foo { ... } } impl foo::Foo { ... } Change this code to: mod foo { struct Foo { ... } impl Foo { ... } } Closes #17059. RFC #155. [breaking-change] r? @brson
2014-09-14Add help diagnostic messagesP1start-0/+3
This adds ‘help’ diagnostic messages to rustc. This is used for anything that provides help to the user, particularly the `--explain` messages that were previously integrated into the relevant error message.
2014-09-14syntax: fix fallout from using ptr::P.Eduard Burtescu-236/+251
2014-09-13librustc: Forbid inherent implementations that aren't adjacent to thePatrick Walton-0/+1
type they provide an implementation for. This breaks code like: mod foo { struct Foo { ... } } impl foo::Foo { ... } Change this code to: mod foo { struct Foo { ... } impl Foo { ... } } Additionally, if you used the I/O path extension methods `stat`, `lstat`, `exists`, `is_file`, or `is_dir`, note that these methods have been moved to the the `std::io::fs::PathExtensions` trait. This breaks code like: fn is_it_there() -> bool { Path::new("/foo/bar/baz").exists() } Change this code to: use std::io::fs::PathExtensions; fn is_it_there() -> bool { Path::new("/foo/bar/baz").exists() } Closes #17059. RFC #155. [breaking-change]
2014-09-11auto merge of #16866 : P1start/rust/tuple-indexing, r=brsonbors-1/+41
This allows code to access the fields of tuples and tuple structs behind the feature gate `tuple_indexing`: ```rust #![feature(tuple_indexing)] let x = (1i, 2i); assert_eq!(x.1, 2); struct Point(int, int); let origin = Point(0, 0); assert_eq!(origin.0, 0); assert_eq!(origin.1, 0); ``` Implements [RFC 53](https://github.com/rust-lang/rfcs/blob/master/active/0053-tuple-accessors.md). Closes #16950.
2014-09-09librustc: Obsolete the old external crate renaming syntax.Patrick Walton-5/+1
Instead of `extern crate foo = bar`, write `extern crate bar as foo`. Instead of `extern crate baz = "quux"`, write `extern crate "quux" as baz`. Closes #16461. [breaking-change]
2014-09-10Implement tuple and tuple struct indexingP1start-1/+41
This allows code to access the fields of tuples and tuple structs: let x = (1i, 2i); assert_eq!(x.1, 2); struct Point(int, int); let origin = Point(0, 0); assert_eq!(origin.0, 0); assert_eq!(origin.1, 0);
2014-09-08librustc: Change the syntax of subslice matching to use postfix `..`Patrick Walton-31/+37
instead of prefix `..`. This breaks code that looked like: match foo { [ first, ..middle, last ] => { ... } } Change this code to: match foo { [ first, middle.., last ] => { ... } } RFC #55. Closes #16967. [breaking-change]
2014-09-07Fix deprecate warning "extern crate ... as ..."Sebastien Martini-1/+1
Its arguments were inverted.
2014-09-05Fix documentation typo.jamesluke-1/+1