Commit Graph

527 Commits

Author SHA1 Message Date
Esteban Küber 1550787b13 Add label for invalid literal suffix 2019-01-11 23:37:49 -08:00
Esteban Küber 8bede50f23 Continue evaluating after incorrect float literal 2019-01-11 21:19:44 -08:00
Mark Rousskov 2a663555dd Remove licenses 2018-12-25 21:08:33 -07:00
John Kåre Alsaker c66b84457f Tweak query code for performance 2018-12-17 08:53:01 +01:00
bors c6fb01d629 Auto merge of #56737 - nnethercote:TokenStream-improvements, r=petrochenkov
`TokenStream` improvements

Some `TokenStream` improvements: shrinking `TokenStream` and some other types, and some other code clean-ups.
2018-12-17 01:48:23 +00:00
kennytm 35fe8c92e9 Rollup merge of #56658 - Xanewok:non-panicking-file-parser, r=petrochenkov
Add non-panicking `maybe_new_parser_from_file` variant

Add (seemingly?) missing `maybe_new_parser_from_file` constructor variant.

Disclaimer: I'm not certain this is the correct approach - just found out we don't have this when working on a Rustfmt PR to catch/prevent more Rust parser panics: https://github.com/rust-lang/rustfmt/pull/3240 and tried to make it work somehow.
2018-12-14 22:10:07 +08:00
Nicholas Nethercote e80c7ddb05 Rename TokenStream::concat and remove TokenStream::concat_rc_vec.
`TokenStream::new` is a better name for the former, and the latter is
now just equivalent to `TokenStream::Stream`.
2018-12-12 20:36:00 +11:00
Nicholas Nethercote 1fe2c03240 Remove tokenstream::Delimited.
Because it's an extra type layer that doesn't really help; in a couple
of places it actively gets in the way, and overall removing it makes the
code nicer. It does, however, move `tokenstream::TokenTree` further away
from the `TokenTree` in `quote.rs`.

More importantly, this change reduces the size of `TokenStream` from 48
bytes to 40 bytes on x86-64, which is enough to slightly reduce
instruction counts on numerous benchmarks, the best by 1.5%.

Note that `open_tt` and `close_tt` have gone from being methods on
`Delimited` to associated methods of `TokenTree`.
2018-12-10 12:10:10 +11:00
Igor Matuszewski 85b50d0312 Add missing, non-panicking maybe_new_parser_from_file variant 2018-12-09 23:56:42 +01:00
bors 1839c144bc Auto merge of #54517 - mcr431:53956-panic-on-include_bytes-of-own-file, r=michaelwoerister
53956 panic on include bytes of own file

fix #53956

When using `include_bytes!` on a source file in the project, compiler would panic on subsequent compilations because `expand_include_bytes` would overwrite files in the source_map with no source. This PR changes `expand_include_bytes` to check source_map and use the already existing src, if any.
2018-12-06 01:36:51 +00:00
Matthew Russo f0f8aa9e05 adds DocTest filename variant, refactors doctest_offset out of source_map, fixes remaining test failures 2018-12-04 19:52:42 -05:00
Shotaro Yamada 11af6f66cb Use iterator and pattern APIs instead of char_at 2018-12-04 09:27:24 +09:00
Eric Huss 7f4bc2247a Clean up some non-mod-rs stuff. 2018-11-14 18:55:41 -08:00
bors 6d69fe7a2f Auto merge of #54861 - rep-nop:find_main_in_doctest, r=estebank
rustdoc: Replaces fn main search and extern crate search with proper parsing during doctests.

Fixes #21299.
Fixes #33731.

Let me know if there's any additional changes you'd like made!
2018-11-04 01:43:40 +00:00
QuietMisdreavus 014c8c4c38 implement existing parser fns in terms of fallible fns 2018-11-02 17:07:28 -05:00
QuietMisdreavus 0fe6aae49a buffer errors from initial tokenization when parsing 2018-11-01 11:57:29 -05:00
David Lavati 6c9f6a1afd Rename other occs of (Code/File)Map to Source(Map/File) #51574 2018-10-29 21:26:13 +01:00
Nicholas Nethercote eb637d26ba Avoid unnecessary allocations in float_lit and integer_lit.
This commit avoids an allocation when parsing any float and integer
literals that don't involved underscores.

This reduces the number of allocations done for the `tuple-stress`
benchmark by 10%, reducing its instruction count by just under 1%.
2018-10-26 22:08:39 +11:00
Vadim Petrochenkov 21d67c45a3 Fix a few tests with target-specific output
Enable one fully ignored test
2018-10-21 14:06:29 +03:00
David Tolnay a1dd39e724 Track distinct spans for open and close delimiter 2018-09-08 19:01:48 -07:00
Eduard-Mihai Burtescu 93f3f5b155 Use FxHash{Map,Set} instead of the default Hash{Map,Set} everywhere in rustc. 2018-08-28 17:04:04 +03:00
kennytm 445718084f Rollup merge of #53521 - alexcrichton:optimize-lit-token, r=michaelwoerister
syntax: Optimize some literal parsing

Currently in the `wasm-bindgen` project we have a very very large crate that's
procedurally generated, `web-sys`. To generate this crate we parse all of a
browser's WebIDL and we then generate bindings for all of the APIs contained
within.

The resulting Rust file is 18MB large (wow!) and currently takes a very long
time to compile in debug mode. On the nightly compiler a *debug* build takes 90s
for the crate to finish. I was curious what was taking so long and upon
investigating a *massive* portion of the time was spent in the `lit_token`
method of the compiler, primarily formatting strings via `format!`.

Upon some more investigation it looks like the `byte_str_lit` was allocating an
error message once per byte, causing a very large number of allocations to
happen for large literals, of which wasm-bindgen generates quite a few (some are
MB large).

This commit fixes the issue by lazily allocating the error message, only doing
so if the error message is actually needed (which should be never). As a result,
the debug mode compilation time for our `web-sys` crate decreased from 90s to
20s, a very nice improvement! (although we've still got some work to do).
2018-08-21 17:51:52 +08:00
Alex Crichton 5bf2ad3018 syntax: Optimize some literal parsing
Currently in the `wasm-bindgen` project we have a very very large crate that's
procedurally generated, `web-sys`. To generate this crate we parse all of a
browser's WebIDL and we then generate bindings for all of the APIs contained
within.

The resulting Rust file is 18MB large (wow!) and currently takes a very long
time to compile in debug mode. On the nightly compiler a *debug* build takes 90s
for the crate to finish. I was curious what was taking so long and upon
investigating a *massive* portion of the time was spent in the `lit_token`
method of the compiler, primarily formatting strings via `format!`.

Upon some more investigation it looks like the `byte_str_lit` was allocating an
error message once per byte, causing a very large number of allocations to
happen for large literals, of which wasm-bindgen generates quite a few (some are
MB large).

This commit fixes the issue by lazily allocating the error message, only doing
so if the error message is actually needed (which should be never). As a result,
the debug mode compilation time for our `web-sys` crate decreased from 90s to
20s, a very nice improvement! (although we've still got some work to do).
2018-08-20 11:28:37 -07:00
Donato Sciarra 6138c82803 fix tidy errors 2018-08-19 23:01:01 +02:00
Donato Sciarra 062bfbf39b mv codemap source_map 2018-08-19 23:01:01 +02:00
Donato Sciarra d3fe97f3d3 mv codemap() source_map() 2018-08-19 23:01:01 +02:00
Donato Sciarra 82607d2cf3 mv (mod) codemap source_map 2018-08-19 23:01:00 +02:00
Donato Sciarra cbd0595710 mv filemap source_file 2018-08-19 23:00:59 +02:00
Donato Sciarra d6dcbcd4e1 mv FileMap SourceFile 2018-08-19 23:00:59 +02:00
Donato Sciarra c655473378 mv CodeMap SourceMap 2018-08-19 23:00:59 +02:00
mark 6cb09ccf9f dump lints _after_ parsing macros 2018-07-23 21:55:51 -05:00
mark 2a7ae04a68 Extend ParseSess to support buffering lints 2018-07-23 21:54:43 -05:00
Vadim Petrochenkov e3acb341b2 Remove some tests using AST comparisons, fix other tests 2018-07-14 14:57:14 +03:00
Vadim Petrochenkov 9f92fce77c Fortify dummy span checking 2018-06-30 01:53:32 +03:00
bors 56e8f29dbe Auto merge of #51580 - cramertj:async-await, r=eddyb
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-23 09:02:45 +00:00
Tim Kuehn 0c33e0ae13 Re-reexport some items that were recently made crate-private. 2018-06-22 16:23:25 -07:00
Without Boats 18ff7d091a Parse async fn header.
This is gated on edition 2018 & the `async_await` feature gate.

The parser will accept `async fn` and `async unsafe fn` as fn
items. Along the same lines as `const fn`, only `async unsafe fn`
is permitted, not `unsafe async fn`.The parser will not accept
`async` functions as trait methods.

To do a little code clean up, four fields of the function type
struct have been merged into the new `FnHeader` struct: constness,
asyncness, unsafety, and ABI.

Also, a small bug in HIR printing is fixed: it previously printed
`const unsafe fn` as `unsafe const fn`, which is grammatically
incorrect.
2018-06-21 22:29:47 -07:00
Mark Simulacrum 60058e5dbe Crate-ify and delete unused code in syntax::parse 2018-06-09 16:57:19 -06:00
Vadim Petrochenkov b4714cdf6e lexer: Fix span override for the first token in a string 2018-05-20 23:35:00 +03:00
Nicholas Nethercote ad471452ba Make Directory::path a Cow.
Because we create a lot of these in the macro parser, but only very
rarely modify them.

This speeds up some html5ever runs by 2--3%.
2018-05-18 22:20:33 +10:00
Nicholas Nethercote 65ea0ff29d Optimize string handling in lit_token().
In the common case, the string value in a string literal Token is the
same as the string value in a string literal LitKind. (The exception is
when escapes or \r are involved.) This patch takes advantage of that to
avoid calling str_lit() and re-interning the string in that case. This
speeds up incremental builds for a few of the rustc-benchmarks, the best
by 3%.
2018-05-09 09:17:03 +10:00
Nicholas Nethercote 7a56360ece Remove parse::escape_default().
str::escape_default() can be used instead.
2018-05-03 10:31:45 +10:00
Irina Popa 04fa0e7bb3 rustc_target: move in syntax::abi and flip dependency. 2018-04-26 17:49:16 +03:00
Nicholas Nethercote 9f145022ef Avoid allocating when parsing \u{...} literals.
`char_lit` uses an allocation in order to ignore '_' chars in \u{...}
literals. This patch changes it to not do that by processing the chars
more directly.

This improves various rustc-perf benchmark measurements by up to 6%,
particularly regex, futures, clap, coercions, hyper, and encoding.
2018-04-19 09:17:40 +10:00
bors 67712d7945 Auto merge of #49390 - Zoxc:sync-syntax, r=michaelwoerister
More thread-safety changes

r? @michaelwoerister
2018-04-10 09:00:27 +00:00
Vadim Petrochenkov b3b5ef186c Remove more duplicated spans 2018-04-06 11:50:49 +03:00
Vadim Petrochenkov 62000c072e Rename ast::Variant_::name into ident + Fix rebase 2018-04-06 11:48:19 +03:00
John Kåre Alsaker c979189867 Make ParseSess thread-safe 2018-03-28 01:27:58 +02:00
Vadim Petrochenkov 604bbee84c libsyntax: Remove obsolete.rs 2018-03-27 00:45:28 +03:00
Alex Crichton 82bb41bdab Merge branch 'master' of https://github.com/Lymia/rust into rollup 2018-03-23 10:16:40 -07:00