about summary refs log tree commit diff
path: root/src/libsyntax/ext
AgeCommit message (Collapse)AuthorLines
2018-11-01Use `SmallVec` for the inner vectors in `MatcherPos::matches`.Nicholas Nethercote-5/+7
This avoids some allocations.
2018-11-01Share empty `Vec`s more within `MatcherPos::matches`.Nicholas Nethercote-4/+9
`create_matches` creates a `Vec<Rc<Vec<NamedMatch>>>`. Even though all the inner `Vec`s are empty, each one is created separately. This commit changes `create_matches` so it instead creates one empty inner `Vec`, and shares it. The commit also changes `MatcherPos::matches` to a boxed slice, because its length doesn't change.
2018-10-31syntax: improve a few allocationsljedrz-0/+2
2018-10-31use String::from() instead of format!() macro to construct Strings.Matthias Krüger-1/+1
2018-10-28Provide specific label for patern parsing errorEsteban Küber-3/+3
2018-10-26Auto merge of #54929 - csmoe:cfg_lint, r=petrochenkovbors-1/+1
Suggest to remove prefix `b` in cfg attribute lint string Closes #54926 r? @estebank
2018-10-26Rollup merge of #55358 - sinkuu:redundant_clone2, r=estebankkennytm-4/+3
Remove redundant clone (2)
2018-10-26Rollup merge of #55301 - estebank:macro-allowed, r=petrochenkovkennytm-44/+94
List allowed tokens after macro fragments Fix #34069.
2018-10-26Rollup merge of #55298 - estebank:macro-def, r=pnkfelixkennytm-13/+39
Point at macro definition when no rules expect token Fix #35150.
2018-10-26Rollup merge of #55292 - estebank:macro-eof, r=pnkfelixkennytm-5/+28
Macro diagnostics tweaks Fix #30128, fix #10951 by adding an appropriate span to the diagnostic. Fix #26288 by suggesting adding semicolon to macro call.
2018-10-26Remove redundant cloneShotaro Yamada-4/+3
2018-10-26Give each PathSegment a NodeIdNick Cameron-2/+6
2018-10-25List allowed tokens after macro fragmentsEsteban Küber-44/+94
2018-10-25Rollup merge of #54977 - estebank:macro-arg-parse, r=pnkfelixPietro Albini-1/+2
Accept `Option<Box<$t:ty>>` in macro argument Given the following code, compile successfuly: ``` macro_rules! test { ( fn fun() -> Option<Box<$t:ty>>; ) => { fn fun(x: $t) -> Option<Box<$t>> { Some(Box::new(x)) } } } test! { fn fun() -> Option<Box<i32>>; } ``` Fix #25274.
2018-10-24Fix incorrect semicolon suggestionEsteban Küber-1/+3
2018-10-24Point to macro def span instead of whole bodyEsteban Küber-1/+1
2018-10-23Point at macro definition when no rules expect tokenEsteban Küber-13/+39
2018-10-23Modify invalid macro in expression context diagnosticEsteban Küber-4/+20
2018-10-23Add macro call span when lacking any other span in diagnosticEsteban Küber-1/+6
2018-10-20handle errors based on parse_sesscsmoe-1/+1
2018-10-12Add missing lifetime fragment specifier to error message.Eric Huss-5/+6
A very minor issue, `lifetime` was missing from the error list. I left `literal` in the list, even though it is unstable. It looks like it may stabilize soon anyways.
2018-10-10Accept `Option<Box<$t:ty>>` in macro argumentEsteban Küber-1/+2
Given the following code, compile successfuly: ``` macro_rules! test { ( fn fun() -> Option<Box<$t:ty>>; ) => { fn fun(x: $t) -> Option<Box<$t>> { Some(Box::new(x)) } } } test! { fn fun() -> Option<Box<i32>>; } ```
2018-10-05Rollup merge of #54833 - abonander:issue-54441, r=petrochenkovPietro Albini-3/+1
make `Parser::parse_foreign_item()` return a foreign item or error Fixes `Parser::parse_foreign_item()` to follow the convention of `parse_trait_item()` and `parse_impl_item()` in that it *must* parse an item or return an error, and then the caller is responsible for detecting the closing delimiter. This prevents it from looping endlessly on an unexpected token in `ext/expand.rs` where it was also leaking memory by continually pushing to `Parser::expected_tokens` via `Parser::check_keyword()`. closes #54441 r? @petrochenkov cc @dtolnay
2018-10-05Auto merge of #54336 - petrochenkov:preuni, r=alexcrichtonbors-43/+30
resolve: Some refactorings in preparation for uniform paths 2.0 The main result is that in-scope resolution performed during macro expansion / import resolution is now consolidated in a single function (`fn early_resolve_ident_in_lexical_scope`), which can now be used for resolving first import segments as well when uniform paths are enabled. r? @ghost
2018-10-05make `Parser::parse_foreign_item()` return a foreign item or errorAustin Bonander-3/+1
closes #54441
2018-10-05expansion: Remove restriction on use of macro attributes with test/benchVadim Petrochenkov-43/+30
The restrictions were introduced in https://github.com/rust-lang/rust/pull/54277 and no longer necessary now because legacy plugins are now expanded in usual left-to-right order
2018-10-02Merge the `proc_macro_` expansion feature gates into a single ↵jeb-13/+10
`proc_macro_hygiene` gate.
2018-09-27Auto merge of #52319 - tinco:issue_12590, r=pnkfelixbors-0/+2
Track whether module declarations are inline (fixes #12590) To track whether module declarations are inline I added a field `inline: bool` to `ast::Mod`. The main use case is for pretty to know whether it should render the items associated with the module, but perhaps there are use cases for this information to not be forgotten in the AST.
2018-09-26Remove OneVectorljedrz-61/+66
2018-09-20Auto merge of #54241 - vi:suggest_with_applicability, r=estebankbors-1/+3
Remove usages of span_suggestion without Applicability Use `Applicability::Unspecified` for all of them instead. Shall deprecations for the non-`_with_applicability` functions be added? Shall clippy be addressed somehow? r? @estebank
2018-09-17Whitespace fix again.Vitaly _Vi Shukela-4/+4
2018-09-17Fill in suggestions Applicability according to @estebankVitaly _Vi Shukela-4/+4
Also fix some formatting along the way.
2018-09-16Remove usages of span_suggestion without ApplicabilityVitaly _Vi Shukela-1/+3
Use Applicability::Unspecified for all of them instead.
2018-09-16Temporarily prohibit proc macro attributes placed after derivesVadim Petrochenkov-39/+59
... and also proc macro attributes used together with test/bench.
2018-09-13resolve: Put different parent scopes into a single structureVadim Petrochenkov-3/+3
2018-09-11resolve: Support resolving identifier macros without their own IDVadim Petrochenkov-5/+4
Invocation/expansion ID (aka `Mark`) is not really necessary for resolving a macro path. What is really necessary is its parent module, parent expansion and parent legacy scope. This is required for validation resolutions of built-in attributes, which don't get their own `Mark`s
2018-09-10Auto merge of #54093 - petrochenkov:noinner, r=alexcrichtonbors-8/+23
Feature gate non-builtin attributes in inner attribute position Closes item 3 from https://github.com/rust-lang/rust/pull/50911#issuecomment-411605393
2018-09-10Track whether module declarations are inline (fixes #12590)Tinco Andringa-0/+2
2018-09-10resolve: Remove `unshadowable_attrs`Vadim Petrochenkov-2/+0
2018-09-10Feature gate non-builtin attributes in inner attribute positionVadim Petrochenkov-8/+23
2018-09-09Auto merge of #53902 - dtolnay:group, r=petrochenkovbors-52/+57
proc_macro::Group::span_open and span_close Before this addition, every delimited group like `(`...`)` `[`...`]` `{`...`}` has only a single Span that covers the full source location from opening delimiter to closing delimiter. This makes it impossible for a procedural macro to trigger an error pointing to just the opening or closing delimiter. The Rust compiler does not seem to have the same limitation: ```rust mod m { type T = } ``` ```console error: expected type, found `}` --> src/main.rs:3:1 | 3 | } | ^ ``` On that same input, a procedural macro would be forced to trigger the error on the last token inside the block, on the entire block, or on the next token after the block, none of which is really what you want for an error like above. This commit adds `group.span_open()` and `group.span_close()` which access the Span associated with just the opening delimiter and just the closing delimiter of the group. Relevant to Syn as we implement real error messages for when parsing fails in a procedural macro: https://github.com/dtolnay/syn/issues/476. ```diff impl Group { fn span(&self) -> Span; + fn span_open(&self) -> Span; + fn span_close(&self) -> Span; } ``` Fixes #48187 r? @alexcrichton
2018-09-08Rename sp_lo to sp_openDavid Tolnay-10/+10
2018-09-08Track distinct spans for open and close delimiterDavid Tolnay-46/+51
2018-09-04Move #[test_case] to a syntax extensionJohn Renner-45/+5
2018-09-04Fix #[test] shadowing in macro_preludeJohn Renner-0/+3
2018-09-04Introduce Custom Test FrameworksJohn Renner-38/+10
2018-08-28Use FxHash{Map,Set} instead of the default Hash{Map,Set} everywhere in rustc.Eduard-Mihai Burtescu-24/+24
2018-08-24Rollup merge of #53563 - matthiaskrgr:String, r=varkorkennytm-1/+1
use String::new() instead of String::from(""), "".to_string(), "".to_owned() or "".into()
2018-08-23Auto merge of #53384 - gootorov:use-servo-smallvec, r=michaelwoeristerbors-21/+22
Use optimized SmallVec implementation This PR replaces current SmallVec implementation with the one from the Servo project. Closes https://github.com/rust-lang/rust/issues/51640 r? @Mark-Simulacrum
2018-08-23use String::new() instead of String::from(""), "".to_string(), "".to_owned() ↵Matthias Krüger-1/+1
or "".into()