summary refs log tree commit diff
path: root/src/libsyntax/ext
AgeCommit message (Collapse)AuthorLines
2019-09-02expand: Do not do questionable span adjustment before eagerly expanding an ↵Vadim Petrochenkov-3/+0
expression Maybe it made sense when it was introduced, but now it's doing something incorrect.
2019-09-02expand: 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-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
2019-07-31Remove span argument from mk_attr_{inner,outer}Mark Rousskov-1/+1
Always the same as the passed MetaItem
2019-07-31Remove Span argument from ExtCtxt::attributeMark Rousskov-5/+5
MetaItem.span was always equivalent
2019-07-31Remove AttrId from Attribute constructorsMark Rousskov-5/+9
2019-07-31Unify spanned and non-spanned Attribute ctorsMark Rousskov-3/+3
There is no difference in the code/arguments, so go with the shorter name throughout the code.
2019-07-30Point at type ascription before macro invocation on expansion parse errorEsteban Küber-2/+11
2019-07-28Rollup merge of #61856 - c410-f3r:attrs-fn, r=matthewjasperMazdak Farrokhzad-0/+1
Lint attributes on function arguments Fixes #61238. cc #60406
2019-07-28Rollup merge of #62550 - Centril:rest-patterns, r=petrochenkovMazdak Farrokhzad-2/+2
Implement RFC 2707 + Parser recovery for range patterns Implement https://github.com/rust-lang/rfcs/pull/2707. - Add a new basic syntactic pattern form `ast::PatKind::Rest` (parsed as `..` or `DOTDOT`) and simplify `ast::PatKind::{Slice, Tuple, TupleStruct}` as a result. - Lower `ast::PatKind::Rest` in combination with the aforementioned `PatKind` variants as well as `PatKind::Ident`. The HIR remains unchanged for now (may be advisable to make slight adjustments later). - Refactor `parser.rs` wrt. parsing sequences and lists of things in the process. - Add parser recovery for range patterns of form `X..`, `X..=`, `X...`, `..Y`, `..=Y`, and `...Y`. This should make it easy to actually support these patterns semantically later if we so desire. cc https://github.com/rust-lang/rust/issues/62254 r? @petrochenkov
2019-07-28Adjust 'ast::PatKind::{TupleStruct,Tuple,Slice}'.Mazdak Farrokhzad-2/+2
2019-07-28Rollup merge of #62771 - petrochenkov:depext, r=eddybMazdak Farrokhzad-240/+967
Break dependencies between `syntax_ext` and other crates Move `source_util` macros into `syntax_ext`. Move other early code generation facilities like standard library injection into `syntax_ext`. The only crate that depends on `syntax_ext` now is `rustc_interface` which is one of the "final" crates that depend on everything. Minor: Cleanup dependencies of `rustc_driver`, many of them are no longer used after introduction of `rustc_interface`. r? @eddyb
2019-07-27Remove run-pass test suitesVadim Petrochenkov-1/+1
2019-07-27syntax_ext: `proc_macro_decls` -> `proc_macro_harness`Vadim Petrochenkov-2/+2
Few other minor renamings for consistency. Remove one unused dependency from `rustc_passes`. Fix libsyntax tests. Fix rebase.
2019-07-27Move proc macro server into libsyntaxVadim Petrochenkov-75/+960
2019-07-27Break dependencies between `syntax_ext` and some other cratesVadim Petrochenkov-166/+8
Move `source_uitil` macros into `syntax_ext` Cleanup dependencies of `rustc_driver`
2019-07-27Lint attributes on function argumentsCaio-0/+1
2019-07-27Fix typo in Delimited::open_ttJulien Cretin-2/+2
2019-07-26Auto merge of #62086 - petrochenkov:builtout, r=eddybbors-1/+6
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-26Rollup merge of #62956 - ia0:fix_62831, r=petrochenkovMazdak Farrokhzad-27/+26
Implement slow-path for FirstSets::first 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-26Introduce built-in macros through libcoreVadim Petrochenkov-1/+6
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-25Rollup merge of #62735 - petrochenkov:galloc, r=alexcrichtonMazdak Farrokhzad-0/+75
Turn `#[global_allocator]` into a regular attribute macro It was a 99% macro with exception of some diagnostic details. As a result of the change, `#[global_allocator]` now works in nested modules and even in nameless blocks. Fixes https://github.com/rust-lang/rust/issues/44113 Fixes https://github.com/rust-lang/rust/issues/58072
2019-07-25Rollup merge of #60938 - jonas-schievink:doc-include-paths, r=petrochenkovMazdak Farrokhzad-33/+32
rustdoc: make #[doc(include)] relative to the containing file This matches the behavior of other in-source paths like `#[path]` and the `include_X!` macros. Fixes https://github.com/rust-lang/rust/pull/58373#issuecomment-462349380 Also addresses https://github.com/rust-lang/rust/issues/44732#issuecomment-467660239 cc #44732 This is still missing a stdsimd change (https://github.com/jonas-schievink/stdsimd/commit/42ed30e0b5fb5e2d11765b5d1e1f36234af85984), so CI will currently fail. I'll land that change once I get initial feedback for this PR.
2019-07-25Remove needless indirection through RcMark Rousskov-20/+16
NamedMatch is already cheap to clone due to Lrc's inside.
2019-07-24syntax_ext: Turn `#[global_allocator]` into a regular attribute macroVadim Petrochenkov-0/+22
2019-07-24Merge `rustc_allocator` into `libsyntax_ext`Vadim Petrochenkov-0/+53
2019-07-23Normalize use of backticks in compiler messages for libsyntax/*Samy Kacimi-1/+1
https://github.com/rust-lang/rust/issues/60532
2019-07-23Make path::resolve a method on ExtCtxtJonas Schievink-7/+30
2019-07-23Make #[doc(include)] paths behave like other pathsJonas Schievink-5/+2
This makes them relative to the containing file instead of the crate root
2019-07-23libsyntax: factor out file path resolvingJonas Schievink-27/+6
This allows the same logic used by `include_X!` macros to be used by `#[doc(include)]`.
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