about summary refs log tree commit diff
path: root/src/libsyntax/ext/base.rs
AgeCommit message (Collapse)AuthorLines
2016-12-18Remove scope placeholders, remove method `add_macro` of `ext::base::Resolver`.Jeffrey Seyfried-2/+0
2016-12-18Remove `MacroDef`'s fields `imported_from` and `allow_internal_unstable`,Jeffrey Seyfried-2/+2
remove `export` argument of `resolver.add_macro()`.
2016-11-22Clean up directory ownership semantics.Jeffrey Seyfried-5/+3
2016-11-21Cleanup `InternedString`.Jeffrey Seyfried-1/+1
2016-11-21Use `Symbol` instead of `InternedString` in the AST, HIR, and various other ↵Jeffrey Seyfried-4/+4
places.
2016-11-20Move `syntax::util::interner` -> `syntax::symbol`, cleanup.Jeffrey Seyfried-3/+3
2016-11-17Resolve imports during expansion.Jeffrey Seyfried-0/+2
2016-11-11Change implementation of syntax::util::SmallVector to use ↵Mark-Simulacrum-3/+3
data_structures::SmallVec.
2016-11-10Elimite `$crate` before invokng custom derives.Jeffrey Seyfried-0/+2
2016-11-04Improve `tt`-heavy expansion performance.Jeffrey Seyfried-1/+3
2016-10-29Move `CrateConfig` from `Crate` to `ParseSess`.Jeffrey Seyfried-5/+3
2016-10-24Refactor away fields `MacroDef::{use_locally, export}`.Jeffrey Seyfried-2/+2
2016-10-19Rollup merge of #37198 - jseyfried:future_proof_macros_11, r=nrcEduard-Mihai Burtescu-5/+5
macros 1.1: future proofing and cleanup This PR - uses the macro namespace for custom derives (instead of a dedicated custom derive namespace), - relaxes the shadowing rules for `#[macro_use]`-imported custom derives to match the shadowing rules for ordinary `#[macro_use]`-imported macros, and - treats custom derive `extern crate`s like empty modules so that we can eventually allow, for example, `extern crate serde_derive; use serde_derive::Serialize;` backwards compatibly. r? @alexcrichton
2016-10-15Use the macro namespace for custom derives.Jeffrey Seyfried-2/+2
2016-10-15Refactor `syntax::ext::base::Resolver::resolve_invoc`.Jeffrey Seyfried-3/+3
2016-10-14Avoid many CrateConfig clones.Nicholas Nethercote-2/+2
This commit changes `ExtCtx::cfg()` so it returns a `CrateConfig` reference instead of a clone. As a result, it also changes all of the `cfg()` callsites to explicitly clone... except one, because the commit also changes `macro_parser::parse()` to take `&CrateConfig`. This is good, because that function can be hot, and `CrateConfig` is expensive to clone. This change almost halves the number of heap allocations done by rustc for `html5ever` in rustc-benchmarks suite, which makes compilation 1.20x faster.
2016-10-11Add support for undetermined macro invocations.Jeffrey Seyfried-3/+11
2016-10-07Refactor away `ext::expand::{expand_crate, expand_crate_with_expander}`.Jeffrey Seyfried-12/+0
2016-10-07Add macros from plugins in `libsyntax_ext::register_builtins`.Jeffrey Seyfried-6/+1
2016-10-07Combine `std_inject::{no_core, no_std}` into `std_inject::injected_crate_name`.Jeffrey Seyfried-7/+1
2016-10-02Refactor `ext::base::Resolver::add_ext` to only define macros in the crate root.Jeffrey Seyfried-3/+3
2016-09-28Rollup merge of #36789 - jseyfried:non_inline_mod_in_block, r=nikomatsakisJonathan Turner-2/+4
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-2/+4
2016-09-27Auto merge of #36601 - jseyfried:build_reduced_graph_in_expansion, r=nrcbors-0/+4
Assign def ids and build the module graph during expansion r? @nrc
2016-09-27With `--test`, make `#[test]` functions `pub` in `InvocationCollector`Jeffrey Seyfried-0/+2
and expand the `__test_reexports` in the correct scope.
2016-09-27Avoid aborting after expansion from `BuildReducedGraphVisitor` errors.Jeffrey Seyfried-0/+2
2016-09-26Remove `TokResult`.Jeffrey Seyfried-142/+1
2016-09-24Load macros from `#[macro_use]` extern crates in `resolve`.Jeffrey Seyfried-46/+8
2016-09-24Refactor `ext::tt::macro_rules::compile` to take a `ParseSess` instead of an ↵Jeffrey Seyfried-1/+1
`ExtCtxt`.
2016-09-22Auto merge of #36573 - jseyfried:groundwork, r=nrcbors-2/+4
resolve: groundwork for building the module graph during expansion r? @nrc
2016-09-22Use `Resolver::visit_expansion` only with monotonic expansions.Jeffrey Seyfried-2/+4
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