about summary refs log tree commit diff
path: root/compiler/rustc_expand
AgeCommit message (Collapse)AuthorLines
2022-04-28rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter`Vadim Petrochenkov-61/+54
2022-04-28Rollup merge of #96471 - BoxyUwU:let_else_considered_harmful, r=lcnrDylan DPC-3/+1
replace let else with `?` r? `@oli-obk`
2022-04-27tut tut tutEllen-3/+1
2022-04-27Avoid producing `NoDelim` values in `Frame`.Nicholas Nethercote-11/+11
The code currently ignores the actual delimiter on the RHS and fakes up a `NoDelim`/`DelimSpan::dummy()` one. This commit changes it to use the actual delimiter. The commit also reorders the fields for the `Delimited` variant to match the `Sequence` variant.
2022-04-22start tracking proc-macros expansion spans in the self-profilerRémy Rakic-3/+12
2022-04-16Rollup merge of #96023 - matthiaskrgr:clippyper1304, r=lcnrDylan DPC-1/+1
couple of clippy::perf fixes
2022-04-15Rollup merge of #96027 - matthiaskrgr:clippy_rec, r=fee1-deadDylan DPC-27/+13
remove function parameters only used in recursion
2022-04-15Rollup merge of #96026 - matthiaskrgr:clippy_compl_1304, r=Dylan-DPCDylan DPC-1/+1
couple of clippy::complexity fixes
2022-04-15Rollup merge of #94461 - jhpratt:2024-edition, r=pnkfelixDylan DPC-1/+1
Create (unstable) 2024 edition [On Zulip](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Deprecating.20macro.20scoping.20shenanigans/near/272860652), there was a small aside regarding creating the 2024 edition now as opposed to later. There was a reasonable amount of support and no stated opposition. This change creates the 2024 edition in the compiler and creates a prelude for the 2024 edition. There is no current difference between the 2021 and 2024 editions. Cargo and other tools will need to be updated separately, as it's not in the same repository. This change permits the vast majority of work towards the next edition to proceed _now_ instead of waiting until 2024. For sanity purposes, I've merged the "hello" UI tests into a single file with multiple revisions. Otherwise we'd end up with a file per edition, despite them being essentially identical. ````@rustbot```` label +T-lang +S-waiting-on-review Not sure on the relevant team, to be honest.
2022-04-14remove reudndant function param in check_matcher_core()Matthias Krüger-19/+7
2022-04-14remove function param that is only used in recursive of fn inner()Matthias Krüger-8/+6
2022-04-14Auto merge of #95928 - nnethercote:rm-TokenTree-Clone, r=petrochenkovbors-106/+164
Remove `<mbe::TokenTree as Clone>` `mbe::TokenTree` doesn't really need to implement `Clone`, and getting rid of that impl leads to some speed-ups. r? `@petrochenkov`
2022-04-14`mbe::TokenTree`: remove `Lrc` around `Delimited` and `SequenceRepetition`.Nicholas Nethercote-19/+10
2022-04-14Introduce `TtHandle` and use it in `TokenSet`.Nicholas Nethercote-53/+111
This removes the last use of `<mbe::TokenTree as Clone>`. It also removes two trivial methods on `Delimited`.
2022-04-13couple of clippy::complexity fixesMatthias Krüger-1/+1
2022-04-13couple of clippy::perf fixesMatthias Krüger-1/+1
2022-04-13errors: lazily load fallback fluent bundleDavid Wood-2/+2
Loading the fallback bundle in compilation sessions that won't go on to emit any errors unnecessarily degrades compile time performance, so lazily create the Fluent bundle when it is first required. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-13Pass a slice instead of a `Vec` to `transcribe`.Nicholas Nethercote-3/+3
It avoids some unnecessary allocations.
2022-04-13Avoid use of `Lrc` in `mbe::Frame`.Nicholas Nethercote-29/+38
This is a nice performance win on some crates.
2022-04-13`SequenceRepetition` and `Delimited` don't need to be `Clone`.Nicholas Nethercote-2/+2
2022-04-11Add a useful comment.Nicholas Nethercote-0/+4
2022-04-11Tweak `NamedMatch` representation.Nicholas Nethercote-27/+7
The `Lrc` isn't necessary, neither is the `SmallVec`. Performance is changed negligibly, but the new code is simpler.
2022-04-11Change internal naming of macros.Nicholas Nethercote-1/+2
When a `macro_rules! foo { ... }` invocation is compiled the name used is `foo`, not `macro_rules!`. This is different to all other macro invocations, and confused me when I was inserted debugging println statements for macro evaluation. This commit changes it to `macro_rules` (or just `macro`), which is what I expected. There are no externally visible changes.
2022-04-09Rollup merge of #95808 - petrochenkov:fragspec, r=nnethercoteDylan DPC-20/+21
expand: Remove `ParseSess::missing_fragment_specifiers` It was used for deduplicating some errors for legacy code which are mostly deduplicated even without that, but at cost of global mutable state, which is not a good tradeoff. cc https://github.com/rust-lang/rust/pull/95747#issuecomment-1091619403 r? ``@nnethercote``
2022-04-09Rollup merge of #95805 - c410-f3r:meta-vars, r=petrochenkovDylan DPC-1/+0
Left overs of #95761 These are just nits. Feel free to close this PR if all modifications are not worth merging. * `#![feature(decl_macro)]` is not needed anymore in `rustc_expand` * `tuple_impls` does not require `$Tuple:ident`. I guess it is there to enhance readability? r? ```@petrochenkov```
2022-04-09Auto merge of #95697 - klensy:no-strings, r=petrochenkovbors-2/+2
refactor: simplify few string related interactions Few small optimizations: check_doc_keyword: don't alloc string for emptiness check check_doc_alias_value: get argument as Symbol to prevent needless string convertions check_doc_attrs: don't alloc vec, iterate over slice. replace as_str() check with symbol check get_single_str_from_tts: don't prealloc string trivial string to str replace LifetimeScopeForPath::NonElided use Vec<Symbol> instead of Vec<String> AssertModuleSource use FxHashSet<Symbol> instead of BTreeSet<String> CrateInfo.crate_name replace FxHashMap<CrateNum, String> with FxHashMap<CrateNum, Symbol>
2022-04-09expand: Remove `ParseSess::missing_fragment_specifiers`Vadim Petrochenkov-20/+21
It was used for deduplicating some errors for legacy code which are mostly deduplicated even without that, but at cost of global mutable state, which is not a good tradeoff.
2022-04-09Rollup merge of #95797 - nnethercote:rm-Delimited-all_tts, r=petrochenkovDylan DPC-96/+58
Remove explicit delimiter token trees from `Delimited`. They were introduced by the final commit in #95159 and gave a performance win. But since the introduction of `MatcherLoc` they are no longer needed. This commit reverts that change, making the code a bit simpler. r? `@petrochenkov`
2022-04-09Remove explicit delimiter token trees from `Delimited`.Nicholas Nethercote-96/+58
They were introduced by the final commit in #95159 and gave a performance win. But since the introduction of `MatcherLoc` they are no longer needed. This commit reverts that change, making the code a bit simpler.
2022-04-08Left overs of #95761Caio-1/+0
2022-04-08Rollup merge of #95761 - c410-f3r:meta-var-stuff, r=petrochenkovDylan DPC-4/+3
Kickstart the inner usage of `macro_metavar_expr` There can be more use-cases but I am out of ideas. cc #83527 r? ``@petrochenkov``
2022-04-08check_doc_keyword: don't alloc string for emptiness checkklensy-2/+2
check_doc_alias_value: get argument as Symbol to prevent needless string convertions check_doc_attrs: don't alloc vec, iterate over slice. Vec introduced in #83149, but no perf run posted on merge replace as_str() check with symbol check get_single_str_from_tts: don't prealloc string trivial string to str replace LifetimeScopeForPath::NonElided use Vec<Symbol> instead of Vec<String> AssertModuleSource use BTreeSet<Symbol> instead of BTreeSet<String> CrateInfo.crate_name replace FxHashMap<CrateNum, String> with FxHashMap<CrateNum, Symbol>
2022-04-07Auto merge of #95715 - nnethercote:shrink-Nonterminal, r=davidtwcobors-2/+2
Shrink `Nonterminal` Small consistency and performance improvements. r? `@petrochenkov`
2022-04-07Kickstart the inner usage of macro_metavar_exprCaio-4/+3
2022-04-07Use gender neutral termsJames 'zofrex' Sanderson-1/+1
2022-04-07Shrink `Nonterminal`.Nicholas Nethercote-2/+2
By heap allocating the argument within `NtPath`, `NtVis`, and `NtStmt`. This slightly reduces cumulative and peak allocation amounts, most notably on `deep-vector`.
2022-04-06Auto merge of #95669 - nnethercote:call-compute_locs-once-per-rule, ↵bors-149/+169
r=petrochenkov Call `compute_locs` once per rule This fixes the small regressions on `wg-grammar` and `hyper-0.14.18` seen in #95555. r? `@petrochenkov`
2022-04-06Call `compute_locs` once per rule.Nicholas Nethercote-114/+123
Currently it's called in `parse_tt` every time a match rule is invoked. This commit moves it so it's called instead once per match rule, in `compile_declarative_macro. This is a performance win. The commit also moves `compute_locs` out of `TtParser`, because there's no longer any reason for it to be in there.
2022-04-05Rollup merge of #95473 - lqd:macro-expansion, r=petrochenkovDylan DPC-10/+24
track individual proc-macro expansions in the self-profiler As described in [this zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Macro.20expansion.20performance.20on.20complex.20macros/near/275063190), users don't currently have a lot of information to diagnose macro expansion performance issues. That comment suggests using the macro names to add further timing information. This PR starts to do this for proc-macros which have the same issue, and performance problems happening in the wild in [this other zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/Identifying.20proc-macro.20slowdowns) could be helped by such information. It uses the available proc-macro name to track their individual expansions with self-profiling events. r? `@Aaron1011` who mentioned this idea originally
2022-04-05track proc-macro expansions in the self-profilerRémy Rakic-10/+24
Use the proc-macro descr to track their individual expansions with self-profiling events. This will help diagnose performance issues with slow proc-macros.
2022-04-05Move the missing fragment identifier checking.Nicholas Nethercote-47/+58
In #95555 this was moved out of `parse_tt_inner` and `nameize` into `compute_locs`. But the next commit will be moving `compute_locs` outwards to a place that isn't suitable for the missing fragment identifier checking. So this reinstates the old checking.
2022-04-05Remove the lifetime from `TtParser` and `MatcherLoc`.Nicholas Nethercote-14/+14
It's a slight performance loss for now, but that will be recouped by the next commit.
2022-04-05session: opt for enabling directionality markersDavid Wood-2/+2
Add an option for enabling and disabling Fluent's directionality isolation markers in output. Disabled by default as these can render in some terminals and applications. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05errors: implement sysroot/testing bundle loadingDavid Wood-1/+3
Extend loading of Fluent bundles so that bundles can be loaded from the sysroot based on the language requested by the user, or using a nightly flag. Sysroot bundles are loaded from `$sysroot/share/locale/$locale/*.ftl`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05errors: implement fallback diagnostic translationDavid Wood-9/+13
This commit updates the signatures of all diagnostic functions to accept types that can be converted into a `DiagnosticMessage`. This enables existing diagnostic calls to continue to work as before and Fluent identifiers to be provided. The `SessionDiagnostic` derive just generates normal diagnostic calls, so these APIs had to be modified to accept Fluent identifiers. In addition, loading of the "fallback" Fluent bundle, which contains the built-in English messages, has been implemented. Each diagnostic now has "arguments" which correspond to variables in the Fluent messages (necessary to render a Fluent message) but no API for adding arguments has been added yet. Therefore, diagnostics (that do not require interpolation) can be converted to use Fluent identifiers and will be output as before.
2022-04-05span: move `MultiSpan`David Wood-7/+8
`MultiSpan` contains labels, which are more complicated with the introduction of diagnostic translation and will use types from `rustc_errors` - however, `rustc_errors` depends on `rustc_span` so `rustc_span` cannot use types like `DiagnosticMessage` without dependency cycles. Introduce a new `rustc_error_messages` crate that can contain `DiagnosticMessage` and `MultiSpan`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05errors: introduce `DiagnosticMessage`David Wood-4/+5
Introduce a `DiagnosticMessage` type that will enable diagnostic messages to be simple strings or Fluent identifiers. `DiagnosticMessage` is now used in the implementation of the standard `DiagnosticBuilder` APIs. Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-04Auto merge of #95653 - Dylan-DPC:rollup-2p9hzi3, r=Dylan-DPCbors-8/+8
Rollup of 7 pull requests Successful merges: - #92942 (stabilize windows_process_extensions_raw_arg) - #94817 (Release notes for 1.60.0) - #95343 (Reduce unnecessary escaping in proc_macro::Literal::character/string) - #95431 (Stabilize total_cmp) - #95438 (Add SyncUnsafeCell.) - #95467 (Windows: Synchronize asynchronous pipe reads and writes) - #95609 (Suggest borrowing when trying to coerce unsized type into `dyn Trait`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-04-04Rollup merge of #95343 - dtolnay:literals, r=petrochenkovDylan DPC-8/+8
Reduce unnecessary escaping in proc_macro::Literal::character/string I noticed that https://doc.rust-lang.org/proc_macro/struct.Literal.html#method.character is producing unreadable literals that make macro-expanded code unnecessarily hard to read. Since the proc macro server was using `escape_unicode()`, every char is escaped using `\u{…}` regardless of whether there is any need to do so. For example `Literal::character('=')` would previously produce `'\u{3d}'` which unnecessarily obscures the meaning when reading the macro-expanded code. I've changed Literal::string also in this PR because `str`'s `Debug` impl is also smarter than just calling `escape_debug` on every char. For example `Literal::string("ferris's")` would previously produce `"ferris\'s"` but will now produce `"ferris's"`.
2022-04-04Reorder match arms in `parse_tt_inner`.Nicholas Nethercote-31/+31
To match the order the variants are declared in.