about summary refs log tree commit diff
path: root/src/libsyntax/ext/expand.rs
AgeCommit message (Collapse)AuthorLines
2019-06-06syntax: Switch function parameter order in `TokenTree::token`Vadim Petrochenkov-2/+2
2019-06-06syntax: Use `Token` in `TokenTree::Token`Vadim Petrochenkov-1/+1
2019-06-06Always use token kinds through `token` module rather than `Token` typeVadim Petrochenkov-2/+2
2019-05-27Avoid unnecessary internings.Nicholas Nethercote-1/+1
Most involving `Symbol::intern` on string literals.
2019-05-22Eliminate unnecessary `Ident::with_empty_ctxt`sVadim Petrochenkov-4/+4
2019-05-22Simplify use of keyword symbolsVadim Petrochenkov-9/+9
2019-05-21Move `edition` outside the hygiene lock and avoid accessing itJohn Kåre Alsaker-4/+4
2019-05-17Avoid unnecessary interning in `Ident::from_str()` calls.Nicholas Nethercote-4/+4
A lot of these static symbols are pre-interned.
2019-05-13Remove the equality operation between `Symbol` and strings.Nicholas Nethercote-4/+4
And also the equality between `Path` and strings, because `Path` is made up of `Symbol`s.
2019-05-13Pass a `Symbol` to `check_name`, `emit_feature_err`, and related functions.Nicholas Nethercote-15/+15
2019-03-16Refactor away `NestedMetaItemKind`Vadim Petrochenkov-7/+7
Remove methods `Attribute::span` and `MetaItem::span` duplicating public fields
2019-03-16Rename `MetaItem::ident` to `MetaItem::path`Vadim Petrochenkov-1/+1
2019-03-16syntax_ext: Validate `#[proc_macro_derive]` input betterVadim Petrochenkov-2/+2
Tweak some error wording
2019-02-23Rollup merge of #58476 - nnethercote:rm-LazyTokenStream, r=petrochenkovMazdak Farrokhzad-2/+3
Remove `LazyTokenStream`. `LazyTokenStream` was added in #40939. Perhaps it was an effective optimization then, but no longer. This PR removes it, making the code both simpler and faster. r? @alexcrichton
2019-02-20cleanup macro after 2018 transitionAleksey Kladov-4/+2
We can now use `?`
2019-02-18Remove `LazyTokenStream`.Nicholas Nethercote-2/+3
It's present within `Token::Interpolated` as an optimization, so that if a nonterminal is converted to a `TokenStream` multiple times, the first-computed value is saved and reused. But in practice it's not needed. `interpolated_to_tokenstream()` is a cold function: it's only called a few dozen times while compiling rustc itself, and a few hundred times across the entire `rustc-perf` suite. Furthermore, when it is called, it is almost always the first conversion, so no benefit is gained from it. So this commit removes `LazyTokenStream`, along with the now-unnecessary `Token::interpolated()`. As well as a significant simplification, the removal speeds things up slightly, mostly due to not having to `drop` the `LazyTokenStream` instances.
2019-02-13Rollup merge of #58273 - taiki-e:rename-dependency, r=matthewjasperMazdak Farrokhzad-1/+1
Rename rustc_errors dependency in rust 2018 crates I think this is a better solution than `use rustc_errors as errors` in `lib.rs` and `use crate::errors` in modules. Related: rust-lang/cargo#5653 cc #58099 r? @Centril
2019-02-12Auto merge of #58341 - alexreg:cosmetic-2-doc-comments, r=steveklabnikbors-1/+1
Cosmetic improvements to doc comments This has been factored out from https://github.com/rust-lang/rust/pull/58036 to only include changes to documentation comments (throughout the rustc codebase). r? @steveklabnik Once you're happy with this, maybe we could get it through with r=1, so it doesn't constantly get invalidated? (I'm not sure this will be an issue, but just in case...) Anyway, thanks for your advice so far!
2019-02-13Cleanup importsTaiki Endo-1/+1
2019-02-13Rename rustc_errors dependency in rust 2018 cratesTaiki Endo-1/+1
2019-02-11Use `Rc<[Symbol]>` instead of `Vec<Symbol>` to reduce # of allocsOliver Scherer-5/+5
2019-02-11Fixup RustcDeserialize internal featuresOliver Scherer-0/+1
2019-02-11Rename the `exp` field to mirror its usesOliver Scherer-1/+1
2019-02-11Require a list of features to allow in `allow_internal_unstable`Oliver Scherer-11/+16
2019-02-10rustc: doc commentsAlexander Regueiro-1/+1
2019-02-07libsyntax => 2018Taiki Endo-24/+25
2019-02-06Overhaul `syntax::fold::Folder`.Nicholas Nethercote-139/+151
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-4/+1
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-4/+3
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-3/+3
2019-01-26Pretty print `$crate` as `crate` or `crate_name` in more casesVadim Petrochenkov-4/+3
2018-12-28Auto merge of #57155 - petrochenkov:dcrate3, r=dtolnaybors-0/+4
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/+4
2018-12-27Make sure feature gate errors are recoverableVadim Petrochenkov-1/+0
2018-12-27Do not abort compilation if expansion produces errorsVadim Petrochenkov-9/+7
Fix a number of uncovered deficiencies in diagnostics
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-19Remove `eliminate_crate_var` and special pretty-printing for `$crate`Vadim Petrochenkov-4/+1
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-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-2/+2
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-1/+1
Various minor/cosmetic improvements to code r? @Centril 😄
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-1/+1
2018-12-07use top level `fs` functions where appropriateAndy Russell-23/+24
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-14/+0
attributes
2018-12-04syntax: Rename some keywordsVadim Petrochenkov-1/+1
`CrateRoot` -> `PathRoot`, `::` doesn't necessarily mean crate root now `SelfValue` -> `SelfLower`, `SelfType` -> `SelfUpper`, both `self` and `Self` can be used in type and value namespaces now
2018-11-20Reuse the `P` in `InvocationCollector::fold_{,opt_}expr`.Nicholas Nethercote-36/+48
This requires adding a new method, `P::filter_map`. This commit reduces instruction counts for various benchmarks by up to 0.7%.
2018-11-05Auto merge of #55451 - estebank:arg-doc, r=pnkfelixbors-1/+1
Custom diagnostic when trying to doc comment argument When writing ``` pub fn f( /// Comment id: u8, ) {} ``` Produce a targeted diagnostic ``` error: documentation comments cannot be applied to method arguments --> $DIR/fn-arg-doc-comment.rs:2:5 | LL | /// Comment | ^^^^^^^^^^^ doc comments are not allowed here ``` Fix #54801.