about summary refs log tree commit diff
path: root/src/libsyntax/ext
AgeCommit message (Collapse)AuthorLines
2019-08-29Rollup merge of #63867 - petrochenkov:dhelpers, r=matthewjasperMazdak Farrokhzad-54/+86
resolve: Block expansion of a derive container until all its derives are resolved So, it turns out there's one more reason to block expansion of a `#[derive]` container until all the derives inside it are resolved, beside `Copy` (https://github.com/rust-lang/rust/pull/63248). The set of derive helper attributes registered by derives in the container also has to be known before the derives themselves are expanded, otherwise it may be too late (see https://github.com/rust-lang/rust/pull/63468#issuecomment-524550872 and the `#[stable_hasher]`-related test failures in https://github.com/rust-lang/rust/pull/63468). So, we stop our attempts to unblock the container earlier, as soon as the `Copy` status is known, and just block until all its derives are resolved. After all the derives are resolved we immediately go and process their helper attributes in the item, without delaying it until expansion of the individual derives. Unblocks https://github.com/rust-lang/rust/pull/63468 r? @matthewjasper (as a reviewer of https://github.com/rust-lang/rust/pull/63248) cc @c410-f3r
2019-08-28Auto merge of #63127 - kper:pr, r=nikomatsakisbors-6/+6
Cleanup: Consistently use `Param` instead of `Arg` #62426 Fixes #62426
2019-08-27Cleanup: Consistently use `Param` instead of `Arg` #62426Kevin Per-6/+6
2019-08-27proc_macro: Update `Span::def_site` to use the proc macro definition locationVadim Petrochenkov-4/+3
Which is no longer dummy and is available from metadata now.
2019-08-27Respect attributes on proc macro definitionsVadim Petrochenkov-59/+78
2019-08-27resolve: Block expansion of a derive container until all its derives are ↵Vadim Petrochenkov-54/+86
resolved Also mark derive helpers as known as a part of the derive container's expansion instead of expansion of the derives themselves which may happen too late.
2019-08-25Rollup merge of #63854 - c410-f3r:attrs-visit, r=petrochenkovMazdak Farrokhzad-3/+7
Modifies how Arg, Arm, Field, FieldPattern and Variant are visited Part of the necessary work to accomplish #63468.
2019-08-24Modifies how Arg, Arm, Field, FieldPattern and Variant are visitedCaio-3/+7
Part of the necessary work to accomplish #63468.
2019-08-23Remove default macro transparenciesVadim Petrochenkov-21/+0
All transparancies are passed explicitly now. Also remove `#[rustc_macro_transparency]` annotations from built-in macros, they are no longer used. `#[rustc_macro_transparency]` only makes sense for declarative macros now.
2019-08-23hygiene: Require passing transparency explicitly to `apply_mark`Vadim Petrochenkov-33/+46
2019-08-23Audit uses of `apply_mark` in built-in macrosVadim Petrochenkov-17/+25
Replace them with equivalents of `Span::{def_site,call_site}` from proc macro API. The new API is much less error prone and doesn't rely on macros having default transparency.
2019-08-21resolve/expand: Rename some things for clarity and add commentsVadim Petrochenkov-4/+7
2019-08-21expand: Do not do questionable span adjustment before eagerly expanding an ↵Vadim Petrochenkov-4/+1
expression Maybe it made sense when it was introduced, but now it's doing something incorrect.
2019-08-21expand: Keep the correct current expansion ID for eager expansionsVadim Petrochenkov-1/+0
Solve the problem of `ParentScope` entries for eager expansions not exising in the resolver map by creating them on demand.
2019-08-17resolve/expand: Rename some things for clarityVadim Petrochenkov-19/+21
2019-08-16Rollup merge of #63525 - matklad:centraliza-file-loading, r=petrochenkovMazdak Farrokhzad-8/+5
Make sure that all file loading happens via SourceMap That way, callers don't need to repeat "let's add this to sm manually for tracking dependencies" trick. It should make it easier to switch to using `FileLoader` for binary files in the future as well cc #62948 r? @petrochenkov
2019-08-15hygiene: `ExpnInfo` -> `ExpnData`Vadim Petrochenkov-20/+20
For naming consistency with everything else in this area
2019-08-15hygiene: Merge `ExpnInfo` and `InternalExpnData`Vadim Petrochenkov-8/+12
2019-08-15hygiene: Remove `Option`s from functions returning `ExpnInfo`Vadim Petrochenkov-17/+10
The expansion info is not optional and should always exist
2019-08-15`Ident::with_empty_ctxt` -> `Ident::with_dummy_span`Vadim Petrochenkov-6/+6
`Ident` has had a full span rather than just a `SyntaxContext` for a long time now.
2019-08-15syntax_pos: `NO_EXPANSION`/`SyntaxContext::empty()` -> `SyntaxContext::root()`Vadim Petrochenkov-3/+3
For consistency with `ExpnId::root`. Also introduce a helper `Span::with_root_ctxt` for creating spans with `SyntaxContext::root()` context
2019-08-15Remove `Spanned` from `{ast,hir}::FieldPat`Vadim Petrochenkov-1/+1
2019-08-15Remove `Spanned` from `ast::Mac`Vadim Petrochenkov-8/+8
2019-08-15Remove `Spanned` from `mk_name_value_item_str` and `expr_to_spanned_string`Vadim Petrochenkov-7/+9
2019-08-15Make sure that all file loading happens via SourceMapAleksey Kladov-8/+5
That way, callers don't need to repeat "let's add this to sm manually for tracking dependencies" trick. It should make it easier to switch to using `FileLoader` for binary files in the future as well
2019-08-14Rollup merge of #63543 - c410-f3r:variant, r=c410-f3rMazdak Farrokhzad-8/+8
Merge Variant and Variant_ Extracted from #63468.
2019-08-14Rollup merge of #63542 - c410-f3r:node_ids, r=petrochenkovMazdak Farrokhzad-0/+2
Add NodeId for Arm, Field and FieldPat Extracted from #63468
2019-08-14Rollup merge of #63537 - petrochenkov:novisit, r=alexcrichtonMazdak Farrokhzad-19/+13
expand: Unimplement `MutVisitor` on `MacroExpander` Each call to `fully_expand_fragment` is something unique, interesting, and requiring attention. It represents a "root" of expansion and its use means that something unusual is happening, like eager expansion or expansion performed outside of the primary expansion pass. So, it shouldn't hide under a generic visitor call. Also, from all the implemented visitor methods only two were actually used. cc https://github.com/rust-lang/rust/pull/63468#discussion_r313504119
2019-08-14Merge Variant and Variant_Caio-8/+8
2019-08-13Add NodeId for Arm, Field and FieldPatCaio-0/+2
2019-08-14expand: Unimplement `MutVisitor` on `MacroExpander`Vadim Petrochenkov-17/+11
Each call to `fully_expand_fragment` is something unique, interesting, and requiring attention. It represents a "root" of expansion and its use means that something unusual is happening, like eager expansion or expansion performed outside of the primary expansion pass. So, it shouldn't be hide under a generic visitor call. Also, from all the implemented visitor methods only two were actually used.
2019-08-14expand: `expand_fragment` -> `fully_expand_fragment`Vadim Petrochenkov-6/+6
2019-08-13syntax: Remove `DummyResult::expn_only`Vadim Petrochenkov-33/+6
2019-08-10resolve: Remove remaining special cases from built-in macrosVadim Petrochenkov-3/+3
2019-08-09review comments: use structured suggestionEsteban Küber-34/+36
2019-08-09More explicit diagnostic when using a `vec![]` in a patternEsteban Küber-6/+45
``` error: unexpected `(` after qualified path --> $DIR/vec-macro-in-pattern.rs:3:14 | LL | Some(vec![x]) => (), | ^^^^^^^ | | | unexpected `(` after qualified path | in this macro invocation | use a slice pattern here instead | = help: for more information, see https://doc.rust-lang.org/edition-guide/rust-2018/slice-patterns.html = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) ```
2019-08-06Rollup merge of #63272 - Mark-Simulacrum:clean-attr, r=petrochenkovMazdak Farrokhzad-5/+4
Some more libsyntax::attr cleanup Much smaller patch than the last one, mostly just finishing up by removing some Span arguments. r? @petrochenkov
2019-08-05Drop explicit span argument from mk_name_value_itemMark Rousskov-2/+1
2019-08-05Drop span argument from mk_list_itemMark Rousskov-3/+3
2019-08-05add unknown tokenAleksey Kladov-1/+1
2019-08-05Auto merge of #63248 - petrochenkov:nomarker, r=matthewjasperbors-51/+26
Move special treatment of `derive(Copy, PartialEq, Eq)` from expansion infrastructure to elsewhere As described in https://github.com/rust-lang/rust/pull/62086#issuecomment-515195477. Reminder: - `derive(PartialEq, Eq)` makes the type it applied to a "structural match" type, so constants of this type can be used in patterns (and const generics in the future). - `derive(Copy)` notifies other derives that the type it applied to implements `Copy`, so `derive(Clone)` can generate optimized code and other derives can generate code working with `packed` types and types with `rustc_layout_scalar_valid_range` attributes. First, the special behavior is now enabled after properly resolving the derives, rather than after textually comparing them with `"Copy"`, `"PartialEq"` and `"Eq"` in `fn add_derived_markers`. The markers are no longer kept as attributes in AST since derives cannot modify items and previously did it through hacks in the expansion infra. Instead, the markers are now kept in a "global context" available from all the necessary places, namely - resolver. For `derive(PartialEq, Eq)` the markers are created by the derive macros themselves and then consumed during HIR lowering to add the `#[structural_match]` attribute in HIR. This is still a hack, but now it's a hack local to two specific macros rather than affecting the whole expansion infra. Ideally we should find the way to put `#[structural_match]` on the impls rather than on the original item, and then consume it in `rustc_mir`, then no hacks in expansion and lowering will be required. (I'll make an issue about this for someone else to solve, after this PR lands.) The marker for `derive(Copy)` cannot be emitted by the `Copy` macro itself because we need to know it *before* the `Copy` macro is expanded for expanding other macros. So we have to do it in resolve and block expansion of any derives in a `derive(...)` container until we know for sure whether this container has `Copy` in it or not. Nasty stuff. r? @eddyb or @matthewjasper
2019-08-04Auto merge of #63213 - varkor:itemkind-tyalias, r=Centrilbors-1/+1
Rename `ItemKind::Ty` to `ItemKind::TyAlias` The current name is not entirely clear without context and `TyAlias` is consistent with `ItemKind::TraitAlias`.
2019-08-04Rename `ItemKind::Ty` to `ItemKind::TyAlias`varkor-1/+1
2019-08-04Auto merge of #62816 - estebank:type-ascription-macros, r=petrochenkovbors-2/+11
Point at type ascription before macro invocation on expansion parse error Fix https://github.com/rust-lang/rust/issues/47666. Follow up to https://github.com/rust-lang/rust/pull/62791. r? @petrochenkov
2019-08-03Move special treatment of `derive(Copy, PartialEq, Eq)` from expansion ↵Vadim Petrochenkov-51/+26
infrastructure to elsewhere
2019-08-03Rollup merge of #63146 - Mark-Simulacrum:clean-attr, r=petrochenkovMazdak Farrokhzad-411/+145
Cleanup syntax::attr Mostly removing needless arguments to constructors r? @petrochenkov
2019-08-03Rollup merge of #62954 - ia0:fix_typo_span, r=CentrilMazdak Farrokhzad-2/+2
Fix typo in Delimited::open_tt
2019-08-01Allow trailing comma in macro 2.0 declarations.Robert Bartlensky-1/+4
2019-07-31Use Ident::new over setting span position via builderMark Rousskov-4/+4
2019-07-31Replace AstBuilder with inherent methodsMark Rousskov-400/+130