about summary refs log tree commit diff
path: root/src/libsyntax/parse
AgeCommit message (Collapse)AuthorLines
2014-09-03Fix spelling errors and capitalization.Joseph Crail-1/+1
2014-09-03Remove cross-borrowing for traits.Nick Cameron-3/+3
Closes #15349 [breaking-change] Trait objects are no longer implicitly coerced from Box<T> to &T. You must make an explicit coercion using `&*`.
2014-09-01Updated to new extern crate syntax.wickerwaka-3/+8
Added warning for old deprecated syntax
2014-08-31auto merge of #16809 : nick29581/rust/dst-bug-3, r=alexcrichtonbors-13/+6
This corrects a rebasing error. Also adds a test so it won't happen again. r?
2014-08-30rollup merge of #16839 : treeman/issue-15358Alex Crichton-1/+1
2014-08-29Add support for labeled while loops.Pythoner6-4/+7
2014-08-29Tweak error message for use of a keyword in ident position.Jonas Hietala-1/+1
Closes #15358
2014-08-29Allow `!` as the return type of proc/closure literalsP1start-10/+10
Fixes #13490.
2014-08-28Forbid ~str and ~[]Nick Cameron-13/+6
This corrects a rebasing error. Also adds a test so it won't happen again.
2014-08-27Implement generalized object and type parameter bounds (Fixes #16462)Niko Matsakis-113/+71
2014-08-27auto merge of #16689 : wickerwaka/rust/crate-as, r=pcwaltonbors-2/+12
For review. Not sure about the link_attrs stuff. Will work on converting all the tests. extern crate "foobar" as foo; extern crate foobar as foo; Implements remaining part of RFC #47. Addresses issue #16461. Removed link_attrs from rust.md, they don't appear to be supported by the parser.
2014-08-26Rebasing changesNick Cameron-14/+17
2014-08-26DST coercions and DST structsNick Cameron-54/+27
[breaking-change] 1. The internal layout for traits has changed from (vtable, data) to (data, vtable). If you were relying on this in unsafe transmutes, you might get some very weird and apparently unrelated errors. You should not be doing this! Prefer not to do this at all, but if you must, you should use raw::TraitObject rather than hardcoding rustc's internal representation into your code. 2. The minimal type of reference-to-vec-literals (e.g., `&[1, 2, 3]`) is now a fixed size vec (e.g., `&[int, ..3]`) where it used to be an unsized vec (e.g., `&[int]`). If you want the unszied type, you must explicitly give the type (e.g., `let x: &[_] = &[1, 2, 3]`). Note in particular where multiple blocks must have the same type (e.g., if and else clauses, vec elements), the compiler will not coerce to the unsized type without a hint. E.g., `[&[1], &[1, 2]]` used to be a valid expression of type '[&[int]]'. It no longer type checks since the first element now has type `&[int, ..1]` and the second has type &[int, ..2]` which are incompatible. 3. The type of blocks (including functions) must be coercible to the expected type (used to be a subtype). Mostly this makes things more flexible and not less (in particular, in the case of coercing function bodies to the return type). However, in some rare cases, this is less flexible. TBH, I'm not exactly sure of the exact effects. I think the change causes us to resolve inferred type variables slightly earlier which might make us slightly more restrictive. Possibly it only affects blocks with unreachable code. E.g., `if ... { fail!(); "Hello" }` used to type check, it no longer does. The fix is to add a semicolon after the string.
2014-08-25auto merge of #16699 : treeman/rust/issue-8492, r=alexcrichtonbors-11/+11
Closes #8492. I did not find this suggestion in the [guidelines][] but it's mentioned in the [old style guide][]. [guidelines]: https://github.com/rust-lang/rust-guidelines [old style guide]: https://github.com/rust-lang/rust/wiki/Note-style-guide/73c864a10a8e231e2a6630e5a3461f1d3022a20a
2014-08-24auto merge of #16646 : P1start/rust/trailing-commas, r=alexcrichtonbors-18/+25
This lets the parser understand trailing commas in method calls, method definitions, enum variants, and type parameters. Closes #14240. Closes #15887.
2014-08-24Adjust the error messages to match the pattern "expected foo, found bar"Jonas Hietala-11/+11
Closes #8492
2014-08-23extern crate foobar as foo;wickerwaka-2/+12
Implements remaining part of RFC #47. Addresses issue #16461. Removed link_attrs from rust.md, they don't appear to be supported by the parser. Changed all the tests to use the new extern crate syntax Change pretty printer to use 'as' syntax
2014-08-23Add support for trailing commas in more placesP1start-18/+25
This lets the parser understand trailing commas in method calls, method definitions, enum variants, and type parameters. Closes #14240. Closes #15887.
2014-08-21syntax: Fix complexity of string parsing. Closes #16624.Brian Anderson-5/+16
2014-08-18libsyntax: Remove the `use foo = bar` syntax from the language in favorPatrick Walton-3/+9
of `use bar as foo`. Change all uses of `use foo = bar` to `use bar as foo`. Implements RFC #47. Closes #16461. [breaking-change]
2014-08-16librustc: Forbid external crates, imports, and/or items from beingPatrick Walton-45/+46
declared with the same name in the same scope. This breaks several common patterns. First are unused imports: use foo::bar; use baz::bar; Change this code to the following: use baz::bar; Second, this patch breaks globs that import names that are shadowed by subsequent imports. For example: use foo::*; // including `bar` use baz::bar; Change this code to remove the glob: use foo::{boo, quux}; use baz::bar; Or qualify all uses of `bar`: use foo::{boo, quux}; use baz; ... baz::bar ... Finally, this patch breaks code that, at top level, explicitly imports `std` and doesn't disable the prelude. extern crate std; Because the prelude imports `std` implicitly, there is no need to explicitly import it; just remove such directives. The old behavior can be opted into via the `import_shadowing` feature gate. Use of this feature gate is discouraged. This implements RFC #116. Closes #16464. [breaking-change]
2014-08-15auto merge of #16424 : pcwalton/rust/where-clauses, r=nikomatsakisbors-34/+107
These `where` clauses are accepted everywhere generics are currently accepted and desugar during type collection to the type parameter bounds we have today. A new keyword, `where`, has been added. Therefore, this is a breaking change. Change uses of `where` to other identifiers. [breaking-change] r? @nikomatsakis (or whoever)
2014-08-14librustc: Implement simple `where` clauses.Patrick Walton-34/+107
These `where` clauses are accepted everywhere generics are currently accepted and desugar during type collection to the type parameter bounds we have today. A new keyword, `where`, has been added. Therefore, this is a breaking change. Change uses of `where` to other identifiers. [breaking-change]
2014-08-14auto merge of #16468 : pcwalton/rust/as-renaming-import, r=alexcrichtonbors-2/+6
The old syntax will be removed after a snapshot. RFC #47. Issue #16461. r? @brson
2014-08-14libsyntax: Accept `use foo as bar;` in lieu of `use bar as foo;`Patrick Walton-2/+6
The old syntax will be removed after a snapshot. RFC #47. Issue #16461.
2014-08-14librustc: Stop assuming that implementations and traits only containPatrick Walton-16/+24
methods. This paves the way to associated items by introducing an extra level of abstraction ("impl-or-trait item") between traits/implementations and methods. This new abstraction is encoded in the metadata and used throughout the compiler where appropriate. There are no functional changes; this is purely a refactoring.
2014-08-14librustc: Tie up loose ends in unboxed closures.Patrick Walton-71/+96
This patch primarily does two things: (1) it prevents lifetimes from leaking out of unboxed closures; (2) it allows unboxed closure type notation, call notation, and construction notation to construct closures matching any of the three traits. This breaks code that looked like: let mut f; { let x = &5i; f = |&mut:| *x + 10; } Change this code to avoid having a reference escape. For example: { let x = &5i; let mut f; // <-- move here to avoid dangling reference f = |&mut:| *x + 10; } I believe this is enough to consider unboxed closures essentially implemented. Further issues (for example, higher-rank lifetimes) should be filed as followups. Closes #14449. [breaking-change]
2014-08-14auto merge of #15929 : pcwalton/rust/by-ref-closures, r=alexcrichtonbors-4/+13
by-reference upvars. This partially implements RFC 38. A snapshot will be needed to turn this on, because stage0 cannot yet parse the keyword. Part of #12831. r? @alexcrichton
2014-08-13librustc: Parse, but do not fully turn on, the `ref` keyword forPatrick Walton-4/+13
by-reference upvars. This partially implements RFC 38. A snapshot will be needed to turn this on, because stage0 cannot yet parse the keyword. Part of #12381.
2014-08-13quote_expr macro: embed Ident using special encoding that preserves hygiene.Felix S. Klock II-0/+174
This adds support to `quote_expr!` and friends for round-trip hygienic preservation of Ident. Here are the pieces of the puzzle: * adding a method for encoding Ident for re-reading into token tree. * Support for reading such encoded Idents in the lexer. Note that one must peek ahead for MOD_SEP after scan_embedded_hygienic_ident. * To ensure that encoded Idents are only read when we are in the midst of expanding a `quote_expr` or similar, added a `read_embedded_ident` flag on `StringReader`. * pprust support for encoding Ident's as (uint,uint) pairs (for hygiene).
2014-08-12libsyntax: Don't strip types and lifetimes from single-segment paths inPatrick Walton-1/+10
patterns. This breaks code like: fn main() { match Some("foo") { None::<int> => {} Some(_) => {} } } Change this code to not contain a type error. For example: fn main() { match Some("foo") { None::<&str> => {} Some(_) => {} } } Closes #16353. [breaking-change]
2014-08-07Temporary bootstrapping hack: introduce syntax for r egion bounds like `'b:'a`,Niko Matsakis-29/+62
meaning `'b outlives 'a`. Syntax currently does nothing but is needed for full fix to #5763. To use this syntax, the issue_5763_bootstrap feature guard is required.
2014-08-07auto merge of #16306 : pnkfelix/rust/fsk-ast-refactor-PatWild, r=alexcrichtonbors-3/+3
AST refactoring: merge PatWild and PatWildMulti into one variant with a flag
2014-08-06auto merge of #16291 : nham/rust/byte_literals, r=alexcrichtonbors-2/+2
This replaces many instances chars being casted to u8 with byte literals.
2014-08-06AST refactoring: merge PatWild and PatWildMulti into one variant with a flag.Felix S. Klock II-3/+3
2014-08-06Use byte literals in libsyntaxnham-2/+2
2014-08-05syntax: Handle \r\n in byte string literalsAlex Crichton-18/+38
This ended up passing through the lexer but dying later on in parsing when it wasn't handled. The strategy taken was to copy the `str_lit` funciton, but adapt it for bytes. Closes #16278
2014-08-05Fixes missing overflow lint for i64 #14269Falco Hirschenberger-39/+22
The `type_overflow` lint, doesn't catch the overflow for `i64` because the overflow happens earlier in the parse phase when the `u64` as biggest possible int gets casted to `i64` , without checking the for overflows. We can't lint in the parse phase, so a refactoring of the `LitInt` type was necessary. The types `LitInt`, `LitUint` and `LitIntUnsuffixed` where merged to one type `LitInt` which stores it's value as `u64`. An additional parameter was added which indicate the signedness of the type and the sign of the value.
2014-08-01Fix misspelled comments.Joseph Crail-1/+1
2014-07-29syntax: add support for quoting armsErick Tryzelaar-25/+29
2014-07-25librustc: Disallow mutation and assignment in pattern guards, and modifyPatrick Walton-183/+208
the CFG for match statements. There were two bugs in issue #14684. One was simply that the borrow check didn't know about the correct CFG for match statements: the pattern must be a predecessor of the guard. This disallows the bad behavior if there are bindings in the pattern. But it isn't enough to prevent the memory safety problem, because of wildcards; thus, this patch introduces a more restrictive rule, which disallows assignments and mutable borrows inside guards outright. I discussed this with Niko and we decided this was the best plan of action. This breaks code that performs mutable borrows in pattern guards. Most commonly, the code looks like this: impl Foo { fn f(&mut self, ...) {} fn g(&mut self, ...) { match bar { Baz if self.f(...) => { ... } _ => { ... } } } } Change this code to not use a guard. For example: impl Foo { fn f(&mut self, ...) {} fn g(&mut self, ...) { match bar { Baz => { if self.f(...) { ... } else { ... } } _ => { ... } } } } Sometimes this can result in code duplication, but often it illustrates a hidden memory safety problem. Closes #14684. [breaking-change]
2014-07-24librustc: Make bare functions implement the `FnMut` trait.Patrick Walton-1/+7
This is done entirely in the libraries for functions up to 16 arguments. A macro is used so that more arguments can be easily added if we need. Note that I had to adjust the overloaded call algorithm to not try calling the overloaded call operator if the callee is a built-in function type, to prevent loops. Closes #15448.
2014-07-24libsyntax: Remove `~self` and `mut ~self` from the language.Patrick Walton-6/+14
This eliminates the last vestige of the `~` syntax. Instead of `~self`, write `self: Box<TypeOfSelf>`; instead of `mut ~self`, write `mut self: Box<TypeOfSelf>`, replacing `TypeOfSelf` with the self-type parameter as specified in the implementation. Closes #13885. [breaking-change]
2014-07-23Parser: Global single-segment paths should be represented as PatEnumJakub Wieczorek-1/+1
Fixed #15774.
2014-07-20auto merge of #15808 : jakub-/rust/use-mod, r=alexcrichtonbors-6/+10
Implements RFC #168.
2014-07-20Implement new mod import sugarJakub Wieczorek-6/+10
Implements RFC #168.
2014-07-20Correctly stringify! types and paths inside macrosPiotr Jawniak-3/+5
Closes #8709
2014-07-18librustc: Implement unboxed closures with mutable receiversPatrick Walton-56/+63
2014-07-17librustc: Remove cross-borrowing of `Box<T>` to `&T` from the language,Patrick Walton-1/+3
except where trait objects are involved. Part of issue #15349, though I'm leaving it open for trait objects. Cross borrowing for trait objects remains because it is needed until we have DST. This will break code like: fn foo(x: &int) { ... } let a = box 3i; foo(a); Change this code to: fn foo(x: &int) { ... } let a = box 3i; foo(&*a); [breaking-change]
2014-07-17auto merge of #15706 : phi-gamma/rust/master, r=huonwbors-1/+1
I kept changes to each file in a separate commit. Please let me know if you prefer them squashed!