about summary refs log tree commit diff
path: root/src/libsyntax/ext
AgeCommit message (Collapse)AuthorLines
2018-08-23Use optimized SmallVec implementationIgor Gutorov-21/+22
2018-08-23Stabilize a few secondary macro featuresVadim Petrochenkov-10/+5
`tool_attributes`, `proc_macro_path_invoc`, partially `proc_macro_gen`
2018-08-21Auto merge of #53471 - petrochenkov:biattr2, r=oli-obkbors-20/+14
resolve: Some macro resolution refactoring Work towards completing https://github.com/rust-lang/rust/pull/50911#issuecomment-411605393 The last commit also fixes https://github.com/rust-lang/rust/issues/53269 by not using `def_id()` on `Def::Err` and also fixes https://github.com/rust-lang/rust/issues/53512.
2018-08-21Rollup merge of #53496 - matthiaskrgr:codespell_08_2018, r=varkorkennytm-4/+4
Fix typos found by codespell.
2018-08-21Rollup merge of #53370 - jkozlowski:stabilize-macro_vis_matcher, r=cramertjkennytm-13/+1
Stabilize macro_vis_matcher This PR should stabilize [macro_vis_matcher](https://github.com/rust-lang/rust/issues/41022) feature. - [ ] "reference" book changes: https://github.com/rust-lang-nursery/reference/pull/400 - [ ] "Rust by example" book changes: https://github.com/rust-lang/rust-by-example/pull/1096 - [ ] "clippy" changes: https://github.com/rust-lang-nursery/rust-clippy/pull/3055 r? @cramertj
2018-08-20resolve: Consolidate error reporting for resolved macros in `fn ↵Vadim Petrochenkov-20/+14
resolve_macro_to_def`
2018-08-19mv codemap() source_map()Donato Sciarra-11/+11
2018-08-19mv (mod) codemap source_mapDonato Sciarra-9/+9
2018-08-19mv filemap source_fileDonato Sciarra-4/+4
2018-08-19mv FileMap SourceFileDonato Sciarra-1/+1
2018-08-19mv CodeMap SourceMapDonato Sciarra-2/+2
2018-08-19Stabilize macro_vis_matcherJakub Kozlowski-13/+1
2018-08-19Fix typos found by codespell.Matthias Krüger-4/+4
2018-08-18Use the new Entry::or_default method where possible.Eduard-Mihai Burtescu-4/+3
2018-08-17Stabilize `use_extern_macros`Vadim Petrochenkov-10/+2
2018-08-13Move SmallVec and ThinVec out of libsyntaxljedrz-84/+88
2018-08-10Rollup merge of #53183 - estebank:println-comma, r=oli-obkkennytm-2/+2
Suggest comma when missing in macro call When missing a comma in a macro call, suggest it, regardless of position. When a macro call doesn't match any of the patterns, check if the call's token stream could be missing a comma between two idents, and if so, create a new token stream containing the comma and try to match against the macro patterns. If successful, emit the suggestion. This works on arbitrary macros, with no need of special support from the macro writers. ``` error: no rules expected the token `d` --> $DIR/missing-comma.rs:26:18 | LL | foo!(a, b, c d, e); | -^ | | | help: missing comma here ``` Follow up to #52397.
2018-08-08Auto merge of #53053 - petrochenkov:custattr, r=alexcrichtonbors-52/+35
resolve: Support custom attributes when macro modularization is enabled Basically, if resolution of a single-segment attribute is a determined error, then we interpret it as a custom attribute. Since custom attributes are integrated into general macro resolution, `feature(custom_attribute)` now requires and implicitly enables macro modularization (`feature(use_extern_macros)`). Actually, a few other "advanced" macro features now implicitly enable macro modularization too (and one bug was found and fixed in process of enabling it). The first two commits are preliminary cleanups/refactorings.
2018-08-07Suggest comma when missing in macro callEsteban Küber-2/+2
When missing a comma in a macro call, suggest it, regardless of position. When a macro call doesn't match any of the patterns, check if the call's token stream could be missing a comma between two idents, and if so, create a new token stream containing the comma and try to match against the macro patterns. If successful, emit the suggestion.
2018-08-06Suggest comma when writing `println!("{}" a);`Esteban Küber-1/+26
2018-08-06Address review commentsVadim Petrochenkov-22/+12
Adjust a few fulldeps and pretty-printing tests Fix rebase
2018-08-06Support custom attributes when macro modularization is enabledVadim Petrochenkov-12/+22
2018-08-06Avoid modifying invocations in place for derive helper attributesVadim Petrochenkov-21/+4
2018-08-02Auto merge of #52841 - petrochenkov:premacro, r=alexcrichtonbors-3/+26
resolve: Implement prelude search for macro paths, implement tool attributes When identifier is macro path is resolved in scopes (i.e. the first path segment - `foo` in `foo::mac!()` or `foo!()`), scopes are searched in the same order as for non-macro paths - items in modules, extern prelude, tool prelude (see later), standard library prelude, language prelude, but with some extra shadowing restrictions (names from globs and macro expansions cannot shadow names from outer scopes). See the comment in `fn resolve_lexical_macro_path_segment` for more details. "Tool prelude" currently contains two "tool modules" `rustfmt` and `clippy`, and is searched immediately after extern prelude. This makes the [possible long-term solution](https://github.com/rust-lang/rfcs/blob/master/text/2103-tool-attributes.md#long-term-solution) for tool attributes exactly equivalent to the existing extern prelude scheme, except that `--extern=my_crate` making crate names available in scope is replaced with something like `--tool=my_tool` making tool names available in scope. The `tool_attributes` feature is still unstable and `#![feature(tool_attributes)]` now implicitly enables `#![feature(use_extern_macros)]`. `use_extern_macros` is a prerequisite for `tool_attributes`, so their stabilization will happen in the same order. If `use_extern_macros` is not enabled, then tool attributes are treated as custom attributes (this is temporary, anyway). Fixes https://github.com/rust-lang/rust/issues/52576 Fixes https://github.com/rust-lang/rust/issues/52512 Fixes https://github.com/rust-lang/rust/issues/51277 cc https://github.com/rust-lang/rust/issues/52269
2018-08-02Auto merge of #52890 - djrenren:test-visibility, r=petrochenkovbors-5/+62
Reexport tests without polluting namespaces This should fix issue #52557. Basically now we gensym a new name for the test function and reexport that. That way the test function's reexport name can't conflict because it was impossible for the test author to write it down. We then use a `use` statement to expose the original name using the original visibility.
2018-08-01Use the correct allowJohn Renner-3/+3
2018-08-01Allow test imports to go unusedJohn Renner-1/+15
2018-08-01resolve: Implement prelude search for macro pathsVadim Petrochenkov-3/+26
resolve/expansion: Implement tool attributes
2018-07-31Address code reviewJohn Renner-5/+10
2018-07-31Allow unnameable testsJohn Renner-8/+28
2018-07-30Reexport tests without polluting namespacesJohn Renner-1/+19
2018-07-27Prefer to_string() to format!()ljedrz-2/+2
2018-07-23make it a migration lintmark-3/+32
2018-07-23Fix test and errorsmark-266/+183
2018-07-23Implement 2015 vs 2018 `?` kleene op + testmark-257/+486
2018-07-22Auto merge of #52394 - estebank:println, r=oli-obkbors-10/+16
Improve suggestion for missing fmt str in println Avoid using `concat!(fmt, "\n")` to improve the diagnostics being emitted when the first `println!()` argument isn't a formatting string literal. Fix #52347.
2018-07-21Gate `format_args_nll` behind feature flagEsteban Küber-0/+1
2018-07-19Improve suggestion for missing fmt str in printlnEsteban Küber-10/+15
Avoid using `concat!(fmt, "\n")` to improve the diagnostics being emitted when the first `println!()` argument isn't a formatting string literal.
2018-07-19rustc: Fix two custom attributes with custom deriveAlex Crichton-0/+17
This commit fixes an issue where multiple custom attributes could not be fed into a custom derive in some situations with the `use_extern_macros` feature enabled. The problem was that the macro expander didn't consider that it was making progress when we were deducing that attributes should be lumped in with custom derive invocations. The fix applied here was to track in the expander if our attribute is changing (getting stashed away elsewhere and replaced with a new invocation). If it is swapped then it's considered progress, otherwise behavior should remain the same. Closes #52525
2018-07-17Auto merge of #52145 - ExpHP:drop-it-like-its-eof, r=nikomatsakisbors-1/+6
Fix macro parser quadratic complexity in small repeating groups Observed in #51754, and more easily demonstrated with the following: ```rust macro_rules! stress { ($($t:tt)+) => { }; } fn main() { stress!{ a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a // ... 65536 copies of "a" total ... a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a } } ``` which takes 50 seconds to compile prior to the fix and <1s after. I hope this has a visible impact on the compile times for real code. (I think it is most likely to affect incremental TT munchers that deal with large inputs, though it depends on how they are written) For a fuller description of the performance issue: https://github.com/rust-lang/rust/issues/51754#issuecomment-403242159 --- There is no test (yet) because I'm not sure how easily to measure this for regressions.
2018-07-16cleanup unnecessary elseMichael Lamparski-6/+4
2018-07-16rustc: Stabilize much of the `proc_macro` featureAlex Crichton-4/+4
This commit stabilizes some of the `proc_macro` language feature as well as a number of APIs in the `proc_macro` crate as [previously discussed][1]. This means that on stable Rust you can now define custom procedural macros which operate as attributes attached to items or `macro_rules!`-like bang-style invocations. This extends the suite of currently stable procedural macros, custom derives, with custom attributes and custom bang macros. Note though that despite the stabilization in this commit procedural macros are still not usable on stable Rust. To stabilize that we'll need to stabilize at least part of the `use_extern_macros` feature. Currently you can define a procedural macro attribute but you can't import it to call it! A summary of the changes made in this PR (as well as the various consequences) is: * The `proc_macro` language and library features are now stable. * Other APIs not stabilized in the `proc_macro` crate are now named under a different feature, such as `proc_macro_diagnostic` or `proc_macro_span`. * A few checks in resolution for `proc_macro` being enabled have switched over to `use_extern_macros` being enabled. This means that code using `#![feature(proc_macro)]` today will likely need to move to `#![feature(use_extern_macros)]`. It's intended that this PR, once landed, will be followed up with an attempt to stabilize a small slice of `use_extern_macros` just for procedural macros to make this feature 100% usable on stable. [1]: https://internals.rust-lang.org/t/help-stabilize-a-subset-of-macros-2-0/7252
2018-07-15Auto merge of #52383 - petrochenkov:pmns, r=alexcrichtonbors-1/+4
resolve: Functions introducing procedural macros reserve a slot in the macro namespace as well Similarly to https://github.com/rust-lang/rust/pull/52234, this gives us symmetry between internal and external views of a crate, but in this case it's always an error to call a procedural macro in the same crate in which it's defined. Closes https://github.com/rust-lang/rust/issues/52225
2018-07-14Functions introducing procedural macros reserve a slot in the macro ↵Vadim Petrochenkov-1/+4
namespace as well
2018-07-14Remove most of `Hash` impls from AST and HIR structuresVadim Petrochenkov-3/+3
2018-07-14Remove most of `PartialEq` impls from AST and HIR structuresVadim Petrochenkov-5/+5
2018-07-11Rollup merge of #52224 - ljedrz:dyn_libsyntax, r=oli-obkMark Rousskov-49/+50
Deny bare trait objects in in src/libsyntax Enforce `#![deny(bare_trait_objects)]` in `src/libsyntax`.
2018-07-10Pacify tidyljedrz-1/+2
2018-07-10Deny bare trait objects in in src/libsyntaxljedrz-49/+49
2018-07-08hygiene: Decouple transparencies from expansion IDsVadim Petrochenkov-12/+6