about summary refs log tree commit diff
path: root/src/libsyntax/ext/base.rs
AgeCommit message (Collapse)AuthorLines
2019-07-11resolve/expand: `resolve_macro_invocation` no longer returns determinate errorsVadim Petrochenkov-13/+4
It either returns the indeterminacy error, or valid (but perhaps dummy) `SyntaxExtension`. With this change enum `Determinacy` is no longer used in libsyntax and can be moved to resolve. The regressions in diagnosics are fixed in the next commits.
2019-07-11resolve: Make proc macro stubs less stubbyVadim Petrochenkov-1/+21
Create real working and registered (even if dummy) `SyntaxExtension`s for them. This improves error recovery and allows to avoid all special cases for proc macro stubs (except for the error on use, of course). The introduced dummy `SyntaxExtension`s can be used for any other inappropriately resolved macros as well.
2019-07-11hygiene: Reuse `MacroKind` in `ExpnKind`Vadim Petrochenkov-10/+2
Orthogonality and reuse are good.
2019-07-11syntax: Make def-site span mandatory in ↵Vadim Petrochenkov-3/+1
ExpnInfo/MacroBacktrace/DiagnosticSpanMacroExpansion We have to deal with dummy spans anyway Remove def-site span from expander interfaces. It's not used by the expansion infra, only by specific expanders, which can keep it themselves if they want it.
2019-07-11expand: Get rid of `resolve_macro_path`Vadim Petrochenkov-3/+0
It was used to choose whether to apply derive markers like `#[rustc_copy_clone_marker]` or not, but it was called before all the data required for resolution is available, so it could work incorrectly in some corner cases (like user-defined derives name `Copy` or `Eq`). Delay the decision about markers until the proper resolution results are available instead.
2019-07-11Rename some things in `syntax_pos/hygiene`Vadim Petrochenkov-7/+7
More consistent with other naming: ExpnFormat -> ExpnKind ExpnKind::name -> ExpnKind::descr DesugaringKind::name -> DesugaringKind::descr Shorter, no tautology: CompilerDesugaring -> Desugaring CompilerDesugaringKind -> DesugaringKind
2019-07-11Move `MacroKind` into `libsyntax_pos`Vadim Petrochenkov-28/+1
So it can be eventually used in `ExpnInfo`
2019-07-11Remove `MacroKind::ProcMacroStub`Vadim Petrochenkov-3/+0
It's internal to resolve and always results in `Res::Err` outside of resolve. Instead put `DefKind::Fn`s themselves into the macro namespace, it's ok. Proc macro stubs are items placed into macro namespase for functions that define proc macros. https://github.com/rust-lang/rust/pull/52383 The rustdoc test is changed because the old test didn't actually reproduce the ICE it was supposed to reproduce.
2019-07-09Resolve `$crate` in all hygienic contexts for pretty-pringingVadim Petrochenkov-1/+1
Stop visiting AST to discover those contexts, just iterate through hygiene data instead
2019-07-07Support deprecation checking for macrosVadim Petrochenkov-2/+5
2019-07-07syntax: Keep full `Stability` in `SyntaxExtension`Vadim Petrochenkov-4/+4
2019-07-07resolve/expand: Move macro stability checking to an earlier pointVadim Petrochenkov-2/+0
2019-07-07syntax: Remove `NodeId` from `SyntaxExtension`Vadim Petrochenkov-4/+4
2019-06-18resolve/expand: Move expansion info setting to a single earlier pointVadim Petrochenkov-1/+1
2019-06-18syntax: Move `default_transparency` into `ExpnInfo`Vadim Petrochenkov-1/+2
2019-06-18syntax: Remove `DummyResolver`Vadim Petrochenkov-25/+0
2019-06-18syntax: Factor out common fields from `SyntaxExtension` variantsVadim Petrochenkov-61/+87
2019-06-10syntax: Rename variants of `SyntaxExtension` for consistencyVadim Petrochenkov-30/+25
2019-06-10syntax: Improve documentation of `SyntaxExtension`Vadim Petrochenkov-36/+54
2019-06-10syntax: Remove `SyntaxExtension::DeclMacro`Vadim Petrochenkov-13/+5
It's a less powerful duplicate of `SyntaxExtension::NormalTT`
2019-06-10syntax: Use `MultiItemModifier` for built-in derivesVadim Petrochenkov-5/+2
2019-06-10syntax: Remove `SyntaxExtension::MultiDecorator` and `MultiItemDecorator`Vadim Petrochenkov-33/+0
2019-06-10syntax: Remove `SyntaxExtension::IdentTT` and `IdentMacroExpander`Vadim Petrochenkov-38/+0
2019-06-06syntax: Switch function parameter order in `TokenTree::token`Vadim Petrochenkov-2/+3
2019-06-06syntax: Remove duplicate span from `token::Ident`Vadim Petrochenkov-1/+1
2019-06-06syntax: Use `Token` in `TokenTree::Token`Vadim Petrochenkov-4/+6
2019-05-29Introduce and use `SyntaxContext::outer_expn_info()`.Nicholas Nethercote-1/+1
It reduces two `hygiene_data` accesses to one on some hot paths.
2019-05-27Pass symbols to `ExtCtxt::std_path` instead of strings.Nicholas Nethercote-2/+2
Because this function is hot. Also remove the dead `ty_option` function.
2019-05-24review commentsEsteban Küber-6/+2
2019-05-24Tweak macro parse errors when reaching EOF during macro call parseEsteban Küber-1/+5
- Add detail on origin of current parser when reaching EOF and stop saying "found <eof>" and point at the end of macro calls - Handle empty `cfg_attr` attribute - Reword empty `derive` attribute error
2019-05-22Simplify use of keyword symbolsVadim Petrochenkov-2/+2
2019-05-21Move `edition` outside the hygiene lock and avoid accessing itJohn Kåre Alsaker-3/+5
2019-05-13Remove the equality operation between `Symbol` and strings.Nicholas Nethercote-2/+2
And also the equality between `Path` and strings, because `Path` is made up of `Symbol`s.
2019-05-02don't amplify errors in format! with bad literalsAleksey Kladov-0/+1
2019-02-18Remove `LazyTokenStream`.Nicholas Nethercote-1/+1
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-17/+17
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-11Parallel rustc needs synchronizing smart pointer cloningOliver Scherer-3/+3
2019-02-11Use `Rc<[Symbol]>` instead of `Vec<Symbol>` to reduce # of allocsOliver Scherer-3/+3
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-7/+13
2019-02-10rustc: doc commentsAlexander Regueiro-17/+17
2019-02-07libsyntax => 2018Taiki Endo-42/+43
2019-02-06Overhaul `syntax::fold::Folder`.Nicholas Nethercote-25/+23
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-01-26Pretty print `$crate` as `crate` or `crate_name` in more casesVadim Petrochenkov-14/+2
2018-12-30Improve error recovery for some built-in macrosVadim Petrochenkov-4/+5
2018-12-28Auto merge of #57155 - petrochenkov:dcrate3, r=dtolnaybors-0/+14
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/+14