about summary refs log tree commit diff
path: root/src/libsyntax/ext/expand.rs
AgeCommit message (Collapse)AuthorLines
2016-09-26make emit_feature_err take a ParseSessTim Neumann-1/+1
2016-09-26Refactor `ensure_complete_parse`.Jeffrey Seyfried-12/+8
2016-09-26Remove `TokResult`.Jeffrey Seyfried-18/+27
2016-09-26Refactor `parse_expansion` out of `ResultAnyMacro`.Jeffrey Seyfried-4/+51
2016-09-24Load macros from `#[macro_use]` extern crates in `resolve`.Jeffrey Seyfried-19/+0
2016-09-22Auto merge of #36573 - jseyfried:groundwork, r=nrcbors-8/+9
resolve: groundwork for building the module graph during expansion r? @nrc
2016-09-22Auto merge of #36154 - nrc:proc-macro-init, r=@jseyfriedbors-2/+79
Adds a `ProcMacro` form of syntax extension This commit adds syntax extension forms matching the types for procedural macros 2.0 (RFC #1566), these still require the usual syntax extension boiler plate, but this is a first step towards proper implementation and should be useful for macros 1.1 stuff too. Supports both attribute-like and function-like macros. Note that RFC #1566 has not been accepted yet, but I think there is consensus that we want to head in vaguely that direction and so this PR will be useful in any case. It is also fairly easy to undo and does not break any existing programs. This is related to #35957 in that I hope it can be used in the implementation of macros 1.1, however, there is no direct overlap and is more of a complement than a competing proposal. There is still a fair bit of work to do before the two can be combined. r? @jseyfried cc @alexcrichton, @cgswords, @eddyb, @aturon
2016-09-22Use `Resolver::visit_expansion` only with monotonic expansions.Jeffrey Seyfried-8/+9
2016-09-23reviewer comments and rebasingNick Cameron-29/+57
2016-09-22Auto merge of #36618 - jseyfried:crate_root_attr_invoc, r=nrcbors-7/+14
macros: allow attribute invocations at the crate root Fixes #36617. r? @nrc
2016-09-22Adds a `ProcMacro` form of syntax extensionNick Cameron-2/+51
This commit adds syntax extension forms matching the types for procedural macros 2.0 (RFC #1566), these still require the usual syntax extension boiler plate, but this is a first step towards proper implementation and should be useful for macros 1.1 stuff too. Supports both attribute-like and function-like macros.
2016-09-21Allow attribute macro invocations at the crate root.Jeffrey Seyfried-7/+14
2016-09-20rustc_metadata: go only through rustc_serialize in astencode.Eduard Burtescu-3/+3
2016-09-15Remove `MacroRulesTT`.Jeffrey Seyfried-41/+1
2016-09-15Allow `IdentMacroExpander::expand` to access the ident macro invocation's ↵Jeffrey Seyfried-1/+1
attributes.
2016-09-15Move fields `single_step` and `keep_macs` from `MacroExpander` to ↵Jeffrey Seyfried-10/+7
`ExpansionConfig`.
2016-09-13Differentiate between monotonic and non-monotonic expansion andJeffrey Seyfried-9/+15
only assign node ids during monotonic expansion.
2016-09-13Remove scope placeholders from the crate root.Jeffrey Seyfried-2/+13
2016-09-13Perform node id assignment and `macros_at_scope` construction duringJeffrey Seyfried-5/+19
the `InvocationCollector` and `PlaceholderExpander` folds.
2016-09-13Move macro resolution into `librustc_resolve`.Jeffrey Seyfried-105/+77
2016-09-13Rewrite the unit tests in `ext/expand.rs` as a `compile-fail` test.Jeffrey Seyfried-107/+0
2016-09-13Refactor `ExtCtxt` to use a `Resolver` instead of a `MacroLoader`.Jeffrey Seyfried-6/+6
2016-09-07Improve `directory` computation during invocation collection.Jeffrey Seyfried-5/+9
2016-09-07Implement stackless placeholder expansion.Jeffrey Seyfried-4/+15
2016-09-07Strip unconfigured nodes in the `InvocationCollector` fold.Jeffrey Seyfried-13/+60
2016-09-05Load macros from `extern crate`s in the `InvocationCollector` fold.Jeffrey Seyfried-62/+22
2016-09-05Implement stackless expansion.Jeffrey Seyfried-151/+182
2016-09-05Add module `ext::placeholders` with `placeholder()` and `PlaceholderExpander`.Jeffrey Seyfried-39/+9
2016-09-05Refactor `expand_invoc(.., fld)` -> `self.expand_invoc(..)`.Jeffrey Seyfried-207/+212
2016-09-05Refactor `SyntaxEnv`.Jeffrey Seyfried-44/+20
2016-09-05Refactor `expand_*` into `expander.fold_*`.Jeffrey Seyfried-214/+194
2016-09-05Clean up module processing.Jeffrey Seyfried-34/+20
2016-09-05Refactor out `expand_item` (with better semantics than before).Jeffrey Seyfried-36/+39
2016-09-05Refactor away `expand_item`.Jeffrey Seyfried-7/+3
2016-09-05Generalize `Invocation` to include modifiers/decorators.Jeffrey Seyfried-85/+138
2016-09-05Refactor `with_exts_frame` from a macro to a function.Jeffrey Seyfried-16/+10
2016-09-05Add `Invocation` and `Expansion`, remove `MacroGenerable`.Jeffrey Seyfried-212/+240
2016-09-05Remove `syntax::config::strip_unconfigured`, add `syntax::config::features`.Jeffrey Seyfried-2/+3
2016-09-05Improve `expand_type`.Jeffrey Seyfried-5/+8
2016-09-05In `Parser` and `ExtCtxt`, replace fields `filename` and `mod_path_stack`Jeffrey Seyfried-25/+18
with a single field `directory: PathBuf`.
2016-09-02rustc: Implement custom derive (macros 1.1)Alex Crichton-3/+8
This commit is an implementation of [RFC 1681] which adds support to the compiler for first-class user-define custom `#[derive]` modes with a far more stable API than plugins have today. [RFC 1681]: https://github.com/rust-lang/rfcs/blob/master/text/1681-macros-1.1.md The main features added by this commit are: * A new `rustc-macro` crate-type. This crate type represents one which will provide custom `derive` implementations and perhaps eventually flower into the implementation of macros 2.0 as well. * A new `rustc_macro` crate in the standard distribution. This crate will provide the runtime interface between macro crates and the compiler. The API here is particularly conservative right now but has quite a bit of room to expand into any manner of APIs required by macro authors. * The ability to load new derive modes through the `#[macro_use]` annotations on other crates. All support added here is gated behind the `rustc_macro` feature gate, both for the library support (the `rustc_macro` crate) as well as the language features. There are a few minor differences from the implementation outlined in the RFC, such as the `rustc_macro` crate being available as a dylib and all symbols are `dlsym`'d directly instead of having a shim compiled. These should only affect the implementation, however, not the public interface. This commit also ended up touching a lot of code related to `#[derive]`, making a few notable changes: * Recognized derive attributes are no longer desugared to `derive_Foo`. Wasn't sure how to keep this behavior and *not* expose it to custom derive. * Derive attributes no longer have access to unstable features by default, they have to opt in on a granular level. * The `derive(Copy,Clone)` optimization is now done through another "obscure attribute" which is just intended to ferry along in the compiler that such an optimization is possible. The `derive(PartialEq,Eq)` optimization was also updated to do something similar. --- One part of this PR which needs to be improved before stabilizing are the errors and exact interfaces here. The error messages are relatively poor quality and there are surprising spects of this such as `#[derive(PartialEq, Eq, MyTrait)]` not working by default. The custom attributes added by the compiler end up becoming unstable again when going through a custom impl. Hopefully though this is enough to start allowing experimentation on crates.io! syntax-[breaking-change]
2016-08-28Rollup merge of #35917 - jseyfried:remove_attr_ext_traits, r=nrcJeffrey Seyfried-1/+0
syntax: Remove traits `AttrMetaMethods`, `AttributeMethods`, and `AttrNestedMetaItemMethods`
2016-08-26Stabilize type-macrosDaniele Baracchi-12/+1
Closes #27245
2016-08-25Refactor away `AttrMetaMethods`.Jeffrey Seyfried-1/+0
2016-08-11Auto merge of #34811 - DanielJCampbell:Expander, r=jseyfriedbors-41/+79
Extended expand.rs to support alternate expansion behaviours (eg. stepwise expansion) r? nrc
2016-08-10Extended expand.rs to support alternate expansion behavioursDaniel Campbell-41/+79
Added single_step & keep_macs flags and functionality to expander
2016-07-25General MetaItem encapsulation rewrites.cgswords-3/+2
2016-07-17Rename `mtwt` to `hygiene`Jeffrey Seyfried-1/+1
2016-07-17Clean up and encapsulate `syntax::ext::mtwt`Jeffrey Seyfried-29/+15
2016-07-15Auto merge of #34570 - jseyfried:no_rename, r=nrcbors-558/+34
Simplify the macro hygiene algorithm This PR removes renaming from the hygiene algorithm and treats differently marked identifiers as unequal. This change makes the scope of identifiers in `macro_rules!` items empty. That is, identifiers in `macro_rules!` definitions do not inherit any semantics from the `macro_rules!`'s scope. Since `macro_rules!` macros are items, the scope of their identifiers "should" be the same as that of other items; in particular, the scope should contain only items. Since all items are unhygienic today, this would mean the scope should be empty. However, the scope of an identifier in a `macro_rules!` statement today is the scope that the identifier would have if it replaced the `macro_rules!` (excluding anything unhygienic, i.e. locals only). To continue to support this, this PR tracks the scope of each `macro_rules!` and uses it in `resolve` to ensure that an identifier expanded from a `macro_rules!` gets a chance to resolve to the locals in the `macro_rules!`'s scope. This PR is a pure refactoring. After this PR, - `syntax::ext::expand` is much simpler. - We can expand macros in any order without causing problems for hygiene (needed for macro modularization). - We can deprecate or remove today's `macro_rules!` scope easily. - Expansion performance improves by 25%, post-expansion memory usage decreases by ~5%. - Expanding a block is no longer quadratic in the number of `let` statements (fixes #10607). r? @nrc