about summary refs log tree commit diff
path: root/src/test/ui/proc-macro/auxiliary
AgeCommit message (Collapse)AuthorLines
2020-09-10Syntactically permit unsafety on modsDavid Tolnay-0/+89
2020-08-03Stabilize Ident::new_rawAaron Hill-0/+35
Tracking issue: #54723 This is a continuation of PR #59002
2020-07-26Add test for serializing hygiene *into* a proc-macro crateAaron Hill-1/+10
This is a very obscure corner case, and should never be hit in practice.
2020-07-01Rollup merge of #73569 - Aaron1011:fix/macro-rules-group, r=petrochenkovManish Goregaokar-0/+33
Handle `macro_rules!` tokens consistently across crates When we serialize a `macro_rules!` macro, we used a 'lowered' `TokenStream` for its body, which has all `Nonterminal`s expanded in-place via `nt_to_tokenstream`. This matters when an 'outer' `macro_rules!` macro expands to an 'inner' `macro_rules!` macro - the inner macro may use tokens captured from the 'outer' macro in its definition. This means that invoking a foreign `macro_rules!` macro may use a different body `TokenStream` than when the same `macro_rules!` macro is invoked in the same crate. This difference is observable by proc-macros invoked by a `macro_rules!` macro - a `None`-delimited group will be seen in the same-crate case (inserted when convering `Nonterminal`s to the `proc_macro` crate's structs), but no `None`-delimited group in the cross-crate case. To fix this inconsistency, we now insert `None`-delimited groups when 'lowering' a `Nonterminal` `macro_rules!` body, just as we do in `proc_macro_server`. Additionally, we no longer print extra spaces for `None`-delimited groups - as far as pretty-printing is concerned, they don't exist (only their contents do). This ensures that `Display` output of a `TokenStream` does not depend on which crate a `macro_rules!` macro was invoked from. This PR is necessary in order to patch the `solana-genesis-programs` for the upcoming hygiene serialization breakage (https://github.com/rust-lang/rust/pull/72121#issuecomment-646924847). The `solana-genesis-programs` crate will need to use a proc macro to re-span certain tokens in a nested `macro_rules!`, which requires us to consistently use a `None`-delimited group. See `src/test/ui/proc-macro/nested-macro-rules.rs` for an example of the kind of nested `macro_rules!` affected by this crate.
2020-07-01Handle `None`-delimited groups when parsing `macro_rules!` macroAaron Hill-0/+12
When a `macro_rules!` macro expands to another `macro_rules!` macro, we may see `None`-delimited groups in odd places when another crate deserializes the 'inner' macro. This commit 'unwraps' an outer `None`-delimited group to avoid breaking existing code. See https://github.com/rust-lang/rust/pull/73569#issuecomment-650860457 for more details. The proper fix is to handle `None`-delimited groups systematically throughout the parser, but that will require significant work. In the meantime, this hack lets us fix important hygiene bugs in macros
2020-07-01Insert NoDelim groups around nonterminals when lowering macro_rulesAaron Hill-0/+21
2020-07-01expand: Stop using nonterminals for passing tokens to attribute and derive ↵Vadim Petrochenkov-22/+21
macros
2020-06-30Add force-host to test aux file used by proc-macroAaron Hill-0/+2
2020-06-29Serialize all foreign `SourceFile`s into proc-macro crate metadataAaron Hill-0/+22
Normally, we encode a `Span` that references a foreign `SourceFile` by encoding information about the foreign crate. When we decode this `Span`, we lookup the foreign crate in order to decode the `SourceFile`. However, this approach does not work for proc-macro crates. When we load a proc-macro crate, we do not deserialzie any of its dependencies (since a proc-macro crate can only export proc-macros). This means that we cannot serialize a reference to an upstream crate, since the associated metadata will not be available when we try to deserialize it. This commit modifies foreign span handling so that we treat all foreign `SourceFile`s as local `SourceFile`s when serializing a proc-macro. All `SourceFile`s will be stored into the metadata of a proc-macro crate, allowing us to cotinue to deserialize a proc-macro crate without needing to load any of its dependencies. Since the number of foreign `SourceFile`s that we load during a compilation session may be very large, we only serialize a `SourceFile` if we have also serialized a `Span` which requires it.
2020-06-15Always capture tokens for `macro_rules!` argumentsAaron Hill-0/+80
2020-05-31test-macros: Avoid always producing errors in `#[derive(Print)]`Vadim Petrochenkov-1/+2
2020-05-03Stabilize fn-like proc macros in expression, pattern and statement positionsVadim Petrochenkov-5/+2
2020-04-26Stabilize `Span::mixed_site`Vadim Petrochenkov-1/+0
2020-04-25Add a test for `Span::resolved_at` and `Span::located_at`Vadim Petrochenkov-0/+32
2020-04-21proc_macro::is_available()David Tolnay-0/+14
2020-03-24resolve: Remove `rustc_attrs` as a standalone feature gateVadim Petrochenkov-0/+32
Now it only gates specific built-in attributes
2020-03-11fix expand-to-unstable testRalf Jung-1/+1
2020-02-17Add a test for proc macro generating `$ IDENT`Vadim Petrochenkov-0/+17
2020-02-01Add tests for issue 59191David Ross-0/+16
2019-11-19resolve: Give derive helpers highest priority during resolutionVadim Petrochenkov-0/+12
2019-11-16Add some more testsVadim Petrochenkov-0/+15
2019-10-15Test basic hygiene for `macro_rules` produced by transparent macrosVadim Petrochenkov-0/+23
2019-10-15Stabilize proc macros generating `macro_rules` itemsVadim Petrochenkov-35/+0
2019-10-03proc_macro: Add `Span::mixed_site` exposing `macro_rules` hygieneVadim Petrochenkov-0/+42
2019-09-30Stabilize macros in `extern` blocksVadim Petrochenkov-26/+0
Add some tests for macros in extern blocks, remove duplicate tests
2019-08-27Respect attributes on proc macro definitionsVadim Petrochenkov-0/+23
2019-08-25pprust: Do not print spaces before some tokensVadim Petrochenkov-4/+4
2019-08-17resolve: Properly integrate derives and `macro_rules` scopesVadim Petrochenkov-0/+12
2019-07-27tests: Move run-pass tests with naming conflicts to uiVadim Petrochenkov-0/+103
2019-07-27tests: Move run-pass tests without naming conflicts to uiVadim Petrochenkov-0/+675
2019-07-09Add a test case with `$crate` from other crateVadim Petrochenkov-0/+6
2019-06-24Address review comments.Mazdak Farrokhzad-0/+1
2019-05-22tests: Centralize proc macros commonly used for testingVadim Petrochenkov-240/+99
2019-04-22Remove double trailing newlinesvarkor-1/+0
2019-03-14Moved issue tests to subdirs and normalised names.Alexander Regueiro-0/+0
2018-12-28Add test demonstrating disintegration of `$crate` into `$` and `crate`Vadim Petrochenkov-0/+7
2018-12-25Remove licensesMark Rousskov-320/+0
2018-12-19Reintroduce special pretty-printing for `$crate` when it's necessary for ↵Vadim Petrochenkov-1/+33
proc macros
2018-12-19proc_macro: Accept `$crate` as an identifier if it comes from the compilerVadim Petrochenkov-0/+12
2018-12-09Fix rebase + Add missing `// force-host`Vadim Petrochenkov-0/+1
2018-12-09Move some tests from ui-fulldeps to uiVadim Petrochenkov-0/+19
2018-12-09Move former compile-fail-fulldeps tests to uiVadim Petrochenkov-0/+596
2018-11-30tests: use `force-host` and `no-prefer-dynamic` in all proc_macro tests.Eduard-Mihai Burtescu-1/+15
2018-11-30tests: move all proc_macro tests from -fulldeps.Eduard-Mihai Burtescu-0/+627