about summary refs log tree commit diff
path: root/src/libsyntax/parse
AgeCommit message (Collapse)AuthorLines
2018-08-11Fix handling of trait methods with bodies and improve efficiencyvarkor-19/+30
2018-08-11Emit error for pattern arguments in trait methodsvarkor-20/+33
The error and check for this already existed, but the parser didn't try to parse trait method arguments as patterns, so the error was never emitted. This surfaces the error, so we get better errors than simple parse errors.
2018-08-05Enable macros to pass $:literal to another macroMatthew Tran-0/+4
2018-08-01async can begin expressionsTaylor Cramer-0/+1
2018-07-29Auto merge of #52738 - ljedrz:push_to_extend, r=eddybbors-3/+1
Replace push loops with extend() where possible Or set the vector capacity where I couldn't do it. According to my [simple benchmark](https://gist.github.com/ljedrz/568e97621b749849684c1da71c27dceb) `extend`ing a vector can be over **10 times** faster than `push`ing to it in a loop: 10 elements (6.1 times faster): ``` test bench_extension ... bench: 75 ns/iter (+/- 23) test bench_push_loop ... bench: 458 ns/iter (+/- 142) ``` 100 elements (11.12 times faster): ``` test bench_extension ... bench: 87 ns/iter (+/- 26) test bench_push_loop ... bench: 968 ns/iter (+/- 3,528) ``` 1000 elements (11.04 times faster): ``` test bench_extension ... bench: 311 ns/iter (+/- 9) test bench_push_loop ... bench: 3,436 ns/iter (+/- 233) ``` Seems like a good idea to use `extend` as much as possible.
2018-07-29Replace push loops with collect() and extend() where possibleljedrz-3/+1
2018-07-29Auto merge of #52767 - ljedrz:avoid_format, r=petrochenkovbors-1/+1
Prefer to_string() to format!() Simple benchmarks suggest in some cases it can be faster by even 37%: ``` test converting_f64_long ... bench: 339 ns/iter (+/- 199) test converting_f64_short ... bench: 136 ns/iter (+/- 34) test converting_i32_long ... bench: 87 ns/iter (+/- 16) test converting_i32_short ... bench: 87 ns/iter (+/- 49) test converting_str ... bench: 54 ns/iter (+/- 15) test formatting_f64_long ... bench: 349 ns/iter (+/- 176) test formatting_f64_short ... bench: 145 ns/iter (+/- 14) test formatting_i32_long ... bench: 98 ns/iter (+/- 14) test formatting_i32_short ... bench: 93 ns/iter (+/- 15) test formatting_str ... bench: 86 ns/iter (+/- 23) ```
2018-07-28Rollup merge of #52740 - estebank:crate-name, r=petrochenkovkennytm-1/+35
Suggest underscore when using dashes in crate namet push fork Fix #48437.
2018-07-27review commentsEsteban Küber-11/+7
2018-07-27Prefer to_string() to format!()ljedrz-1/+1
2018-07-26Suggest underscore when using dashes in crate namet push forkEsteban Küber-3/+41
2018-07-24Rollup merge of #52645 - oli-obk:existential_in_fn_body, r=dtolnayMark Rousskov-0/+6
Allow declaring existential types inside blocks fixes #52631 r? @dtolnay
2018-07-24Auto merge of #51587 - mark-i-m:at_most_once_rep_2018, r=alexcrichtonbors-2/+22
2018 edition `?` Kleene operator This is my first attempt at implementing the migration lint + 2018 behavior as discussed in #48075 r? @nikomatsakis
2018-07-24Allow declaring existential types inside blocksOliver Schneider-0/+6
2018-07-23Allow by default, fix testsmark-0/+1
2018-07-23dump lints _after_ parsing macrosmark-3/+3
2018-07-23Extend ParseSess to support buffering lintsmark-2/+21
2018-07-22rustc: Implement tokenization of nested itemsAlex Crichton-43/+76
Ever plagued by #43081 the compiler can return surprising spans in situations related to procedural macros. This is exhibited by #47983 where whenever a procedural macro is invoked in a nested item context it would fail to have correct span information. While #43230 provided a "hack" to cache the token stream used for each item in the compiler it's not a full-blown solution. This commit continues to extend this "hack" a bit more to work for nested items. Previously in the parser the `parse_item` method would collect the tokens for an item into a cache on the item itself. It turned out, however, that nested items were parsed through the `parse_item_` method, so they didn't receive similar treatment. To remedy this situation the hook for collecting tokens was moved into `parse_item_` instead of `parse_item`. Afterwards the token collection scheme was updated to support nested collection of tokens. This is implemented by tracking `TokenStream` tokens instead of `TokenTree` to allow for collecting items into streams at intermediate layers and having them interleaved in the upper layers. All in all, this... Closes #47983
2018-07-21Auto merge of #52552 - eddyb:proc-macro-prep, r=alexcrichtonbors-6/+0
Prepare proc_macro for decoupling it from the rest of the compiler. This is #49219 up to the point where the bridge is introduced. Aside from moving some code around, the largest change is the rewrite of `proc_macro::quote` to be simpler and do less introspection. I'd like to also extend `quote!` with `${stmt;...;expr}` instead of just `$variable` (and maybe even `$(... $iter ...)*`), which seems pretty straight-forward now, but I don't know if/when I should. r? @alexcrichton or @dtolnay cc @jseyfried @petrochenkov
2018-07-21Auto merge of #52536 - alexcrichton:attr-spans, r=nikomatsakisbors-5/+44
proc_macro: Preserve spans of attributes on functions This commit updates the tokenization of items which are subsequently passed to `proc_macro` to ensure that span information is preserved on attributes as much as possible. Previously this area of the code suffered from #43081 where we haven't actually implemented converting an attribute to to a token tree yet, but a local fix was possible here. Closes #47941
2018-07-20proc_macro: move some implementation details to a rustc module.Eduard-Mihai Burtescu-6/+0
2018-07-19proc_macro: Preserve spans of attributes on functionsAlex Crichton-5/+44
This commit updates the tokenization of items which are subsequently passed to `proc_macro` to ensure that span information is preserved on attributes as much as possible. Previously this area of the code suffered from #43081 where we haven't actually implemented converting an attribute to to a token tree yet, but a local fix was possible here. Closes #47941
2018-07-18Implement existential typesOliver Schneider-17/+56
2018-07-14Address commentsVadim Petrochenkov-1/+1
2018-07-14Remove some tests using AST comparisons, fix other testsVadim Petrochenkov-206/+30
2018-07-14Remove most of `Hash` impls from AST and HIR structuresVadim Petrochenkov-2/+2
2018-07-14Remove most of `PartialEq` impls from AST and HIR structuresVadim Petrochenkov-13/+13
2018-07-10Deny bare trait objects in in src/libsyntaxljedrz-1/+1
2018-07-08Auto merge of #51955 - zackmdavis:item_semi, r=oli-obkbors-0/+16
clarify why we're suggesting removing semicolon after braced items Previously (issue #46186, pull-request #46258), a suggestion was added to remove the semicolon after we fail to parse an item, but issue #51603 complains that it's still insufficiently obvious why. Let's add a note. Resolves #51603.
2018-06-30choose a less arbitrary span when parsing the empty visibility modifierZack M. Davis-1/+4
Visibility spans were added to the AST in #47799 (d6bdf296) as a `Spanned<_>`—which means that we need to choose a span even in the case of inherited visibility (what you get when there's no `pub` &c. keyword at all). That initial implementation's choice is pretty counterintuitive, which could matter if we want to use it as a site to suggest inserting a visibility modifier, &c. (The phrase "Schelling span" in the comment is meant in analogy to the game-theoretic concept of a "Schelling point", a value that is chosen simply because it's what one can expect to agree upon with other agents in the absence of explicit coördination.)
2018-06-30clarify why we're suggesting removing semicolon after braced itemsZack M. Davis-0/+16
Previously (issue #46186, pull-request #46258), a suggestion was added to remove the semicolon after we fail to parse an item, but issue #51603 complains that it's still insufficiently obvious why. Let's add a note. Resolves #51603.
2018-06-30Auto merge of #51762 - petrochenkov:oh-hi-mark, r=oli-obkbors-8/+8
hygiene: Implement transparent marks and use them for call-site hygiene in proc-macros Fixes https://github.com/rust-lang/rust/issues/50050
2018-06-30Auto merge of #51806 - oli-obk:lowering_cleanups1, r=cramertjbors-7/+11
Lowering cleanups [1/N]
2018-06-30Fortify dummy span checkingVadim Petrochenkov-8/+8
2018-06-28Auto merge of #50997 - michaelwoerister:pre-analyze-filemaps, r=Mark-Simulacrumbors-21/+5
Make FileMap::{lines, multibyte_chars, non_narrow_chars} non-mutable. This PR removes most of the interior mutability from `FileMap`, which should be beneficial, especially in a multithreaded setting. This is achieved by initializing the state in question when the filemap is constructed instead of during lexing. Hopefully this doesn't degrade performance. cc @wesleywiser
2018-06-28Fix FileMap::line_begin_pos().Michael Woerister-2/+4
The method relied on the FileMap still being under construction in order for it to do what the name promises. It's now independent of the current state.
2018-06-28Use `Ident`s in a number of structures in HIRVadim Petrochenkov-1/+1
Namely: labels, type parameters, bindings in patterns, parameter names in functions without body. All of these do not need hygiene after lowering to HIR, only span locations.
2018-06-27Make FileMap::{lines, multibyte_chars, non_narrow_chars} non-mutable.Michael Woerister-19/+1
2018-06-27Generate `DefId`s for the impl trait of `async` functionsOliver Schneider-6/+10
2018-06-27Generate the `NodeId` for `existential type` in the ASTOliver Schneider-1/+1
2018-06-26inclusive range syntax lint (`...` → `..=`)Zack M. Davis-12/+21
Our implementation ends up changing the `PatKind::Range` variant in the AST to take a `Spanned<RangeEnd>` instead of just a `RangeEnd`, because the alternative would be to try to infer the span of the range operator from the spans of the start and end subexpressions, which is both hideous and nontrivial to get right (whereas getting the change to the AST right was a simple game of type tennis). This is concerning #51043.
2018-06-26migrate codebase to `..=` inclusive range patternsZack M. Davis-2/+2
These were stabilized in March 2018's #47813, and are the Preferred Way to Do It going forward (q.v. #51043).
2018-06-23structured suggestion and rewording for `...` expression syntax errorZack M. Davis-6/+8
Now that `..=` inclusive ranges are stabilized, people probably shouldn't be using `...` even in patterns, even if it's still legal there (see #51043). To avoid drawing attention to `...` being a real thing, let's reword this message to just say "unexpected token" rather "cannot be used in expressions".
2018-06-23Auto merge of #51580 - cramertj:async-await, r=eddybbors-23/+125
async/await This PR implements `async`/`await` syntax for `async fn` in Rust 2015 and `async` closures and `async` blocks in Rust 2018 (tracking issue: https://github.com/rust-lang/rust/issues/50547). Limitations: non-`move` async closures with arguments are currently not supported, nor are `async fn` with multiple different input lifetimes. These limitations are not fundamental and will be removed in the future, however I'd like to go ahead and get this PR merged so we can start experimenting with this in combination with futures 0.3. Based on https://github.com/rust-lang/rust/pull/51414. cc @petrochenkov for parsing changes. r? @eddyb
2018-06-22Re-reexport some items that were recently made crate-private.Tim Kuehn-2/+2
2018-06-22Auto merge of #51704 - kennytm:rollup, r=kennytmbors-4/+4
Rollup of 6 pull requests Successful merges: - #51158 (Mention spec and indented blocks in doctest docs) - #51629 (Do not consume semicolon twice while parsing local statement) - #51637 (Update zx_cprng_draw_new on Fuchsia) - #51664 (make more libsyntax methods public) - #51666 (Disable probestack when GCOV profiling is being used) - #51703 (Recognize the extra "LLVM tools versions" argument to build-manifest.) Failed merges: r? @ghost
2018-06-22add an explanatory comment for recovery behaviorNiko Matsakis-0/+3
2018-06-22Issue #50974: Fix compilation error and testLamb-1/+1
2018-06-22Fix when the help message is displayedMaerten-2/+2
Only display the "remove this comma" suggestion when followed by an identifier
2018-06-22Issue #50974: Change text of suggestion to be more directLamb-1/+1