about summary refs log tree commit diff
path: root/src/libsyntax/ext/expand.rs
AgeCommit message (Collapse)AuthorLines
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.
2016-12-06annotate stricter lifetimes on LateLintPass methods to allow them to forward ↵Oliver Schneider-1/+1
to a Visitor
2016-11-30Support paths in macro invocations.Jeffrey Seyfried-6/+1
2016-11-22Start warning cycle.Jeffrey Seyfried-1/+1
2016-11-22Clean up directory ownership semantics.Jeffrey Seyfried-9/+15
2016-11-21Use `Symbol` instead of `InternedString` in the AST, HIR, and various other ↵Jeffrey Seyfried-1/+1
places.
2016-11-20Move `syntax::util::interner` -> `syntax::symbol`, cleanup.Jeffrey Seyfried-3/+4
2016-11-20Refactor `MetaItemKind` to use `Name`s instead of `InternedString`s.Jeffrey Seyfried-3/+3
2016-11-20Refactor away `ast::Attribute_`.Jeffrey Seyfried-2/+2
2016-11-17Resolve imports during expansion.Jeffrey Seyfried-2/+11
2016-11-11Change implementation of syntax::util::SmallVector to use ↵Mark-Simulacrum-7/+7
data_structures::SmallVec.
2016-11-11Auto merge of #37246 - goffrie:no-loop, r=jseyfriedbors-1/+3
Don't spin expanding stmt macros. If we can't make progress when parsing a macro expansion as a statement then we should just bail. This alleviates the symptoms shown in e.g. #37113 and #37234 but it doesn't fix the problem that parsing invalid enum bodies (and others) leaves the parser in a crappy state. I'm not sold on this strategy (checking `tokens_consumed`), so if anyone has a better idea, I'm all ears!
2016-10-29Move `CrateConfig` from `Crate` to `ParseSess`.Jeffrey Seyfried-4/+1
2016-10-26Don't spin expanding stmt macros.Geoffry Song-1/+3
If we can't make progress when parsing a macro expansion as a statement then we should just bail. This alleviates the symptoms shown in e.g. #37113 but it doesn't fix the problem that parsing invalid enum bodies (and others) leaves the parser in a crappy state.
2016-10-19Improve `$crate`.Jeffrey Seyfried-1/+1
2016-10-15Use the macro namespace for custom derives.Jeffrey Seyfried-1/+14
2016-10-15Refactor `syntax::ext::base::Resolver::resolve_invoc`.Jeffrey Seyfried-1/+11
2016-10-11Add support for undetermined macro invocations.Jeffrey Seyfried-3/+26
2016-10-11Merge branch 'persistent_macro_scopes' into cleanup_expanded_macro_use_scopesJeffrey Seyfried-30/+19
2016-10-07Cleanup `depth`s.Jeffrey Seyfried-7/+9
2016-10-07Refactor away `ext::expand::{expand_crate, expand_crate_with_expander}`.Jeffrey Seyfried-19/+10
2016-10-07Add macros from plugins in `libsyntax_ext::register_builtins`.Jeffrey Seyfried-8/+4
2016-10-06rustc: Rename rustc_macro to proc_macroAlex Crichton-1/+1
This commit blanket renames the `rustc_macro` infrastructure to `proc_macro`, which reflects the general consensus of #35900. A follow up PR to Cargo will be required to purge the `rustc-macro` name as well.
2016-09-28Rollup merge of #36789 - jseyfried:non_inline_mod_in_block, r=nikomatsakisJonathan Turner-6/+11
Allow more non-inline modules in blocks Currently, non-inline modules without a `#[path]` attribute are not allowed in blocks. This PR allows non-inline modules that have an ancestor module with a `#[path]` attribute, provided there is not a nearer ancestor block. For example, ```rust fn main() { #[path = "..."] mod foo { mod bar; //< allowed by this PR fn f() { mod bar; //< still an error } } } ``` Fixes #36772. r? @nikomatsakis
2016-09-28Allow non-inline modules in more places.Jeffrey Seyfried-6/+11
2016-09-27Auto merge of #36601 - jseyfried:build_reduced_graph_in_expansion, r=nrcbors-3/+12
Assign def ids and build the module graph during expansion r? @nrc
2016-09-27With `--test`, make `#[test]` functions `pub` in `InvocationCollector`Jeffrey Seyfried-2/+9
and expand the `__test_reexports` in the correct scope.
2016-09-27Avoid aborting after expansion from `BuildReducedGraphVisitor` errors.Jeffrey Seyfried-1/+3
2016-09-26Auto merge of #36764 - jonathandturner:rollup, r=jonathandturnerbors-22/+86
Rollup of 14 pull requests - Successful merges: #36563, #36574, #36586, #36662, #36663, #36669, #36676, #36721, #36723, #36727, #36729, #36742, #36754, #36756 - Failed merges:
2016-09-26Move `ensure_complete_parse` into `expand.rs`.Jeffrey Seyfried-0/+12