about summary refs log tree commit diff
path: root/src/librustc_expand
AgeCommit message (Collapse)AuthorLines
2020-02-14Fix a typo in a variable name.Nicholas Nethercote-3/+4
2020-02-14Avoid `base_parser`, it's not needed.Nicholas Nethercote-14/+11
2020-02-13Rollup merge of #69057 - Centril:clean-expand, r=petrochenkovDylan DPC-59/+60
expand: misc cleanups and simplifications Some work I did while trying to understand expand for the purposes of https://github.com/rust-lang/rust/issues/64197. r? @petrochenkov
2020-02-13parser: unify item list parsing.Mazdak Farrokhzad-1/+1
as a consequence, `trait X { #![attr] }` becomes legal.
2020-02-13macro_legacy_warnings -> errorMazdak Farrokhzad-8/+5
2020-02-13expand: simplify flat_map_item wrt. inline module detectionMazdak Farrokhzad-7/+4
2020-02-13expand: simplify flat_map_itemMazdak Farrokhzad-5/+1
2020-02-13expand: simplify classify_*Mazdak Farrokhzad-8/+5
2020-02-13expand: extract error_wrong_fragment_kindMazdak Farrokhzad-7/+13
2020-02-13expand: extract error_recursion_limit_reachedMazdak Farrokhzad-11/+16
2020-02-13expand: extract error_derive_forbidden_on_non_adtMazdak Farrokhzad-22/+22
2020-02-13IsAsync -> enum Async { Yes { span: Span, .. }, No }Mazdak Farrokhzad-2/+2
use new span for better diagnostics.
2020-02-13Rollup merge of #68848 - nnethercote:hasten-macro-parsing, r=petrochenkovDylan DPC-51/+62
Hasten macro parsing r? @eddyb
2020-02-11Run RustFmtjumbatm-1/+5
2020-02-11Invert control in struct_lint_level.jumbatm-1/+1
Caller now passes in a `decorate` function, which is only run if the lint is allowed.
2020-02-06Rollup merge of #68788 - Centril:unified-fn-bodies, r=petrochenkovDylan DPC-19/+25
Towards unified `fn` grammar Part of https://github.com/rust-lang/rust/pull/68728. - Syntactically, `fn` items in `extern { ... }` blocks can now have bodies (`fn foo() { ... }` as opposed to `fn foo();`). As above, we use semantic restrictions instead. - Syntactically, `fn` items in free contexts (directly in a file or a module) can now be without bodies (`fn foo();` as opposed to `fn foo() { ... }`. As above, we use semantic restrictions instead, including for non-ident parameter patterns. - We move towards unifying the `fn` front matter; this is fully realized in https://github.com/rust-lang/rust/pull/68728. r? @petrochenkov
2020-02-06Change condition ordering in `parse_tt`.Nicholas Nethercote-6/+6
This is a small win, because `Failure` is much more common than `Success`.
2020-02-06Remove the `Cow` from `Directory`.Nicholas Nethercote-2/+2
The previous commit wrapped `Parser` within a `Cow` for the hot macro parsing path. As a result, there's no need for the `Cow` within `Directory`, because it lies within `Parser`.
2020-02-06Avoid instantiating many `Parser` structs in `generic_extension`.Nicholas Nethercote-45/+56
Currently, every iteration of the main loop in `generic_extension` instantiates a `Parser`, which is expensive because `Parser` is a large type. Many of those instantiations are only used immutably, particularly for simple-but-repetitive macros of the sort seen in `html5ever` and PR 68836. This commit initializes a single "base" parser outside the loop, and then uses `Cow` to avoid cloning it except for the mutating iterations. This speeds up `html5ever` runs by up to 15%.
2020-02-05Rollup merge of #68840 - Centril:rec-lim-curr-crate, r=estebankDylan DPC-2/+2
On suggesting `#![recursion_limit = "X"]`, note current crate name This would have saved me much confusion e.g. when reading the log output in https://github.com/rust-lang/rust/pull/68788#issuecomment-581852191. r? @estebank
2020-02-05`#![recursion_limit = "X"]`: note current crate name.Mazdak Farrokhzad-2/+2
2020-02-05parser: merge `fn` grammars wrt. bodies & headersMazdak Farrokhzad-19/+25
also refactor `FnKind` and `visit_assoc_item` visitors
2020-02-04Rollup merge of #68758 - daboross:fix-59191, r=petrochenkovDylan DPC-1/+11
Fix 59191 - ICE when macro replaces crate root with non-module item Hi, This should fix #59191! My friend and I are working on learning the rustc codebase through contributions, so please feel free to mention anything amiss or that could be done better. The code adds an explicit case for when a macro applied to the crate root (via an inner attribute) replaces it with something nonsensical, like a function. The crate root must be a module, and the error message reflects this. --- I should note that there are a few other weird edge cases here, like if they do output a module, it succeeds but uses that module's name as a prefix for all names in the crate. I'm assuming that's an issue for stabilizing #54726, though.
2020-02-02Change expansion error to be non-fatalDavid-1/+3
Changes the error handler for inner attributes that replace the root with a non-module. Previously it would emit a fatal error. It now emits an empty expasion and a non-fatal error like the existing handler for a failed expansion.
2020-02-01Fix 59191David Ross-1/+9
This adds an explicit error for when macros replace the crate root with a non-module item.
2020-02-01fix fallout in testsMazdak Farrokhzad-5/+5
2020-02-01syntax::print -> new crate rustc_ast_prettyMazdak Farrokhzad-5/+6
2020-02-011. move node_id to syntaxMazdak Farrokhzad-6/+6
2. invert rustc_session & syntax deps 3. drop rustc_session dep in rustc_hir
2020-02-01Move builtin attribute logic to new rustc_attr crate.Mazdak Farrokhzad-3/+4
For now, this is all the crate contains, but more attribute logic & types will be moved there over time.
2020-02-01syntax: simplify HasAttrs codeMazdak Farrokhzad-1/+1
2020-02-01syntax: move GLOBALS to attr moduleMazdak Farrokhzad-1/+1
2020-01-30Use `P` for `NtMeta`.Nicholas Nethercote-1/+2
This commit reduces the size of `Nonterminal` from a 72 bytes to 40 bytes (on x86-64).
2020-01-30Use `P` for `NtTraitItem`, `NtImplItem`, and `NtForeignItem`.Nicholas Nethercote-71/+86
This commit reduces the size of `Nonterminal` from a whopping 240 bytes to 72 bytes (on x86-64), which gets it below the `memcpy` threshold. It also removes some impedance mismatches with `Annotatable`, which already uses `P` for these variants.
2020-01-26rustc_span: move pretty syntax from macro_backtrace to ExpnKind::descr.Eduard-Mihai Burtescu-4/+1
2020-01-20Revert "Add a `constness` field to `ast::TraitRef`"Dylan MacKenzie-1/+1
This reverts commit fd4a6a12136c5b5d6bce4081e95890df1fd1febd.
2020-01-11Rollup merge of #68084 - estebank:ice-68000, r=varkorMazdak Farrokhzad-1/+1
Do not ICE on unicode next point Use `shrink_to_hi` instead of `next_point` and fix `next_point`. Fix #68000, fix #68091, fix #68092.
2020-01-11{syntax -> rustc_ast_passes}::feature_gateMazdak Farrokhzad-2/+2
2020-01-11nix syntax::early_buffered_lintsMazdak Farrokhzad-4/+5
2020-01-11simplify feature_err importsMazdak Farrokhzad-2/+2
2020-01-10Change `next_point` when `shrink_to_hi` is more appropriateEsteban Küber-1/+1
2020-01-10nix syntax::errors & prefer rustc_errors over errorsMazdak Farrokhzad-43/+34
2020-01-09Add a `constness` field to `ast::TraitRef`Dylan MacKenzie-1/+1
This is used for both the `?const` syntax in bounds as well as the `impl const Trait` syntax. I also considered handling these separately by adding a variant of `TraitBoundModifier` and a field to `ItemKind::Impl`, but this approach was less intrusive.
2020-01-04Rollup merge of #67137 - anp:tracked-panic-internals, r=eddybDylan DPC-8/+2
libstd uses `core::panic::Location` where possible. cc @eddyb
2020-01-04core and std macros and panic internals use panic::Location::caller.Adam Perry-8/+2
2020-01-02Normalize `syntax::edition` imports.Mazdak Farrokhzad-2/+2
2020-01-02Normalize `syntax::symbol` imports.Mazdak Farrokhzad-9/+9
2020-01-02Normalize `syntax::source_map` imports.Mazdak Farrokhzad-8/+8
2020-01-01Rename `syntax_pos` to `rustc_span` in source codeVadim Petrochenkov-26/+26
2019-12-31Rollup merge of #67744 - Centril:reduce-diversity, r=petrochenkovMazdak Farrokhzad-4/+6
parser: reduce diversity in error handling mechanisms Instead of having e.g. `span_err`, `fatal`, etc., we prefer to move towards uniformly using `struct_span_err` thus making it harder to emit fatal and/or unstructured diagnostics. This PR also de-fatalizes some diagnostics. r? @estebank
2019-12-31parser::diagnostics: remove fn fatalMazdak Farrokhzad-4/+6