summary refs log tree commit diff
path: root/compiler/rustc_expand/src
AgeCommit message (Collapse)AuthorLines
2022-05-13Use pluralize in one instanceest31-2/+2
2022-05-13Improve name and documentation of generic_extensionest31-3/+4
This function doesn't *create* a (rules based) macro, it *expands* it. Thus, the documentation was wrong.
2022-05-12Auto merge of #96150 - est31:unused_macro_rules, r=petrochenkovbors-12/+30
Implement a lint to warn about unused macro rules This implements a new lint to warn about unused macro rules (arms/matchers), similar to the `unused_macros` lint added by #41907 that warns about entire macros. ```rust macro_rules! unused_empty { (hello) => { println!("Hello, world!") }; () => { println!("empty") }; //~ ERROR: 1st rule of macro `unused_empty` is never used } fn main() { unused_empty!(hello); } ``` Builds upon #96149 and #96156. Fixes #73576
2022-05-11ast: Introduce some traits to get AST node properties genericallyVadim Petrochenkov-119/+70
And use them to avoid constructing some artificial `Nonterminal` tokens during expansion
2022-05-07Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errorsbors-5/+6
Begin fixing all the broken doctests in `compiler/` Begins to fix #95994. All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are. There are also a few that I marked `ignore` that could maybe be made to work but seem less important. Each `ignore` has a rough "reason" for ignoring after it parentheses, with - `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax" - `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy. - `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR. - `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup. Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful. I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool
2022-05-05Implement the unused_macro_rules lintest31-12/+30
2022-05-05Auto merge of #91779 - ridwanabdillahi:natvis, r=michaelwoeristerbors-2/+39
Add a new Rust attribute to support embedding debugger visualizers Implemented [this RFC](https://github.com/rust-lang/rfcs/pull/3191) to add support for embedding debugger visualizers into a PDB. Added a new attribute `#[debugger_visualizer]` and updated the `CrateMetadata` to store debugger visualizers for crate dependencies. RFC: https://github.com/rust-lang/rfcs/pull/3191
2022-05-04Auto merge of #96683 - nnethercote:speed-up-Token-ident-lifetime, r=petrochenkovbors-4/+4
Speed up `Token::{ident,lifetime}` Some speed and cleanliness improvements. r? `@petrochenkov`
2022-05-04Fix spelling of an identifier.Nicholas Nethercote-4/+4
2022-05-03Add support for a new attribute `#[debugger_visualizer]` to support ↵ridwanabdillahi-2/+39
embedding debugger visualizers into a generated PDB. Cleanup `DebuggerVisualizerFile` type and other minor cleanup of queries. Merge the queries for debugger visualizers into a single query. Revert move of `resolve_path` to `rustc_builtin_macros`. Update dependencies in Cargo.toml for `rustc_passes`. Respond to PR comments. Load visualizer files into opaque bytes `Vec<u8>`. Debugger visualizers for dynamically linked crates should not be embedded in the current crate. Update the unstable book with the new feature. Add the tracking issue for the debugger_visualizer feature. Respond to PR comments and minor cleanups.
2022-05-02fix most compiler/ doctestsElliot Roberts-5/+6
2022-04-30Save colon span to suggest bounds.Camille GILLOT-0/+2
2022-04-29errors: `span_suggestion` takes `impl ToString`David Wood-1/+1
Change `span_suggestion` (and variants) to take `impl ToString` rather than `String` for the suggested code, as this simplifies the requirements on the diagnostic derive. Signed-off-by: David Wood <david.wood@huawei.com>
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`