about summary refs log tree commit diff
path: root/src/libsyntax/ext
AgeCommit message (Collapse)AuthorLines
2019-02-10rustc: doc commentsAlexander Regueiro-41/+41
2019-02-09Auto merge of #57617 - mark-i-m:multiple-matcher-bindings, r=petrochenkovbors-5/+62
Error on duplicate matcher bindings fix #57593 This should not be merged without a crater run and maybe an FCP. Discussion is ongoing at #57593. TODO: - [x] write tests - [x] crater run - [x] ~maybe need edition gating?~ not for 1 regression /centril r? @petrochenkov
2019-02-07Make it an incompatibility lint for nowMark Mansi-9/+22
2019-02-07error on duplicate matcher bindingsmark-5/+49
2019-02-07Support const generics in derivevarkor-1/+19
Co-Authored-By: Gabriel Smith <yodaldevoid@users.noreply.github.com>
2019-02-07libsyntax => 2018Taiki Endo-179/+188
2019-02-06Overhaul `syntax::fold::Folder`.Nicholas Nethercote-212/+218
This commit changes `syntax::fold::Folder` from a functional style (where most methods take a `T` and produce a new `T`) to a more imperative style (where most methods take and modify a `&mut T`), and renames it `syntax::mut_visit::MutVisitor`. The first benefit is speed. The functional style does not require any reallocations, due to the use of `P::map` and `MoveMap::move_{,flat_}map`. However, every field in the AST must be overwritten; even those fields that are unchanged are overwritten with the same value. This causes a lot of unnecessary memory writes. The imperative style reduces instruction counts by 1--3% across a wide range of workloads, particularly incremental workloads. The second benefit is conciseness; the imperative style is usually more concise. E.g. compare the old functional style: ``` fn fold_abc(&mut self, abc: ABC) { ABC { a: fold_a(abc.a), b: fold_b(abc.b), c: abc.c, } } ``` with the imperative style: ``` fn visit_abc(&mut self, ABC { a, b, c: _ }: &mut ABC) { visit_a(a); visit_b(b); } ``` (The reductions get larger in more complex examples.) Overall, the patch removes over 200 lines of code -- even though the new code has more comments -- and a lot of the remaining lines have fewer characters. Some notes: - The old style used methods called `fold_*`. The new style mostly uses methods called `visit_*`, but there are a few methods that map a `T` to something other than a `T`, which are called `flat_map_*` (`T` maps to multiple `T`s) or `filter_map_*` (`T` maps to 0 or 1 `T`s). - `move_map.rs`/`MoveMap`/`move_map`/`move_flat_map` are renamed `map_in_place.rs`/`MapInPlace`/`map_in_place`/`flat_map_in_place` to reflect their slightly changed signatures. - Although this commit renames the `fold` module as `mut_visit`, it keeps it in the `fold.rs` file, so as not to confuse git. The next commit will rename the file.
2019-02-05Various improvements in `Folder` impls.Nicholas Nethercote-14/+6
2019-02-05Simplify `fold_attribute`.Nicholas Nethercote-5/+3
It doesn't need to return an `Option`.
2019-02-05Remove some unnecessary `ast::` and `fold::` qualifiers.Nicholas Nethercote-4/+3
2019-01-28Rollup merge of #57915 - petrochenkov:notto-disu, r=zackmdavisMazdak Farrokhzad-18/+5
Pretty print `$crate` as `crate` or `crate_name` in more cases So, people do parse output of `--pretty=expanded` (sigh), so covering only the legacy proc-macro case (like it was done in https://github.com/rust-lang/rust/pull/57155) is not enough. This PRs resolves all `$crate`s produced by macros, so they are all printed in the parseable form `$crate::foo` -> `crate::foo` or `crate_name::foo`. Fixes https://github.com/rust-lang/rust/issues/38016#issuecomment-455851334 Fixes https://github.com/rust-lang/rust/pull/57155#issuecomment-455807195
2019-01-26remove `_with_applicability` from suggestion fnsAndy Russell-4/+4
2019-01-26Pretty print `$crate` as `crate` or `crate_name` in more casesVadim Petrochenkov-18/+5
2019-01-24Remove quote_*! macros and associated APIsMark Simulacrum-893/+0
2019-01-20Auto merge of #57651 - JohnTitor:give-char-type, r=estebankbors-0/+1
Implement new literal type `Err` Fixes #57384 I removed `return Ok`, otherwise, two errors occur. Any solutions? r? @estebank
2019-01-19Rollup merge of #57486 - nnethercote:simplify-TokenStream-more, r=petrochenkovMazdak Farrokhzad-1/+1
Simplify `TokenStream` some more These commits simplify `TokenStream`, remove `ThinTokenStream`, and avoid some clones. The end result is simpler code and a slight perf win on some benchmarks. r? @petrochenkov
2019-01-19Rollup merge of #57610 - mark-i-m:nested-matchers, r=petrochenkovMazdak Farrokhzad-4/+10
Fix nested `?` matchers fix #57597 I'm not 100% if this works yet... cc @alercah When this is ready (but perhaps not yet):
2019-01-18Change from mk_lit! to cx.exprYuki Okushi-1/+1
2019-01-16Auto merge of #57321 - petrochenkov:atokens, r=nikomatsakisbors-0/+5
Implement basic input validation for built-in attributes Correct top-level shape (`#[attr]` vs `#[attr(...)]` vs `#[attr = ...]`) is enforced for built-in attributes, built-in attributes must also fit into the "meta-item" syntax (aka the "classic attribute syntax"). For some subset of attributes (found by crater run), errors are lowered to deprecation warnings. NOTE: This PR previously included https://github.com/rust-lang/rust/pull/57367 as well.
2019-01-16Add new literal type ErrYuki Okushi-0/+1
2019-01-15fix nested matchers with ?mark-4/+10
2019-01-14Remove `ThinTokenStream`.Nicholas Nethercote-1/+1
`TokenStream` is now almost identical to `ThinTokenStream`. This commit removes the latter, replacing it with the former.
2019-01-13Rollup merge of #57004 - nnethercote:TS-change-Stream, r=petrochenkovMazdak Farrokhzad-4/+4
Make `TokenStream` less recursive. `TokenStream` is currently recursive in *two* ways: - the `TokenTree` variant contains a `ThinTokenStream`, which can contain a `TokenStream`; - the `TokenStream` variant contains a `Vec<TokenStream>`. The latter is not necessary and causes significant complexity. This commit replaces it with the simpler `Vec<(TokenTree, IsJoint)>`. This reduces complexity significantly. In particular, `StreamCursor` is eliminated, and `Cursor` becomes much simpler, consisting now of just a `TokenStream` and an index. The commit also removes the `Extend` impl for `TokenStream`, because it is only used in tests. (The commit also removes those tests.) Overall, the commit reduces the number of lines of code by almost 200.
2019-01-13Implement basic input validation for built-in attributesVadim Petrochenkov-0/+5
2019-01-09Change `String` to `&'static str` in `ParseResult::Failure`.Nicholas Nethercote-4/+4
This avoids 770,000 allocations when compiling the `html5ever` benchmark, reducing instruction counts by up to 2%.
2019-01-08Make `TokenStream` less recursive.Nicholas Nethercote-4/+4
`TokenStream` is currently recursive in *two* ways: - the `TokenTree` variant contains a `ThinTokenStream`, which can contain a `TokenStream`; - the `TokenStream` variant contains a `Vec<TokenStream>`. The latter is not necessary and causes significant complexity. This commit replaces it with the simpler `Vec<(TokenTree, IsJoint)>`. This reduces complexity significantly. In particular, `StreamCursor` is eliminated, and `Cursor` becomes much simpler, consisting now of just a `TokenStream` and an index. The commit also removes the `Extend` impl for `TokenStream`, because it is only used in tests. (The commit also removes those tests.) Overall, the commit reduces the number of lines of code by almost 200.
2019-01-03Fix repeated word typosWiktor Kuchta-1/+1
Found with `git grep -P '\b([a-z]+)\s+\1\b'`
2018-12-30Improve error recovery for some built-in macrosVadim Petrochenkov-5/+6
2018-12-28Auto merge of #57155 - petrochenkov:dcrate3, r=dtolnaybors-0/+18
Resolve `$crate`s for pretty-printing at more appropriate time Doing it in `BuildReducedGraphVisitor` wasn't a good idea, identifiers wasn't actually visited half of the time. As a result some `$crate`s weren't resolved and were therefore pretty-printed as `$crate` literally, which turns into two tokens during re-parsing of the pretty-printed text. Now we are visiting and resolving `$crate` identifiers in an item right before sending that item to a proc macro attribute or derive. Fixes https://github.com/rust-lang/rust/issues/57089
2018-12-28Resolve `$crate`s for pretty-printing at more appropriate timeVadim Petrochenkov-0/+18
2018-12-27Make sure feature gate errors are recoverableVadim Petrochenkov-1/+0
2018-12-27Fix `trace_macros` and `log_syntax`Vadim Petrochenkov-12/+18
2018-12-27Get rid of `Block::recovered`Vadim Petrochenkov-1/+0
2018-12-27Do not abort compilation if expansion produces errorsVadim Petrochenkov-14/+11
Fix a number of uncovered deficiencies in diagnostics
2018-12-25Remove licensesMark Rousskov-110/+0
2018-12-19Remove `eliminate_crate_var` and special pretty-printing for `$crate`Vadim Petrochenkov-6/+1
2018-12-17Auto merge of #56737 - nnethercote:TokenStream-improvements, r=petrochenkovbors-3/+3
`TokenStream` improvements Some `TokenStream` improvements: shrinking `TokenStream` and some other types, and some other code clean-ups.
2018-12-15Rollup merge of #56679 - euclio:external-doc-parse, r=estebankPietro Albini-12/+56
overhaul external doc attribute diagnostics This PR improves the error handling and spans for the external doc attribute. Many cases that silently failed before now emit errors, spans are tightened, and the errors have help and suggestions. I tried to address all the cases that users ran into in the tracking issue. cc #44732 r? @QuietMisdreavus
2018-12-12Rename `TokenStream::concat` and remove `TokenStream::concat_rc_vec`.Nicholas Nethercote-3/+3
`TokenStream::new` is a better name for the former, and the latter is now just equivalent to `TokenStream::Stream`.
2018-12-10improve diagnostics for invalid external docsAndy Russell-10/+26
2018-12-10reject invalid external doc attributesAndy Russell-2/+30
Also, provide a suggestion for the correct syntax.
2018-12-10Remove `tokenstream::Delimited`.Nicholas Nethercote-32/+31
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-08Auto merge of #56578 - alexreg:cosmetic-1, r=alexregbors-20/+20
Various minor/cosmetic improvements to code r? @Centril 😄
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-20/+20
2018-12-07use top level `fs` functions where appropriateAndy Russell-54/+47
This commit replaces many usages of `File::open` and reading or writing with `fs::read_to_string`, `fs::read` and `fs::write`. This reduces code complexity, and will improve performance for most reads, since the functions allocate the buffer to be the size of the file. I believe that this commit will not impact behavior in any way, so some matches will check the error kind in case the file was not valid UTF-8. Some of these cases may not actually care about the error.
2018-12-07Unsupport `#[derive(Trait)]` sugar for `#[derive_Trait]` legacy plugin ↵Vadim Petrochenkov-21/+0
attributes
2018-12-06Rollup merge of #56426 - petrochenkov:syntweak, r=nikomatsakisPietro Albini-12/+9
libsyntax_pos: A few tweaks
2018-12-06Auto merge of #54517 - mcr431:53956-panic-on-include_bytes-of-own-file, ↵bors-7/+11
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-04adds DocTest filename variant, refactors doctest_offset out of source_map, ↵Matthew Russo-0/+1
fixes remaining test failures
2018-12-04updates all Filename variants to take a fingerprintMatthew Russo-4/+4