about summary refs log tree commit diff
path: root/src/libsyntax/ext/base.rs
AgeCommit message (Collapse)AuthorLines
2016-09-23reviewer comments and rebasingNick Cameron-62/+86
2016-09-22Adds a `ProcMacro` form of syntax extensionNick Cameron-8/+195
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-15Remove `MacroRulesTT`.Jeffrey Seyfried-3/+0
2016-09-15Allow `IdentMacroExpander::expand` to access the ident macro invocation's ↵Jeffrey Seyfried-2/+4
attributes.
2016-09-13Differentiate between monotonic and non-monotonic expansion andJeffrey Seyfried-1/+7
only assign node ids during monotonic expansion.
2016-09-13Perform node id assignment and `macros_at_scope` construction duringJeffrey Seyfried-0/+3
the `InvocationCollector` and `PlaceholderExpander` folds.
2016-09-13Move macro resolution into `librustc_resolve`.Jeffrey Seyfried-237/+61
2016-09-13Refactor `ExtCtxt` to use a `Resolver` instead of a `MacroLoader`.Jeffrey Seyfried-6/+6
2016-09-13Avoid needless reexpansions.Jeffrey Seyfried-5/+10
2016-09-05Implement stackless expansion.Jeffrey Seyfried-22/+3
2016-09-05Refactor `SyntaxEnv`.Jeffrey Seyfried-75/+94
2016-09-05Generalize `Invocation` to include modifiers/decorators.Jeffrey Seyfried-10/+0
2016-09-05In `Parser` and `ExtCtxt`, replace fields `filename` and `mod_path_stack`Jeffrey Seyfried-4/+3
with a single field `directory: PathBuf`.
2016-09-02rustc: Implement custom derive (macros 1.1)Alex Crichton-3/+30
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-29Remove inherent methods `Annotatable::attrs` and `Annotatable::fold_attrs`.Jeffrey Seyfried-7/+0
2016-08-10Extended expand.rs to support alternate expansion behavioursDaniel Campbell-1/+1
Added single_step & keep_macs flags and functionality to expander
2016-07-16Auto merge of #34816 - jseyfried:fix_include_path, r=nrcbors-0/+6
Fix `include!()`s inside `asm!()` invocations Fixes #34812, a regression caused by #33749 that was not fixed in #34450. r? @nrc
2016-07-14Make `ext::base::expr_to_string` work correctly with `include!` macro ↵Jeffrey Seyfried-0/+6
invocations
2016-07-14Instead of renaming, treat differently marked identifiers as unequalJeffrey Seyfried-4/+0
2016-07-03prefer `if let` to match with `None => {}` arm in some placesZack M. Davis-3/+2
This is a spiritual succesor to #34268/8531d581, in which we replaced a number of matches of None to the unit value with `if let` conditionals where it was judged that this made for clearer/simpler code (as would be recommended by Manishearth/rust-clippy's `single_match` lint). The same rationale applies to matches of None to the empty block.
2016-06-28cleanup: use `DummyResult` to implement `MacroGenerable::dummy`Jeffrey Seyfried-0/+4
2016-06-26Rollup merge of #34339 - jseyfried:thin_vec, r=petrochenkov,ManishearthJeffrey Seyfried-1/+1
Generalize and abstract `ThinAttributes` to `ThinVec<Attribute>`.
2016-06-26Rollup merge of #34316 - jseyfried:refactor_ast_stmt, r=eddybJeffrey Seyfried-8/+10
Refactor away `ast::Decl`, refactor `ast::Stmt`, and rename `ast::ExprKind::Again` to `ast::ExprKind::Continue`.
2016-06-26Rollup merge of #34385 - cgswords:tstream, r=nrcJeffrey Seyfried-12/+16
syntax-[breaking-change] cc #31645 (Only breaking because ast::TokenTree is now tokenstream::TokenTree.) This pull request refactors TokenTrees into their own file as src/libsyntax/tokenstream.rs, moving them out of src/libsyntax/ast.rs, in order to prepare for an accompanying TokenStream implementation (per RFC 1566).
2016-06-25Rollup merge of #34403 - jonathandturner:move_liberror, r=alexcrichtonJeffrey Seyfried-2/+2
This PR refactors the 'errors' part of libsyntax into its own crate (librustc_errors). This is the first part of a few refactorings to simplify error reporting and potentially support more output formats (like a standardized JSON output and possibly an --explain mode that can work with the user's code), though this PR stands on its own and doesn't assume further changes. As part of separating out the errors crate, I have also refactored the code position portion of codemap into its own crate (libsyntax_pos). While it's helpful to have the common code positions in a separate crate for the new errors crate, this may also enable further simplifications in the future.
2016-06-25Rollup merge of #34213 - josephDunne:trait_item_macros, r=jseyfriedJeffrey Seyfried-0/+18
**syntax-[breaking-change]** cc #31645 New `TraitItemKind::Macro` variant This change adds support for macro expansion inside trait items by adding the new `TraitItemKind::Macro` and associated parsing code.
2016-06-23Move errors from libsyntax to its own crateJonathan Turner-2/+2
2016-06-23Auto merge of #34253 - jseyfried:improve_multi_modifiers, r=nrcbors-27/+32
Allow `MultiItemModifier`s to expand into zero or many items Fixes #34223. r? @nrc
2016-06-21Refactored tokentrees into their own files in preparation for tokenstreams. ↵cgswords-12/+16
Modified tests to point to the new file now.
2016-06-18Auto merge of #34295 - jseyfried:cfg_decoration, r=eddybbors-0/+10
Perform `cfg` attribute processing on decorator-generated items Fixes https://users.rust-lang.org/t/unused-attribute-warning-for-custom-derive-attribute/6180. r? @nrc
2016-06-19Generalize and abstract `ThinAttributes`Jeffrey Seyfried-1/+1
2016-06-17Fix falloutJeffrey Seyfried-8/+10
2016-06-16Simplify gated cfg checkingJeffrey Seyfried-4/+0
2016-06-16Auto merge of #34239 - jseyfried:fix_macro_use_scope_regression, r=nrcbors-1/+1
Revert a change in the scope of macros imported from crates to fix a regression Fixes #34212. The regression was caused by #34032, which changed the scope of macros imported from extern crates to match the scope of macros imported from modules. r? @nrc
2016-06-16Strip unconfigured nodes from decorator-generated ASTJeffrey Seyfried-0/+10
2016-06-16Allow `MultiItemModifier`s to expand into zero or many itemsJeffrey Seyfried-11/+13
2016-06-16Implement `HasAttrs` for `Annotatable`Jeffrey Seyfried-16/+19
2016-06-13Auto merge of #33749 - jseyfried:fix_call_site_span, r=nrcbors-16/+0
Fix macro call site spans Fix macro call site spans. r? @nrc
2016-06-13Add support for macro expansion inside trait itemsJoseph Dunne-0/+18
2016-06-12Load macros from `#[macro_use]` crates earlier in expansionJeffrey Seyfried-1/+1
2016-06-09Add comment and clean up `expand_annotatable`Jeffrey Seyfried-0/+2
2016-06-09Load macros from `extern crate`s during expansion.Jeffrey Seyfried-1/+20
2016-05-28Fix macro call site spansJeffrey Seyfried-16/+0
2016-05-02replace fileline_{help,note} with {help,note}Niko Matsakis-4/+3
The extra filename and line was mainly there to keep the indentation relative to the main snippet; now that this doesn't include filename/line-number as a prefix, it is distracted.
2016-03-02Fix the search paths for macro-expanded non-inline modulesJeffrey Seyfried-0/+8
2016-02-16Add check on find_best_match_for_name and improve help message for undefined ↵ggomez-1/+6
macro
2016-02-13Rename ast::Pat_ and its variantsVadim Petrochenkov-3/+3
2016-02-11Remove some unnecessary indirection from AST structuresVadim Petrochenkov-16/+16
2016-02-11[breaking-change] don't glob export ast::Item_ variantsOliver 'ker' Schneider-1/+1
2016-02-11[breaking-change] don't pub export ast::Stmt_ variantsOliver Schneider-3/+3