about summary refs log tree commit diff
path: root/src/test/ui-fulldeps/proc-macro
AgeCommit message (Collapse)AuthorLines
2018-12-09Move some tests from ui-fulldeps to uiVadim Petrochenkov-43/+0
2018-11-30tests: move all proc_macro tests from -fulldeps.Eduard-Mihai Burtescu-1878/+0
2018-11-30tests: remove ignore-stage1 where possible in proc_macro tests.Eduard-Mihai Burtescu-17/+16
2018-11-27resolve: Suggest `crate::` for resolving ambiguities when appropriateVadim Petrochenkov-6/+6
More precise spans for ambiguities from macros
2018-11-27resolve: Implement edition hygiene for imports and absolute pathsVadim Petrochenkov-0/+43
Use per-span hygiene in a few other places in resolve Prefer `rust_2015`/`rust_2018` helpers to comparing editions
2018-11-21Stabilize `extern_crate_item_prelude`Vadim Petrochenkov-2/+0
2018-11-19Auto merge of #55971 - SergioBenitez:skip-non-semantic, r=alexcrichtonbors-0/+112
Ignore non-semantic tokens for 'probably_eq' streams. Improves the situation in #43081 by skipping typically non-semantic tokens when checking for 'probably_eq'. r? @alexcrichton
2018-11-18resolve: Tweak some articles in ambiguity diagnosticsVadim Petrochenkov-6/+6
2018-11-18resolve: Improve diagnostics for resolution ambiguitiesVadim Petrochenkov-43/+24
2018-11-18resolve: Simplify ambiguity checking for built-in attributesVadim Petrochenkov-6/+6
2018-11-16Ignore non-semantic tokens for 'probably_eq' streams.Sergio Benitez-0/+112
2018-10-24Feature gate extern prelude additions from `extern crate` itemsVadim Petrochenkov-0/+2
Fix rustdoc and fulldeps tests
2018-10-24Add `extern crate` items to extern preludeVadim Petrochenkov-0/+7
2018-10-02Merge the `proc_macro_` expansion feature gates into a single ↵jeb-4/+4
`proc_macro_hygiene` gate.
2018-10-01Extra proc macro gates are now at #54727Alex Crichton-2/+2
2018-09-25resolve: Do not block derive helper resolutions on single import resolutionsVadim Petrochenkov-7/+6
Derive helpers conflict currently conflict with anything else, so if some resolution from a single import appears later, it will result in error anyway
2018-09-17Auto merge of #54277 - petrochenkov:afterder, r=alexcrichtonbors-3/+3
Temporarily prohibit proc macro attributes placed after derives ... and also proc macro attributes used together with `#[test]`/`#[bench]`. Addresses item 6 from https://github.com/rust-lang/rust/pull/50911#issuecomment-411605393. The end goal is straightforward predictable left-to-right expansion order for attributes. Right now derives are expanded last regardless of their relative ordering with macro attributes and right now it's simpler to temporarily prohibit macro attributes placed after derives than changing the expansion order. I'm not sure whether the new beta is already released or not, but if it's released, then this patch needs to be backported, so the solution needs to be minimal. How to fix broken code (derives): - Move macro attributes above derives. This won't change expansion order, they are expanded before derives anyway. Using attribute macros on same items with `#[test]` and `#[bench]` is prohibited for similar expansion order reasons, but this one is going to be reverted much sooner than restrictions on derives. How to fix broken code (test/bench): - Enable `#![feature(plugin)]` (don't ask why). r? @ghost
2018-09-16resolve: Do not error on access to proc macros imported with `#[macro_use]`Vadim Petrochenkov-0/+88
2018-09-16Temporarily prohibit proc macro attributes placed after derivesVadim Petrochenkov-3/+3
... and also proc macro attributes used together with test/bench.
2018-09-15Auto merge of #52896 - SergioBenitez:master, r=alexcrichtonbors-0/+170
Add inspection and setter methods to proc_macro::Diagnostic. A few useful methods for `proc_macro::Diagnostic`. r? @alexcrichton
2018-09-13resolve: Introduce two sub-namespaces in macro namespaceVadim Petrochenkov-0/+29
2018-09-13Add multispan support to proc-macro diagnostics.Sergio Benitez-0/+170
Also updates the issue number for 'proc_macro_diagnostic'.
2018-09-13resolve: Future proof derive helper attributesVadim Petrochenkov-0/+81
2018-09-11resolve: Reserve a few very special names in macro namespaceVadim Petrochenkov-52/+48
2018-09-11resolve: Future proof resolutions for potentially built-in attributesVadim Petrochenkov-0/+242
2018-08-23Stabilize a few secondary macro featuresVadim Petrochenkov-10/+8
`tool_attributes`, `proc_macro_path_invoc`, partially `proc_macro_gen`
2018-08-22Auto merge of #53516 - petrochenkov:derregr, r=estebankbors-0/+26
resolve: Continue search in outer scopes after applying derive resolution fallback Fixes https://github.com/rust-lang/rust/issues/53263
2018-08-20resolve: Refactor away `MacroBinding`Vadim Petrochenkov-3/+3
`fn resolve_legacy_scope` can now resolve only to `macro_rules!` items, `fn resolve_lexical_macro_path_segment` is for everything else - modularized macros, preludes
2018-08-20resolve: Consolidate error reporting for resolved macros in `fn ↵Vadim Petrochenkov-9/+9
resolve_macro_to_def`
2018-08-20resolve: Continue search in outer scopes after applying derive resolution ↵Vadim Petrochenkov-0/+26
fallback
2018-08-17Stabilize `use_extern_macros`Vadim Petrochenkov-21/+14
2018-08-15syntax: Enforce attribute grammar in the parserVadim Petrochenkov-5/+5
2018-08-06Enable macro modularization implicitly if one of "advanced" macro features ↵Vadim Petrochenkov-13/+10
is enabled Do not mark all builtin attributes as used when macro modularization is enabled
2018-08-01resolve: Implement prelude search for macro pathsVadim Petrochenkov-1/+1
resolve/expansion: Implement tool attributes
2018-07-24Auto merge of #52618 - alexcrichton:capture-more, r=petrochenkovbors-0/+79
rustc: Implement tokenization of nested items Ever plagued by #43081 the compiler can return surprising spans in situations related to procedural macros. This is exhibited by #47983 where whenever a procedural macro is invoked in a nested item context it would fail to have correct span information. While #43230 provided a "hack" to cache the token stream used for each item in the compiler it's not a full-blown solution. This commit continues to extend this "hack" a bit more to work for nested items. Previously in the parser the `parse_item` method would collect the tokens for an item into a cache on the item itself. It turned out, however, that nested items were parsed through the `parse_item_` method, so they didn't receive similar treatment. To remedy this situation the hook for collecting tokens was moved into `parse_item_` instead of `parse_item`. Afterwards the token collection scheme was updated to support nested collection of tokens. This is implemented by tracking `TokenStream` tokens instead of `TokenTree` to allow for collecting items into streams at intermediate layers and having them interleaved in the upper layers. All in all, this... Closes #47983
2018-07-22rustc: Implement tokenization of nested itemsAlex Crichton-0/+79
Ever plagued by #43081 the compiler can return surprising spans in situations related to procedural macros. This is exhibited by #47983 where whenever a procedural macro is invoked in a nested item context it would fail to have correct span information. While #43230 provided a "hack" to cache the token stream used for each item in the compiler it's not a full-blown solution. This commit continues to extend this "hack" a bit more to work for nested items. Previously in the parser the `parse_item` method would collect the tokens for an item into a cache on the item itself. It turned out, however, that nested items were parsed through the `parse_item_` method, so they didn't receive similar treatment. To remedy this situation the hook for collecting tokens was moved into `parse_item_` instead of `parse_item`. Afterwards the token collection scheme was updated to support nested collection of tokens. This is implemented by tracking `TokenStream` tokens instead of `TokenTree` to allow for collecting items into streams at intermediate layers and having them interleaved in the upper layers. All in all, this... Closes #47983
2018-07-21Attach deprecation lint `proc_macro_derive_resolution_fallback` to a ↵Vadim Petrochenkov-0/+16
specific node id
2018-07-19proc_macro: Preserve spans of attributes on functionsAlex Crichton-0/+88
This commit updates the tokenization of items which are subsequently passed to `proc_macro` to ensure that span information is preserved on attributes as much as possible. Previously this area of the code suffered from #43081 where we haven't actually implemented converting an attribute to to a token tree yet, but a local fix was possible here. Closes #47941
2018-07-16rustc: Stabilize much of the `proc_macro` featureAlex Crichton-6/+7
This commit stabilizes some of the `proc_macro` language feature as well as a number of APIs in the `proc_macro` crate as [previously discussed][1]. This means that on stable Rust you can now define custom procedural macros which operate as attributes attached to items or `macro_rules!`-like bang-style invocations. This extends the suite of currently stable procedural macros, custom derives, with custom attributes and custom bang macros. Note though that despite the stabilization in this commit procedural macros are still not usable on stable Rust. To stabilize that we'll need to stabilize at least part of the `use_extern_macros` feature. Currently you can define a procedural macro attribute but you can't import it to call it! A summary of the changes made in this PR (as well as the various consequences) is: * The `proc_macro` language and library features are now stable. * Other APIs not stabilized in the `proc_macro` crate are now named under a different feature, such as `proc_macro_diagnostic` or `proc_macro_span`. * A few checks in resolution for `proc_macro` being enabled have switched over to `use_extern_macros` being enabled. This means that code using `#![feature(proc_macro)]` today will likely need to move to `#![feature(use_extern_macros)]`. It's intended that this PR, once landed, will be followed up with an attempt to stabilize a small slice of `use_extern_macros` just for procedural macros to make this feature 100% usable on stable. [1]: https://internals.rust-lang.org/t/help-stabilize-a-subset-of-macros-2-0/7252
2018-07-14Functions introducing procedural macros reserve a slot in the macro ↵Vadim Petrochenkov-0/+206
namespace as well
2018-07-13proc_macro: Fix crate root detectionVadim Petrochenkov-0/+33
2018-07-12Rollup merge of #52276 - alexcrichton:validate-proc-macro-attr, r=petrochenkovkennytm-0/+74
rustc: Verify #[proc_macro] is only a word ... and perform the same verification for #[proc_macro_attribute], currently neither of these attributes take any arguments. Closes #52273
2018-07-11rustc: Verify #[proc_macro] is only a wordAlex Crichton-0/+74
... and perform the same verification for #[proc_macro_attribute], currently neither of these attributes take any arguments. Closes #52273
2018-07-08Remove fallback to parent modules from lexical resolutionVadim Petrochenkov-5/+81
2018-07-08hygiene: Decouple transparencies from expansion IDsVadim Petrochenkov-0/+58
2018-05-25Rename TokenStream::empty to TokenStream::newDavid Tolnay-1/+1
There is no precedent for the `empty` name -- we do not have `Vec::empty` or `HashMap::empty` etc.
2018-05-22rustc: Correctly pretty-print macro delimitersAlex Crichton-0/+57
This commit updates the `Mac_` AST structure to keep track of the delimiters that it originally had for its invocation. This allows us to faithfully pretty-print macro invocations not using parentheses (e.g. `vec![...]`). This in turn helps procedural macros due to #43081. Closes #50840
2018-05-16Fix stability annotations for already stable bits of proc macro API 1.1Vadim Petrochenkov-3/+3
Remove unnecessary proc-macro-related `feature`s
2018-05-15TokenTree: Op -> Punct, Term -> IdentVadim Petrochenkov-2/+2
2018-04-20rustc: Tweak custom attribute capabilitiesAlex Crichton-2/+2
This commit starts to lay some groundwork for the stabilization of custom attribute invocations and general procedural macros. It applies a number of changes discussed on [internals] as well as a [recent issue][issue], namely: * The path used to specify a custom attribute must be of length one and cannot be a global path. This'll help future-proof us against any ambiguities and give us more time to settle the precise syntax. In the meantime though a bare identifier can be used and imported to invoke a custom attribute macro. A new feature gate, `proc_macro_path_invoc`, was added to gate multi-segment paths and absolute paths. * The set of items which can be annotated by a custom procedural attribute has been restricted. Statements, expressions, and modules are disallowed behind two new feature gates: `proc_macro_expr` and `proc_macro_mod`. * The input to procedural macro attributes has been restricted and adjusted. Today an invocation like `#[foo(bar)]` will receive `(bar)` as the input token stream, but after this PR it will only receive `bar` (the delimiters were removed). Invocations like `#[foo]` are still allowed and will be invoked in the same way as `#[foo()]`. This is a **breaking change** for all nightly users as the syntax coming in to procedural macros will be tweaked slightly. * Procedural macros (`foo!()` style) can only be expanded to item-like items by default. A separate feature gate, `proc_macro_non_items`, is required to expand to items like expressions, statements, etc. Closes #50038 [internals]: https://internals.rust-lang.org/t/help-stabilize-a-subset-of-macros-2-0/7252 [issue]: https://github.com/rust-lang/rust/issues/50038