about summary refs log tree commit diff
path: root/src/libsyntax/ext
AgeCommit message (Collapse)AuthorLines
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
2018-07-07fix perf issue in macro parserMichael Lamparski-1/+8
For a fuller description of the performance issue fixed by this: https://github.com/rust-lang/rust/issues/51754#issuecomment-403242159
2018-06-30Fortify dummy span checkingVadim Petrochenkov-6/+6
2018-06-30hygiene: Implement transparent marksVadim Petrochenkov-1/+12
2018-06-30expansion: Give names to some fields of `SyntaxExtension`Vadim Petrochenkov-20/+26
2018-06-28Auto merge of #50997 - michaelwoerister:pre-analyze-filemaps, r=Mark-Simulacrumbors-5/+9
Make FileMap::{lines, multibyte_chars, non_narrow_chars} non-mutable. This PR removes most of the interior mutability from `FileMap`, which should be beneficial, especially in a multithreaded setting. This is achieved by initializing the state in question when the filemap is constructed instead of during lexing. Hopefully this doesn't degrade performance. cc @wesleywiser
2018-06-27Remove the now redundant CodeMap::new_filemap_with_lines() method.Michael Woerister-5/+9
2018-06-27Implement `#[macro_export(local_inner_macros)]`Vadim Petrochenkov-1/+20
2018-06-23hygiene: Merge `NameAndSpan` into `ExpnInfo`Vadim Petrochenkov-50/+38
2018-06-23hygiene: Do not reset expansion info for `quote!`Vadim Petrochenkov-3/+7
2018-06-23expansion: Add some commentsVadim Petrochenkov-2/+14
2018-06-23expansion: Improve searchability for `AstFragments` methodsVadim Petrochenkov-44/+60
2018-06-23expansion: Rename `Expansion` to `AstFragment`Vadim Petrochenkov-186/+198
2018-06-23expansion: Remove unnecessary override from `impl Folder for Marker`Vadim Petrochenkov-5/+0
2018-06-21async await desugaring and testsTaylor Cramer-0/+2
2018-06-21Parse async fn header.Without Boats-3/+6
This is gated on edition 2018 & the `async_await` feature gate. The parser will accept `async fn` and `async unsafe fn` as fn items. Along the same lines as `const fn`, only `async unsafe fn` is permitted, not `unsafe async fn`.The parser will not accept `async` functions as trait methods. To do a little code clean up, four fields of the function type struct have been merged into the new `FnHeader` struct: constness, asyncness, unsafety, and ABI. Also, a small bug in HIR printing is fixed: it previously printed `const unsafe fn` as `unsafe const fn`, which is grammatically incorrect.
2018-06-20Rename ty_param_bound to trait_boundvarkor-2/+2
2018-06-20Make GenericBound explicitvarkor-1/+2
2018-06-20Rename ParamBound(s) to GenericBound(s)varkor-6/+6
2018-06-20Rename TraitTyParamBound to ParamBound::Traitvarkor-1/+1
2018-06-20Remove name from GenericParamKind::Lifetimevarkor-3/+1
2018-06-20Lift bounds into GenericParamvarkor-8/+8
2018-06-20Rename structures in astvarkor-13/+13
2018-06-20Refactor ast::GenericParam as a structvarkor-10/+17