about summary refs log tree commit diff
path: root/src/libsyntax/parse
AgeCommit message (Collapse)AuthorLines
2016-10-31Changed most vec! invocations to use square bracesiirelu-20/+20
Most of the Rust community agrees that the vec! macro is clearer when called using square brackets [] instead of regular brackets (). Most of these ocurrences are from before macros allowed using different types of brackets. There is one left unchanged in a pretty-print test, as the pretty printer still wants it to have regular brackets.
2016-10-29Move `CrateConfig` from `Crate` to `ParseSess`.Jeffrey Seyfried-119/+44
2016-10-28Auto merge of #37367 - jseyfried:import_crate_root, r=nrcbors-4/+9
Support `use *;` and `use ::*;`. Fixes #31484. r? @nrc
2016-10-28Rollup merge of #36206 - mcarton:35755, r=pnkfelixGuillaume Gomez-0/+11
Fix bad error message with `::<` in types Fix #36116. Before: ```rust error: expected identifier, found `<` --> src/test/compile-fail/issue-36116.rs:16:52 | 16 | let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>); | ^ error: chained comparison operators require parentheses --> src/test/compile-fail/issue-36116.rs:16:52 | 16 | let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>); | ^^^^^^ | = help: use `::<...>` instead of `<...>` if you meant to specify type arguments error: expected expression, found `)` --> src/test/compile-fail/issue-36116.rs:16:57 | 16 | let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>); | ^ error: expected identifier, found `<` --> src/test/compile-fail/issue-36116.rs:20:17 | 20 | let g: Foo::<i32> = Foo { _a: 42 }; | ^ error: aborting due to 5 previous errors ``` After: ```rust error: unexpected token: `::` --> src/test/compile-fail/issue-36116.rs:16:50 | 16 | let f = Some(Foo { _a: 42 }).map(|a| a as Foo::<i32>); | ^^ | = help: use `<...>` instead of `::<...>` if you meant to specify type arguments error: unexpected token: `::` --> src/test/compile-fail/issue-36116.rs:20:15 | 20 | let g: Foo::<i32> = Foo { _a: 42 }; | ^^ | = help: use `<...>` instead of `::<...>` if you meant to specify type arguments error: aborting due to 2 previous errors ```
2016-10-28Fix bad error message with `::<` in typesmcarton-0/+11
2016-10-27Auto merge of #37245 - goffrie:recovery, r=nrcbors-2/+10
Recover out of an enum or struct's braced block. If we encounter a syntax error inside of a braced block, then we should fail by consuming the rest of the block if possible. This implements such recovery for enums and structs. Fixes #37113.
2016-10-26Recover out of an enum or struct's braced block.Geoffry Song-2/+10
If we encounter a syntax error inside of a braced block, then we should fail by consuming the rest of the block if possible. This implements such recovery for enums and structs. Fixes #37113.
2016-10-27Implement field shorthands in struct literal expressions.Eduard Burtescu-8/+21
2016-10-23Support `use *;` and `use ::*;`.Jeffrey Seyfried-4/+9
2016-10-20Tweak path parsing logicVadim Petrochenkov-19/+30
2016-10-20Refactor parser lookahead buffer and increase its sizeVadim Petrochenkov-38/+41
2016-10-19Improve `$crate`.Jeffrey Seyfried-21/+7
2016-10-19Rollup merge of #37208 - jseyfried:fix_partially_consumed_tokens_in_macros, ↵Eduard-Mihai Burtescu-3/+24
r=nrc macros: fix partially consumed tokens in macro matchers Fixes #37175. This PR also avoids re-transcribing the tokens consumed by a matcher (and cloning the `TtReader` once per matcher), which improves expansion performance of the test case from #34630 by ~8%. r? @nrc
2016-10-18Fix some pretty printing testsVadim Petrochenkov-16/+30
2016-10-17Auto merge of #36969 - nnethercote:rename-Parser-fields, r=eddybbors-400/+399
Clarify the positions of the lexer and parser The lexer and parser use unclear names to indicate their positions in the source code. I propose the following renamings. Lexer: ``` pos -> next_pos # it's actually the next pos! last_pos -> pos # it's actually the current pos! curr -> ch # the current char curr_is -> ch_is # tests the current char col (unchanged) # the current column ``` parser ``` - last_span -> prev_span # the previous token's span - last_token_kind -> prev_token_kind # the previous token's kind - LastTokenKind -> PrevTokenKind # ditto (but the type) - token (unchanged) # the current token - span (unchanged) # the current span ``` Things to note: - This proposal removes all uses of "last", which is an unclear word because it could mean (a) previous, (b) final, or (c) most recent, i.e. current. - The "current" things (ch, col, token, span) consistently lack a prefix. The "previous" and "next" things consistently have a prefix.
2016-10-17Fix partially consumed tokens in macro matchers.Jeffrey Seyfried-3/+24
2016-10-15Auto merge of #37132 - petrochenkov:intern, r=alexcrichtonbors-10/+3
Get rid of double indirection in string interner
2016-10-13Get rid of double indirection in string interner by using `Rc<str>`Vadim Petrochenkov-10/+3
2016-10-10Avoid allocations in `Decoder::read_str`.Nicholas Nethercote-1/+1
`opaque::Decoder::read_str` is very hot within `rustc` due to its use in the reading of crate metadata, and it currently returns a `String`. This commit changes it to instead return a `Cow<str>`, which avoids a heap allocation. This change reduces the number of calls to `malloc` by almost 10% in some benchmarks. This is a [breaking-change] to libserialize.
2016-10-05Clarify StringReader::bump.Nicholas Nethercote-13/+16
This commit renames the variables to make it clearer which char each one refers to. It also slightly reorders and rearranges some statements.
2016-10-05Rename StringReader::curr as ch.Nicholas Nethercote-99/+99
Likewise, rename StringReader::curr_is as ch_is. This is a [breaking-change] for libsyntax.
2016-10-05Rename StringReader::last_pos as pos.Nicholas Nethercote-100/+100
This is a [breaking-change] for libsyntax.
2016-10-05Rename StringReader::pos as next_pos.Nicholas Nethercote-18/+18
This is a [breaking-change] for libsyntax.
2016-10-05Rename Parser::last_token_kind as prev_token_kind.Nicholas Nethercote-17/+17
Likewise, rename LastTokenKind as PrevTokenKind. This is a [breaking-change] for libsyntax.
2016-10-05Rename Parser::last_span as prev_span.Nicholas Nethercote-164/+160
This is a [breaking-change] for libsyntax.
2016-10-03Simplify `start_bpos` calculation in scan_comment().Nicholas Nethercote-5/+1
The two branches of this `if` compute the same value. This commit gets rid of the first branch, which makes this calculation identical to the one in scan_block_comment().
2016-10-03Streamline StringReader::bump.Nicholas Nethercote-3/+1
First, assert! is redundant w.r.t. the unwrap() immediately afterwards. Second, `byte_offset_diff` is effectively computed as `current_byte_offset + ch.len_utf8() - current_byte_offset` (with `next` as an intermediate) which is silly and can be simplified.
2016-10-01Rollup merge of #34764 - pnkfelix:attrs-on-generic-formals, r=eddybManish Goregaokar-9/+53
First step for #34761
2016-10-01Rollup merge of #36599 - ↵Manish Goregaokar-3/+3
jonas-schievink:whats-a-pirates-favorite-data-structure, r=pnkfelix Contains a syntax-[breaking-change] as a separate commit (cc #31645).nnAlso renames slice patterns from `PatKind::Vec` to `PatKind::Slice`.
2016-09-28Rollup merge of #36789 - jseyfried:non_inline_mod_in_block, r=nikomatsakisJonathan Turner-9/+13
Allow more non-inline modules in blocks Currently, non-inline modules without a `#[path]` attribute are not allowed in blocks. This PR allows non-inline modules that have an ancestor module with a `#[path]` attribute, provided there is not a nearer ancestor block. For example, ```rust fn main() { #[path = "..."] mod foo { mod bar; //< allowed by this PR fn f() { mod bar; //< still an error } } } ``` Fixes #36772. r? @nikomatsakis
2016-09-28Allow non-inline modules in more places.Jeffrey Seyfried-9/+13
2016-09-28libsyntax: clearer names for some AST partsJonas Schievink-3/+3
This applies the HIR changes from the previous commits to the AST, and is thus a syntax-[breaking-change] Renames `PatKind::Vec` to `PatKind::Slice`, since these are called slice patterns, not vec patterns. Renames `TyKind::Vec`, which represents the type `[T]`, to `TyKind::Slice`. Renames `TyKind::FixedLengthVec` to `TyKind::Array`.
2016-09-26Auto merge of #36764 - jonathandturner:rollup, r=jonathandturnerbors-263/+222
Rollup of 14 pull requests - Successful merges: #36563, #36574, #36586, #36662, #36663, #36669, #36676, #36721, #36723, #36727, #36729, #36742, #36754, #36756 - Failed merges:
2016-09-26Rollup merge of #36669 - jseyfried:refactor_tok_result, r=nrcJonathan Turner-11/+0
Unify `TokResult` and `ResultAnyMacro` Fixes #36641. r? @nrc
2016-09-26Rollup merge of #36662 - jseyfried:parse_macro_invoc_paths, r=nrcJonathan Turner-252/+222
parser: support paths in bang macro invocations (e.g. `path::to::macro!()`) r? @nrc
2016-09-26Move `ensure_complete_parse` into `expand.rs`.Jeffrey Seyfried-14/+0
2016-09-26add unstable_features to ParseSessTim Neumann-0/+3
2016-09-26Refactor `ensure_complete_parse`.Jeffrey Seyfried-9/+12
2016-09-23Added tests and fixed corner case for trailing attributes with no attached ↵Felix S. Klock II-1/+16
binding in generics.
2016-09-23Add attribute support to generic lifetime and type parameters.Felix S. Klock II-9/+38
I am using `ThinAttributes` rather than a vector for attributes attached to generics, since I expect almost all lifetime and types parameters to not carry any attributes.
2016-09-23Fix indents.Jeffrey Seyfried-141/+131
2016-09-23Cleanup.Jeffrey Seyfried-40/+17
2016-09-23Parse paths in item, trait item, and impl item macro invocations.Jeffrey Seyfried-21/+6
2016-09-23Parse paths in statement and pattern macro invocations.Jeffrey Seyfried-31/+46
2016-09-22Auto merge of #36154 - nrc:proc-macro-init, r=@jseyfriedbors-13/+49
Adds a `ProcMacro` form of syntax extension This commit adds syntax extension forms matching the types for procedural macros 2.0 (RFC #1566), these still require the usual syntax extension boiler plate, but this is a first step towards proper implementation and should be useful for macros 1.1 stuff too. Supports both attribute-like and function-like macros. Note that RFC #1566 has not been accepted yet, but I think there is consensus that we want to head in vaguely that direction and so this PR will be useful in any case. It is also fairly easy to undo and does not break any existing programs. This is related to #35957 in that I hope it can be used in the implementation of macros 1.1, however, there is no direct overlap and is more of a complement than a competing proposal. There is still a fair bit of work to do before the two can be combined. r? @jseyfried cc @alexcrichton, @cgswords, @eddyb, @aturon
2016-09-23reviewer comments and rebasingNick Cameron-37/+20
2016-09-22Rollup merge of #36539 - mikhail-m1:36530, r=jonathandturnerJonathan Turner-1/+1
fix top level attr spans issue #36530 ?r @jonathandturner
2016-09-22Refactor out `parse_struct_expr`.Jeffrey Seyfried-45/+48
2016-09-22Adds a `ProcMacro` form of syntax extensionNick Cameron-6/+59
This commit adds syntax extension forms matching the types for procedural macros 2.0 (RFC #1566), these still require the usual syntax extension boiler plate, but this is a first step towards proper implementation and should be useful for macros 1.1 stuff too. Supports both attribute-like and function-like macros.
2016-09-19Auto merge of #36471 - nnethercote:rm-to_binop, r=sanxiynbors-26/+1
Remove unused Token::to_binop function Just some dead code removal.