summary refs log tree commit diff
path: root/src/libsyntax/ext/expand.rs
AgeCommit message (Collapse)AuthorLines
2017-08-12Stabilize the `compile_error_macro` featureAlex Crichton-1/+0
Stabilizes: * `compile_error!` as a macro defined by rustc Closes #40872
2017-06-26Add `LazyTokenStream`.Jeffrey Seyfried-30/+10
2017-06-26Simplify `hygiene::Mark` application, andJeffrey Seyfried-20/+16
remove variant `Token::SubstNt` in favor of `quoted::TokenTree::MetaVar`.
2017-06-19Add compile_error!Wesley Wiser-0/+1
Related to #40872
2017-05-31Extend the unused macro lint to macros 2.0est31-2/+3
2017-05-25Hygienize `librustc_resolve`.Jeffrey Seyfried-15/+27
2017-05-17Auto merge of #42049 - Mark-Simulacrum:rollup, r=Mark-Simulacrumbors-15/+11
Rollup of 5 pull requests - Successful merges: #41937, #41957, #42017, #42039, #42046 - Failed merges:
2017-05-13Support #[allow] etc logic on a per macro levelest31-1/+1
This commit extends the current unused macro linter to support directives like #[allow(unused_macros)] or #[deny(unused_macros)] directly next to the macro definition, or in one of the modules the macro is inside. Before, we only supported such directives at a per crate level, due to the crate's NodeId being passed to session.add_lint. We also had to implement handling of the macro's NodeId in the lint visitor.
2017-05-12Fix some clippy warnings in libsyntaxAndre Bogus-15/+11
This is mostly removing stray ampersands, needless returns and lifetimes.
2017-05-08Rollup merge of #41520 - estebank:trace-macro, r=nikomatsakisCorey Farwell-1/+1
Use diagnostics for trace_macro instead of println When using `trace_macro`, use `span_label`s instead of `println`: ```rust note: trace_macro --> $DIR/trace-macro.rs:14:5 | 14 | println!("Hello, World!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: expands to `println! { "Hello, World!" }` = note: expands to `print! { concat ! ( "Hello, World!" , "\n" ) }` ``` Fix #22597.
2017-05-06Group "macro expansion" notes per call spanEsteban Küber-1/+1
2017-05-01Increase macro recursion limit to 1024 Fixes #22552Charlie Sheridan-1/+1
2017-04-26Implement a file-path remapping feature in support of debuginfo and ↵Michael Woerister-1/+1
reproducible builds.
2017-04-20Don't panic if an attribute macro fails to resolve at crate rootAustin Bonander-2/+12
Adds temporary regression test; this ideally should work as-is (#41430) Closes #41211
2017-04-17Auto merge of #41282 - arielb1:missing-impl-item, r=petrochenkovbors-2/+2
libsyntax/parse: fix missing kind error reporting Fixes #41161. Fixes #41239.
2017-04-17libsyntax/parse: improve associated item error reportingAriel Ben-Yehuda-2/+2
Fixes #41161. Fixes #41239.
2017-04-12First attempt at global_asm! macroA.J. Gardner-0/+1
2017-03-29Merge `ExpnId` and `SyntaxContext`.Jeffrey Seyfried-65/+46
2017-03-29Move `syntax::ext::hygiene` to `syntax_pos::hygiene`.Jeffrey Seyfried-3/+3
2017-03-21Refactor parsing of trait object typesVadim Petrochenkov-1/+1
2017-03-14Liberalize attributes.Jeffrey Seyfried-45/+49
2017-03-14Refactor `Attribute` to use `Path` and `TokenStream` instead of `MetaItem`.Jeffrey Seyfried-34/+8
2017-03-11Auto merge of #40220 - jseyfried:ast_macro_def, r=nrcbors-79/+10
syntax: add `ast::ItemKind::MacroDef`, simplify hygiene info This PR - adds a new variant `MacroDef` to `ast::ItemKind` for `macro_rules!` and eventually `macro` items, - [breaking-change] forbids macro defs without a name (`macro_rules! { () => {} }` compiles today), - removes `ast::MacroDef`, and - no longer uses `Mark` and `Invocation` to identify and characterize macro definitions. - We used to apply (at least) two `Mark`s to an expanded identifier's `SyntaxContext` -- the definition mark(s) and the expansion mark(s). We now only apply the latter. r? @nrc
2017-03-10Expect macro defs in save-analysis and add expn info to spans for attr proc ↵Nick Cameron-1/+13
macros
2017-03-10Avoid using `Mark` and `Invocation` for macro defs.Jeffrey Seyfried-7/+3
2017-03-10Move `resolve_invoc` from `syntax` to `resolve`.Jeffrey Seyfried-60/+2
2017-03-10Refactor out `ast::ItemKind::MacroDef`.Jeffrey Seyfried-12/+5
2017-03-03Integrate `TokenStream`.Jeffrey Seyfried-20/+19
2017-03-03Remove lifetime parameter from `syntax::tokenstream::Cursor`.Jeffrey Seyfried-1/+1
2017-02-16Refactor macro resolution errors + add derive macro suggestionsJosh Driver-6/+8
2017-02-12Allow using inert attributes from `proc_macro_derive`s with ↵Jeffrey Seyfried-82/+179
`#![feature(proc_macro)]`.
2017-02-05Move derive macro expansion into the MacroExpanderJosh Driver-8/+102
This removes the expand_derives function, and sprinkles the functionality throughout the Invocation Collector, Expander and Resolver.
2017-02-05Rename CustomDerive to ProcMacroDerive for macros 1.1Josh Driver-2/+2
2017-02-05Make builtin derives a SyntaxExtensionJosh Driver-2/+2
This allows builtin derives to be registered and resolved, just like other derive types.
2017-01-22Refactor `TokenStream`.Jeffrey Seyfried-6/+4
2017-01-20Rollup merge of #39118 - jseyfried:token_tree_based_parser, r=nrcAlex Crichton-7/+3
Refactor the parser to consume token trees This is groundwork for efficiently parsing attribute proc macro invocations, bang macro invocations, and `TokenStream`-based attributes and fragment matchers. This improves parsing performance by 8-15% and expansion performance by 0-5% on a sampling of the compiler's crates. r? @nrc
2017-01-20Rollup merge of #38842 - abonander:proc_macro_attribute, r=jseyfriedAlex Crichton-3/+27
Implement `#[proc_macro_attribute]` This implements `#[proc_macro_attribute]` as described in https://github.com/rust-lang/rfcs/pull/1566 The following major (hopefully non-breaking) changes are included: * Refactor `proc_macro::TokenStream` to use `syntax::tokenstream::TokenStream`. * `proc_macro::tokenstream::TokenStream` no longer emits newlines between items, this can be trivially restored if desired * `proc_macro::TokenStream::from_str` does not try to parse an item anymore, moved to `impl MultiItemModifier for CustomDerive` with more informative error message * Implement `#[proc_macro_attribute]`, which expects functions of the kind `fn(TokenStream, TokenStream) -> TokenStream` * Reactivated `#![feature(proc_macro)]` and gated `#[proc_macro_attribute]` under it * `#![feature(proc_macro)]` and `#![feature(custom_attribute)]` are mutually exclusive * adding `#![feature(proc_macro)]` makes the expansion pass assume that any attributes that are not built-in, or introduced by existing syntax extensions, are proc-macro attributes * Fix `feature_gate::find_lang_feature_issue()` to not use `unwrap()` * This change wasn't necessary for this PR, but it helped debugging a problem where I was using the wrong feature string. * Move "completed feature gate checking" pass to after "name resolution" pass * This was necessary for proper feature-gating of `#[proc_macro_attribute]` invocations when the `proc_macro` feature flag isn't set. Prototype/Litmus Test: [Implementation](https://github.com/abonander/anterofit/blob/proc_macro/service-attr/src/lib.rs#L13) -- [Usage](https://github.com/abonander/anterofit/blob/proc_macro/service-attr/examples/post_service.rs#L35)
2017-01-17Introduce `string_reader.parse_all_token_trees()`.Jeffrey Seyfried-7/+3
2017-01-17Give the `StringReader` a `sess: &ParseSess`.Jeffrey Seyfried-1/+1
2017-01-16Implement `#[proc_macro_attribute]`Austin Bonander-3/+27
* Add support for `#[proc_macro]` * Reactivate `proc_macro` feature and gate `#[proc_macro_attribute]` under it * Have `#![feature(proc_macro)]` imply `#![feature(use_extern_macros)]`, error on legacy import of proc macros via `#[macro_use]`
2017-01-17syntax: Rename parse_ty -> parse_ty_no_plus, parse_ty_sum -> parse_tyVadim Petrochenkov-1/+1
2017-01-15Mark the pushpop_unsafe feature as "removed"est31-1/+0
This marks the pushpop_unsafe feature as removed inside the feature_gate. It was added in commit 1829fa5199bae5a192c771807c532badce14be37 and then removed again in commit d399098fd82e0bf3ed61bbbbcdbb0b6adfa4c808 . Seems that the second commit forgot to mark it as removed in feature_gate.rs. This enables us to remove another element from the whitelist of non gate tested unstable lang features (issue #39059).
2017-01-12Auto merge of #38814 - Ralith:cfg-fields, r=jseyfriedbors-0/+1
syntax: enable attributes and cfg on struct fields This enables conditional compilation of field initializers in a struct literal, simplifying construction of structs whose fields are themselves conditionally present. For example, the intializer for the constant in the following becomes legal, and has the intuitive effect: ```rust struct Foo { #[cfg(unix)] bar: (), } const FOO: Foo = Foo { #[cfg(unix)] bar: (), }; ``` It's not clear to me whether this calls for the full RFC process, but the implementation was simple enough that I figured I'd begin the conversation with code.
2017-01-11syntax: struct field attributes and cfgBenjamin Saunders-0/+1
2017-01-02rustc: Stabilize the `proc_macro` featureAlex Crichton-1/+0
This commit stabilizes the `proc_macro` and `proc_macro_lib` features in the compiler to stabilize the "Macros 1.1" feature of the language. Many more details can be found on the tracking issue, #35900. Closes #35900
2016-12-18Refactor out `mark.as_placeholder_id()`.Jeffrey Seyfried-4/+4
2016-12-18Avoid including attributes in bang macro invocations.Jeffrey Seyfried-21/+17
2016-12-18Remove scope placeholders, remove method `add_macro` of `ext::base::Resolver`.Jeffrey Seyfried-15/+22
2016-12-17Auto merge of #38205 - jseyfried:fix_module_directory_regression, r=eddybbors-1/+1
macros: fix the expected paths for a non-inline module matched by an `item` fragment Fixes #38190. r? @nrc
2016-12-07macros: fix the expected paths for a non-inline module matched by an `item` ↵Jeffrey Seyfried-1/+1
fragment.