about summary refs log tree commit diff
path: root/src/libsyntax/ext/tt
AgeCommit message (Collapse)AuthorLines
2019-09-22rename libsyntax::ext::tt to mbeAleksey Kladov-3582/+0
mbe stands for macro-by-example
2019-09-22reduce visibility of a bunch of stuff in ext::ttAleksey Kladov-49/+40
2019-09-20factor out pluralisation remains after #64280gaolei-2/+3
2019-09-16Use `Symbol` in two more functions.Nicholas Nethercote-22/+22
2019-09-06Correct pluralisation of various diagnostic messagesvarkor-2/+7
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-19/+46
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-2/+2
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-27Remove run-pass test suitesVadim Petrochenkov-1/+1
2019-07-27Fix typo in Delimited::open_ttJulien Cretin-2/+2
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-20/+16
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-20/+16
NamedMatch is already cheap to clone due to Lrc's inside.
2019-07-20Auto merge of #62008 - ia0:issues_61053, r=petrochenkovbors-67/+681
Add meta-variable checks in macro definitions This is an implementation of #61053. It is not sound (some errors are not reported) and not complete (reports may not be actual errors). This is due to the possibility to define macros in macros in indirect ways. See module documentation of `macro_check` for more details. What remains to be done: - [x] Migrate from an error to an allow-by-default lint. - [x] Add more comments in particular for the handling of nested macros. - [x] Add more tests if needed. - [x] Try to avoid cloning too much (one idea is to use lists on the stack). - [ ] Run crater with deny-by-default lint (measure rate of false positives). - [ ] Remove extra commit for deny-by-default lint - [x] Create a PR to remove the old `question_mark_macro_sep` lint #62160
2019-07-19Implement checks for meta-variables in macrosJulien Cretin-46/+648
2019-07-19Remember the span of the Kleene operator in macrosJulien Cretin-21/+33
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-19Adjust other names after the `Mark` renamingVadim Petrochenkov-5/+5
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-07-04Rollup merge of #62249 - czipperz:use-mem-take-instead-of-replace-default, ↵Mazdak Farrokhzad-1/+1
r=dtolnay,Centril Use mem::take instead of mem::replace with default
2019-07-03Remove needless lifetimesJeremy Stucki-1/+1
2019-07-01Convert more usages overChris Gregory-1/+1
2019-06-26Fix clippy::redundant_field_namesIgor Matuszewski-4/+4
2019-06-23Auto merge of #62070 - ia0:rustfmt, r=petrochenkovbors-235/+273
Run rustfmt on some libsyntax files As part of #62008, run rustfmt on: - src/libsyntax/ext/tt/macro_rules.rs - src/libsyntax/ext/tt/quoted.rs There is no semantic change. To fix potential merge conflicts, simply choose the other side then run rustfmt and fix any tidy check (like line length).
2019-06-23Run rustfmtJulien Cretin-235/+273
2019-06-23let_chains: note re. back-compat wrt. expr beginning.Mazdak Farrokhzad-1/+3
2019-06-23let_chains: readd kw::let to ident_can_begin_expr.Mazdak Farrokhzad-1/+1
2019-06-19Rollup merge of #61898 - petrochenkov:sekind, r=eddybMazdak Farrokhzad-5/+7
syntax: Factor out common fields from `SyntaxExtension` variants And some other related cleanups. Continuation of https://github.com/rust-lang/rust/pull/61606. This will also help to unblock https://github.com/rust-lang/rust/pull/61877.
2019-06-18rustc: remove 'x: 'y bounds (except from comments/strings).Eduard-Mihai Burtescu-2/+2
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`