about summary refs log tree commit diff
path: root/src/libsyntax/parse
AgeCommit message (Collapse)AuthorLines
2014-07-11Add scaffolding for assigning alpha-numeric codes to rustc diagnosticsJakub Wieczorek-2/+2
2014-07-09Fix all the test falloutCorey Richardson-9/+19
2014-07-09ast: make Name its own typeCorey Richardson-80/+95
2014-07-09lexer: lex WS/COMMENT/SHEBANG rather than skippingCorey Richardson-62/+118
Now, the lexer will categorize every byte in its input according to the grammar. The parser skips over these while parsing, thus avoiding their presence in the input to syntax extensions.
2014-07-09syntax: don't parse numeric literals in the lexerCorey Richardson-225/+287
This removes a bunch of token types. Tokens now store the original, unaltered numeric literal (that is still checked for correctness), which is parsed into an actual number later, as needed, when creating the AST. This can change how syntax extensions work, but otherwise poses no visible changes. [breaking-change]
2014-07-09syntax: don't process string/char/byte/binary litsCorey Richardson-76/+307
This shuffles things around a bit so that LIT_CHAR and co store an Ident which is the original, unaltered literal in the source. When creating the AST, unescape and postprocess them. This changes how syntax extensions can work, slightly, but otherwise poses no visible changes. To get a useful value out of one of these tokens, call `parse::{char_lit, byte_lit, bin_lit, str_lit}` [breaking-change]
2014-07-09lexer: add ident_from and ident_from_to methodsCorey Richardson-0/+14
2014-07-09lexer: shuffle around some functionsCorey Richardson-99/+100
2014-07-09syntax: use a better Show impl for IdentCorey Richardson-1/+1
Rather than just dumping the id in the interner, which is useless, actually print the interned string. Adjust the lexer logging to use Show instead of Poly.
2014-07-09token: replace ast::Ident with just IdentCorey Richardson-18/+19
2014-07-09syntax: doc comments all the thingsCorey Richardson-284/+288
2014-07-08carry self ident forward through re-parsingJohn Clements-30/+42
formerly, the self identifier was being discarded during parsing, which stymies hygiene. The best fix here seems to be to attach a self identifier to ExplicitSelf_, a change that rippled through the rest of the compiler, but without any obvious damage.
2014-07-08remove outdated commentJohn Clements-12/+0
I believe this comment is now irrelevant, as a result of commit 6757053cffb585249105fbd76f
2014-07-08replace idents with namesJohn Clements-0/+5
2014-07-08get rid of keyword idents, replace with namesJohn Clements-8/+8
should prevent future bugs
2014-07-08preserve context in parsing of `self` varrefJohn Clements-9/+11
2014-07-08remove unused fn, make SELF_KEYWORD_NAME publicJohn Clements-5/+1
2014-07-08change if/else to matchJohn Clements-179/+197
2014-07-08auto merge of #15493 : brson/rust/tostr, r=pcwaltonbors-52/+52
This updates https://github.com/rust-lang/rust/pull/15075. Rename `ToStr::to_str` to `ToString::to_string`. The naive renaming ends up with two `to_string` functions defined on strings in the prelude (the other defined via `collections::str::StrAllocating`). To remedy this I removed `StrAllocating::to_string`, making all conversions from `&str` to `String` go through `Show`. This has a measurable impact on the speed of this conversion, but the sense I get from others is that it's best to go ahead and unify `to_string` and address performance for all `to_string` conversions in `core::fmt`. `String::from_str(...)` still works as a manual fast-path. Note that the patch was done with a script, and ended up renaming a number of other `*_to_str` functions, particularly inside of rustc. All the ones I saw looked correct, and I didn't notice any additional API breakage. Closes #15046.
2014-07-08std: Rename the `ToStr` trait to `ToString`, and `to_str` to `to_string`.Richo Healey-52/+52
[breaking-change]
2014-07-08Change DST syntax: type -> Sized?Nick Cameron-18/+47
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-07-05auto merge of #15428 : phildawes/rust/master, r=huonwbors-2/+3
Fix small bug introduced in e38cb972dcf: PatIdent span was incorrect because self.last_span was being used before the ident token was parsed.
2014-07-05auto merge of #15427 : aochagavia/rust/parse, r=pcwaltonbors-16/+2
2014-07-05auto merge of #15425 : jbclements/rust/hygiene-for-3-kinds-of-args, r=cmrbors-1/+1
This pull request adds hygiene for 3 kinds of argument bindings: - arguments to item fns, - arguments to `ExprFnBlock`s, and - arguments to `ExprProc`s It also adds a bunch of unit tests, fixes a few macro uses to be non-capturing, and has a few cleanup items. local `make check` succeeds.
2014-07-04Parser: fix PatIdent span bugPhil Dawes-2/+3
Fix small bug introduced in e38cb972dcf: PatIdent span was incorrect because self.last_span was being used before the ident token was parsed.
2014-07-04Removed unnecessary method in testAdolfo OchagavĂ­a-16/+2
2014-07-04new_mark -> apply_mark, new_rename -> apply_renameJohn Clements-1/+1
2014-07-04librustc: Remove the `&LIFETIME EXPR` production from the language.Patrick Walton-1/+0
This was parsed by the parser but completely ignored; not even stored in the AST! This breaks code that looks like: static X: &'static [u8] = &'static [1, 2, 3]; Change this code to the shorter: static X: &'static [u8] = &[1, 2, 3]; Closes #15312. [breaking-change]
2014-07-03Fix ICE with nested macro_rules!-style macrosKevin Ballard-2/+2
Fixes #10536.
2014-07-03Simplify PatIdent to contain an Ident rather than a PathJohn Clements-44/+32
Rationale: for what appear to be historical reasons only, the PatIdent contains a Path rather than an Ident. This means that there are many places in the code where an ident is artificially promoted to a path, and---much more problematically--- a bunch of elements from a path are simply thrown away, which seems like an invitation to some really nasty bugs. This commit replaces the Path in a PatIdent with a SpannedIdent, which just contains an ident and a span.
2014-07-01rustc: Remove `&str` indexing from the language.Brian Anderson-2/+2
Being able to index into the bytes of a string encourages poor UTF-8 hygiene. To get a view of `&[u8]` from either a `String` or `&str` slice, use the `as_bytes()` method. Closes #12710. [breaking-change]
2014-06-28auto merge of #15208 : alexcrichton/rust/snapshots, r=pcwaltonbors-1/+5
This change registers new snapshots, allowing `*T` to be removed from the language. This is a large breaking change, and it is recommended that if compiler errors are seen that any FFI calls are audited to determine whether they should be actually taking `*mut T`.
2014-06-28auto merge of #15233 : jbclements/rust/match-var-hygiene-etc, r=cmrbors-0/+1
This PR includes two big things and a bunch of little ones. 1) It enables hygiene for variables bound by 'match' expressions. 2) It fixes a bug discovered indirectly (#15221), wherein fold traversal failed to visit nonterminal nodes. 3) It fixes a small bug in the macro tutorial. It also adds tests for the first two, and makes a bunch of small comment improvements and cleanup.
2014-06-27comments onlyJohn Clements-0/+1
2014-06-26Remove unnecessary to_string callsPiotr Jawniak-1/+1
This commit removes superfluous to_string calls from various places
2014-06-25Register new snapshotsAlex Crichton-1/+5
This change starts denying `*T` in the parser. All code using `*T` should ensure that the FFI call does indeed take `const T*` on the other side before renaming the type to `*const T`. Otherwise, all code can rename `*T` to `*const T`. [breaking-change]
2014-06-25auto merge of #15160 : alexcrichton/rust/remove-f128, r=brsonbors-8/+1
The f128 type has very little support in the compiler and the feature is basically unusable today. Supporting half-baked features in the compiler can be detrimental to the long-term development of the compiler, and hence this feature is being removed.
2014-06-24Make parse_expr_res publicKeegan McAllister-1/+1
2014-06-24librustc: Remove the fallback to `int` from typechecking.Niko Matsakis-4/+2
This breaks a fair amount of code. The typical patterns are: * `for _ in range(0, 10)`: change to `for _ in range(0u, 10)`; * `println!("{}", 3)`: change to `println!("{}", 3i)`; * `[1, 2, 3].len()`: change to `[1i, 2, 3].len()`. RFC #30. Closes #6023. [breaking-change]
2014-06-24Remove the quad_precision_float feature gateAlex Crichton-8/+1
The f128 type has very little support in the compiler and the feature is basically unusable today. Supporting half-baked features in the compiler can be detrimental to the long-term development of the compiler, and hence this feature is being removed.
2014-06-24auto merge of #14952 : alexcrichton/rust/const-unsafe-pointers, r=brsonbors-4/+17
This does not yet change the compiler and libraries from `*T` to `*const T` as it will require a snapshot to do so. cc #7362 --- Note that the corresponding RFC, https://github.com/rust-lang/rfcs/pull/68, has not yet been accepted. It was [discussed at the last meeting](https://github.com/rust-lang/rust/wiki/Meeting-weekly-2014-06-10#rfc-pr-68-unsafe-pointers-rename-t-to-const-t) and decided to be accepted, however. I figured I'd get started on the preliminary work for the RFC that will be required regardless.
2014-06-23libsyntax: Disallow struct literals after `if`, `while`, `match`, andPatrick Walton-14/+16
`for...in`. Closes #14803. If you used a structure literal after one of these keywords, surround it in parentheses. [breaking-change]
2014-06-22libsyntax: don't allow enum structs with no fieldsBenjamin Herr-0/+5
Unit-like structs are written as `struct Foo;`, but we erroneously accepted `struct Foo();` and took it to mean the same thing. Now we don't, so use the `struct Foo;` form! [breaking-change]
2014-06-21auto merge of #15062 : pcwalton/rust/trailing-plus, r=brsonbors-0/+6
This will break code that looks like `Box<Trait+>`. Change that code to `Box<Trait>` instead. Closes #14925. [breaking-change] r? @brson
2014-06-20libsyntax: Stop parsing `+` with no bounds after it.Patrick Walton-0/+6
This will break code that looks like `Box<Trait+>`. Change that code to `Box<Trait>` instead. Closes #14925. [breaking-change]
2014-06-20syntax: Parse GT tokens from `>=` and `>>=`Alex Crichton-1/+13
The parser already has special logic for parsing `>` tokens from `>>`, and this commit extends the logic to the acquiring a `>` from the `>=` and `>>=` tokens as well. Closes #15043
2014-06-18Handle CRLF properly in the lexerKevin Ballard-23/+140
The lexer already ignores CRLF in between tokens, but it doesn't properly handle carriage returns inside strings and doc comments. Teach it to treat CRLF as LF inside these tokens, and to disallow carriage returns that are not followed by linefeeds. This includes handling an escaped CRLF inside a regular string token the same way it handles an escaped LF. This is technically a breaking change, as bare carriage returns are no longer allowed, and CRLF sequences are now treated as LF inside strings and doc comments, but it's very unlikely to actually affect any real-world code. This change is necessary to have Rust code compile on Windows the same way it does on Unix. The mozilla/rust repository explicitly sets eol=lf for Rust source files, but other Rust repositories don't. Notably, rust-http cannot be compiled on Windows without converting the CRLF line endings back to LF. [breaking-change]
2014-06-18Don't require mutable StringReader to emit lexer errorsKevin Ballard-42/+52
Teach StringReader how to emit errors for arbitrary spans, so we don't need to modify peek_span. This allows for emitting errors without having a &mut borrow of the StringReader.
2014-06-18Fix spans for doc commentsKevin Ballard-3/+3
2014-06-18auto merge of #14880 : SimonSapin/rust/byte-literals, r=alexcrichtonbors-83/+213
See #14646 (tracking issue) and rust-lang/rfcs#69. This does not close the tracking issue, as the `bytes!()` macro still needs to be removed. It will be later, after a snapshot is made with the changes in this PR, so that the new syntax can be used when bootstrapping the compiler.