about summary refs log tree commit diff
path: root/src/libsyntax_ext
AgeCommit message (Collapse)AuthorLines
2019-08-28Auto merge of #63127 - kper:pr, r=nikomatsakisbors-8/+8
Cleanup: Consistently use `Param` instead of `Arg` #62426 Fixes #62426
2019-08-27Cleanup: Consistently use `Param` instead of `Arg` #62426Kevin Per-8/+8
2019-08-27proc_macro: Turn `quote` into a regular built-in macroVadim Petrochenkov-0/+8
Previously in was implemented using a special hack in the metadata loader
2019-08-23Audit uses of `apply_mark` in built-in macrosVadim Petrochenkov-24/+23
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-17Remove SyntaxContext from {ast, hir}::{GlobalAsm, InlineAsm}Matthew Jasper-7/+3
We now store it in the `Span` of the expression or item.
2019-08-17Remove gensyms from built-in derivesMatthew Jasper-86/+67
Also make them generally more hygienic with name resolution.
2019-08-16Rollup merge of #63613 - petrochenkov:stdhyg, r=alexcrichtonMazdak Farrokhzad-1/+0
Hygienize use of built-in macros in the standard library Same as https://github.com/rust-lang/rust/pull/61629, but for built-in macros. Closes https://github.com/rust-lang/rust/issues/48781 r? @alexcrichton
2019-08-16Rollup merge of #63525 - matklad:centraliza-file-loading, r=petrochenkovMazdak Farrokhzad-26/+11
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-15Remove `__rust_unstable_column`Vadim Petrochenkov-1/+0
2019-08-15hygiene: `ExpnInfo` -> `ExpnData`Vadim Petrochenkov-12/+12
For naming consistency with everything else in this area
2019-08-15hygiene: Merge `ExpnInfo` and `InternalExpnData`Vadim Petrochenkov-13/+11
2019-08-15`Ident::with_empty_ctxt` -> `Ident::with_dummy_span`Vadim Petrochenkov-20/+20
`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-9/+7
2019-08-15Remove `Spanned` from `ast::Mac`Vadim Petrochenkov-6/+3
2019-08-15Remove `Spanned` from `mk_name_value_item_str` and `expr_to_spanned_string`Vadim Petrochenkov-8/+8
2019-08-15Make sure that all file loading happens via SourceMapAleksey Kladov-26/+11
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-14/+14
Merge Variant and Variant_ Extracted from #63468.
2019-08-14Rollup merge of #63542 - c410-f3r:node_ids, r=petrochenkovMazdak Farrokhzad-0/+1
Add NodeId for Arm, Field and FieldPat Extracted from #63468
2019-08-14Rollup merge of #63537 - petrochenkov:novisit, r=alexcrichtonMazdak Farrokhzad-16/+20
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-14/+14
2019-08-13Add NodeId for Arm, Field and FieldPatCaio-0/+1
2019-08-14expand: Unimplement `MutVisitor` on `MacroExpander`Vadim Petrochenkov-16/+20
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-13syntax: Remove `DummyResult::expn_only`Vadim Petrochenkov-21/+21
2019-08-09Rollup merge of #63114 - matthewjasper:hygienic-format-args, r=petrochenkovMazdak Farrokhzad-2/+2
Remove gensym in format_args This also fixes some things to allow us to export opaque macros from libcore: * Don't consider items that are only reachable through opaque macros as public/exported (so they aren't linted as needing docs) * Mark private items reachable from the root of libcore as unstable - they are now reachable (in principle) in other crates via macros in libcore r? @petrochenkov
2019-08-05Remove gensym from format_argsMatthew Jasper-2/+2
2019-08-05Drop span argument from mk_list_itemMark Rousskov-2/+1
2019-08-05Auto merge of #63248 - petrochenkov:nomarker, r=matthewjasperbors-7/+12
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/+2
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 `ItemImplKind::Type` to `ItemImplKind::TyAlias`varkor-1/+2
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-7/+12
infrastructure to elsewhere
2019-08-03Rollup merge of #63146 - Mark-Simulacrum:clean-attr, r=petrochenkovMazdak Farrokhzad-63/+21
Cleanup syntax::attr Mostly removing needless arguments to constructors r? @petrochenkov
2019-08-03Rollup merge of #63121 - estebank:formatting-pos, r=alexcrichtonMazdak Farrokhzad-24/+122
On `format!()` arg count mismatch provide extra info When positional width and precision formatting flags are present in a formatting string that has an argument count mismatch, provide extra information pointing at them making it easiser to understand where the problem may lay: ``` error: 4 positional arguments in format string, but there are 3 arguments --> $DIR/ifmt-bad-arg.rs:78:15 | LL | println!("{} {:.*} {}", 1, 3.2, 4); | ^^ ^^--^ ^^ --- this parameter corresponds to the precision flag | | | this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected | = note: positional arguments are zero-based = note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html error: 4 positional arguments in format string, but there are 3 arguments --> $DIR/ifmt-bad-arg.rs:81:15 | LL | println!("{} {:07$.*} {}", 1, 3.2, 4); | ^^ ^^-----^ ^^ --- this parameter corresponds to the precision flag | | | | | this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected | this width flag expects an `usize` argument at position 7, but there are 3 arguments | = note: positional arguments are zero-based = note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html error: invalid reference to positional argument 7 (there are 3 arguments) --> $DIR/ifmt-bad-arg.rs:84:18 | LL | println!("{} {:07$} {}", 1, 3.2, 4); | ^^^--^ | | | this width flag expects an `usize` argument at position 7, but there are 3 arguments | = note: positional arguments are zero-based = note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html ``` Fix #49384.
2019-07-31fix dedupEsteban Küber-1/+1
2019-07-31Remove derives `Encodable`/`Decodable` and unstabilize attribute `#[bench]`Vadim Petrochenkov-36/+2
2019-07-31Replace AstBuilder with inherent methodsMark Rousskov-23/+0
2019-07-31Replace a few Attribute constructors with mk_attrMark Rousskov-17/+4
2019-07-31Remove span argument from mk_attr_{inner,outer}Mark Rousskov-3/+1
Always the same as the passed MetaItem
2019-07-31Remove Span argument from ExtCtxt::attributeMark Rousskov-18/+16
MetaItem.span was always equivalent
2019-07-31Remove AttrId from Attribute constructorsMark Rousskov-2/+0
2019-07-30Point at type ascription before macro invocation on expansion parse errorEsteban Küber-0/+1
2019-07-29review commentsEsteban Küber-1/+1
2019-07-29Improve handling of invalid references in `format!()`Esteban Küber-13/+34
2019-07-29On `format!()` arg count mismatch provide extra infoEsteban Küber-15/+92
When positional width and precision formatting flags are present in a formatting string that has an argument count mismatch, provide extra information pointing at them making it easiser to understand where the problem may lay: ``` error: 4 positional arguments in format string, but there are 3 arguments --> $DIR/ifmt-bad-arg.rs:78:15 | LL | println!("{} {:.*} {}", 1, 3.2, 4); | ^^ ^^--^ ^^ --- this parameter corresponds to the precision flag | | | this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected | = note: positional arguments are zero-based = note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html error: 4 positional arguments in format string, but there are 3 arguments --> $DIR/ifmt-bad-arg.rs:81:15 | LL | println!("{} {:07$.*} {}", 1, 3.2, 4); | ^^ ^^-----^ ^^ --- this parameter corresponds to the precision flag | | | | | this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected | this width flag expects an `usize` argument at position 7, but there are 3 arguments | = note: positional arguments are zero-based = note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html error: 3 positional arguments in format string, but there are 3 arguments --> $DIR/ifmt-bad-arg.rs:84:15 | LL | println!("{} {:07$} {}", 1, 3.2, 4); | ^^ ^^---^ ^^ | | | this width flag expects an `usize` argument at position 7, but there are 3 arguments | = note: positional arguments are zero-based = note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html ```
2019-07-28Deny `unused_lifetimes` through rustbuildVadim Petrochenkov-2/+0
2019-07-28Remove lint annotations in specific crates that are already enforced by ↵Vadim Petrochenkov-3/+0
rustbuild Remove some random unnecessary lint `allow`s
2019-07-27syntax_ext: `proc_macro_decls` -> `proc_macro_harness`Vadim Petrochenkov-14/+13
Few other minor renamings for consistency. Remove one unused dependency from `rustc_passes`. Fix libsyntax tests. Fix rebase.
2019-07-27Move standard library injection into libsyntax_extVadim Petrochenkov-0/+96
2019-07-27Move test harness generation into libsyntax_extVadim Petrochenkov-50/+432