about summary refs log tree commit diff
path: root/src/libsyntax/ext/tt/macro_rules.rs
AgeCommit message (Collapse)AuthorLines
2019-09-22rename libsyntax::ext::tt to mbeAleksey Kladov-1173/+0
mbe stands for macro-by-example
2019-09-22reduce visibility of a bunch of stuff in ext::ttAleksey Kladov-5/+9
2019-09-16Use `Symbol` in two more functions.Nicholas Nethercote-22/+22
2019-08-27Respect attributes on proc macro definitionsVadim Petrochenkov-57/+13
2019-08-23Remove default macro transparenciesVadim Petrochenkov-1/+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-8/+13
2019-08-09review comments: use structured suggestionEsteban Küber-19/+34
2019-08-09More explicit diagnostic when using a `vec![]` in a patternEsteban Küber-0/+23
``` 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-05Auto merge of #63248 - petrochenkov:nomarker, r=matthewjasperbors-1/+4
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 #62816 - estebank:type-ascription-macros, r=petrochenkovbors-0/+1
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-1/+4
infrastructure to elsewhere
2019-08-03Rollup merge of #62954 - ia0:fix_typo_span, r=CentrilMazdak Farrokhzad-1/+1
Fix typo in Delimited::open_tt
2019-08-01Allow trailing comma in macro 2.0 declarations.Robert Bartlensky-1/+4
2019-07-30Point at type ascription before macro invocation on expansion parse errorEsteban Küber-0/+1
2019-07-27Fix typo in Delimited::open_ttJulien Cretin-1/+1
2019-07-26Auto merge of #62086 - petrochenkov:builtout, r=eddybbors-0/+1
Define built-in macros through libcore This PR defines built-in macros through libcore using a scheme similar to lang items (attribute `#[rustc_builtin_macro]`). All the macro properties (stability, visibility, etc.) are taken from the source code in libcore, with exception of the expander function transforming input tokens/AST into output tokens/AST, which is still provided by the compiler. The macros are made available to user code through the standard library prelude (`{core,std}::prelude::v1`), so they are still always in scope. As a result **built-in macros now have stable absolute addresses in the library**, like `core::prelude::v1::line!()`, this is an insta-stable change. Right now `prelude::v1` is the only publicly available absolute address for these macros, but eventually they can be moved into more appropriate locations with library team approval (e.g. `Clone` derive -> `core::clone::Clone`). Now when built-in macros have canonical definitions they can be imported or reexported without issues (https://github.com/rust-lang/rust/issues/61687). Other changes: - You can now define a derive macro with a name matching one of the built-in derives (https://github.com/rust-lang/rust/issues/52269). This was an artificial restriction that could be worked around with import renaming anyway. Known regressions: - Empty library crate with a crate-level `#![test]` attribute no longer compiles without `--test`. Previously it didn't compile *with* `--test` or with the bin crate type. Fixes https://github.com/rust-lang/rust/issues/61687 Fixes https://github.com/rust-lang/rust/issues/61804 r? @eddyb
2019-07-26Rollup merge of #62983 - Mark-Simulacrum:remove-needless-rc, r=petrochenkovMazdak Farrokhzad-2/+2
Remove needless indirection through Rc NamedMatch is already cheap to clone due to Lrc's inside.
2019-07-26Introduce built-in macros through libcoreVadim Petrochenkov-0/+1
2019-07-25Implement slow-path for FirstSets::firstJulien Cretin-27/+26
When 2 or more sequences share the same span, we can't use the precomputed map for their first set. So we compute it recursively. Fixes #62831.
2019-07-25Remove needless indirection through RcMark Rousskov-2/+2
NamedMatch is already cheap to clone due to Lrc's inside.
2019-07-19Implement checks for meta-variables in macrosJulien Cretin-46/+6
2019-07-19Remember the span of the Kleene operator in macrosJulien Cretin-8/+8
This is needed for having complete error messages where reporting macro variable errors. Here is what they would look like: error: meta-variable repeats with different kleene operator --> $DIR/issue-61053-different-kleene.rs:3:57 | LL | ( $( $i:ident = $($j:ident),+ );* ) => { $( $( $i = $j; )* )* }; | - expected repetition ^^ - conflicting repetition
2019-07-11syntax: Make def-site span mandatory in ↵Vadim Petrochenkov-8/+6
ExpnInfo/MacroBacktrace/DiagnosticSpanMacroExpansion We have to deal with dummy spans anyway Remove def-site span from expander interfaces. It's not used by the expansion infra, only by specific expanders, which can keep it themselves if they want it.
2019-07-07Support deprecation checking for macrosVadim Petrochenkov-0/+1
2019-07-07syntax: Keep full `Stability` in `SyntaxExtension`Vadim Petrochenkov-13/+2
2019-07-07syntax: Remove `NodeId` from `SyntaxExtension`Vadim Petrochenkov-1/+1
2019-07-06privacy: Only opaque macros leak private thingsVadim Petrochenkov-13/+14
2019-07-06`#[rustc_transparent_macro]` -> `#[rustc_macro_transparency = ...]`Vadim Petrochenkov-7/+11
2019-06-23Run rustfmtJulien Cretin-206/+260
2019-06-18syntax: Factor out common fields from `SyntaxExtension` variantsVadim Petrochenkov-5/+7
2019-06-16Rollup merge of #61866 - sinkuu:redundant_clone, r=petrochenkovMazdak Farrokhzad-2/+3
Remove redundant `clone()`s
2019-06-15Rollup merge of #61813 - matthewjasper:remove-unnecessary-symbol-ops, ↵Mazdak Farrokhzad-11/+11
r=petrochenkov Remove some unnecessary symbol interner ops * Don't gensym symbols that don't need to worry about colliding with other symbols * Use symbol constants instead of interning string literals in a few places. * Don't generate a module in `__register_diagnostic` r? @petrochenkov
2019-06-15Use `slice::from_ref` instead of cloningShotaro Yamada-2/+3
2019-06-14Avoid some unnecessary symbol interner operationsMatthew Jasper-11/+11
2019-06-10syntax: Rename variants of `SyntaxExtension` for consistencyVadim Petrochenkov-3/+2
2019-06-10syntax: Remove `SyntaxExtension::DeclMacro`Vadim Petrochenkov-54/+55
It's a less powerful duplicate of `SyntaxExtension::NormalTT`
2019-06-09Rollup merge of #61669 - petrochenkov:tokderef2, r=oli-obkMazdak Farrokhzad-17/+17
syntax: Remove `Deref` impl from `Token` Follow up to https://github.com/rust-lang/rust/pull/61541 r? @oli-obk
2019-06-09Rollup merge of #61646 - L117:master, r=CentrilMazdak Farrokhzad-15/+15
Remove useless allocations in macro_rules follow logic. Closes #61543
2019-06-08syntax: Remove `Deref` impl from `Token`Vadim Petrochenkov-2/+2
2019-06-08syntax: Keep full `Token`s for `macro_rules` separatorsVadim Petrochenkov-15/+15
2019-06-08Remove useless allocations in macro_rules follow logic.L117-15/+15
2019-06-07parser: `self.span` -> `self.token.span`Vadim Petrochenkov-2/+2
2019-06-06Address review commentsVadim Petrochenkov-12/+9
2019-06-06syntax: Switch function parameter order in `TokenTree::token`Vadim Petrochenkov-5/+5
2019-06-06syntax: Remove duplicate span from `token::Ident`Vadim Petrochenkov-7/+5
2019-06-06syntax: Use `Token` in `Parser`Vadim Petrochenkov-8/+8
2019-06-06syntax: Use `Token` in `TokenTree::Token`Vadim Petrochenkov-16/+16
2019-06-06syntax: Rename `Token` into `TokenKind`Vadim Petrochenkov-1/+1
2019-05-27Avoid unnecessary internings.Nicholas Nethercote-1/+1
Most involving `Symbol::intern` on string literals.
2019-05-24Tweak macro parse errors when reaching EOF during macro call parseEsteban Küber-1/+1
- Add detail on origin of current parser when reaching EOF and stop saying "found <eof>" and point at the end of macro calls - Handle empty `cfg_attr` attribute - Reword empty `derive` attribute error