Josh Driver
2d91e7aab8
Refactor macro resolution errors + add derive macro suggestions
2017-02-16 22:03:15 +10:30
Jeffrey Seyfried
2cc61eebb7
Allow using inert attributes from proc_macro_derives with #![feature(proc_macro)].
2017-02-12 07:20:04 +00:00
Josh Driver
fbdd038866
Move derive macro expansion into the MacroExpander
...
This removes the expand_derives function, and sprinkles
the functionality throughout the Invocation Collector,
Expander and Resolver.
2017-02-05 09:31:02 +10:30
Josh Driver
0a7380d7fc
Rename CustomDerive to ProcMacroDerive for macros 1.1
2017-02-05 09:31:02 +10:30
Josh Driver
0477daf9f0
Make builtin derives a SyntaxExtension
...
This allows builtin derives to be registered and
resolved, just like other derive types.
2017-02-05 09:31:01 +10:30
Jeffrey Seyfried
debcbf0b8e
Refactor the parser to consume token trees.
2017-01-17 08:17:26 +00:00
Jeffrey Seyfried
c12fc66a9d
Allow legacy custom derive authors to disable warnings in downstream crates.
2016-12-23 05:49:34 +00:00
Jeffrey Seyfried
6f040b48ef
Avoid including attributes in bang macro invocations.
2016-12-18 23:26:31 +00:00
Jeffrey Seyfried
421c5d11c1
Remove scope placeholders, remove method add_macro of ext::base::Resolver.
2016-12-18 23:26:30 +00:00
Jeffrey Seyfried
e80d1a8faf
Remove MacroDef's fields imported_from and allow_internal_unstable,
...
remove `export` argument of `resolver.add_macro()`.
2016-12-18 23:26:29 +00:00
Jeffrey Seyfried
5675d9d280
Clean up directory ownership semantics.
2016-11-22 01:48:10 +00:00
Jeffrey Seyfried
36c8f6b0d3
Cleanup InternedString.
2016-11-21 09:00:56 +00:00
Jeffrey Seyfried
e85a0d70b8
Use Symbol instead of InternedString in the AST, HIR, and various other places.
2016-11-21 09:00:55 +00:00
Jeffrey Seyfried
d2f8fb0a0a
Move syntax::util::interner -> syntax::symbol, cleanup.
2016-11-20 23:40:20 +00:00
Jeffrey Seyfried
641274f907
Resolve imports during expansion.
2016-11-17 08:07:44 +00:00
Mark-Simulacrum
7bbebb1f54
Change implementation of syntax::util::SmallVector to use data_structures::SmallVec.
2016-11-11 07:38:48 -07:00
Jeffrey Seyfried
11195676a0
Elimite $crate before invokng custom derives.
2016-11-10 10:23:35 +00:00
Jeffrey Seyfried
23ad6fdb66
Improve tt-heavy expansion performance.
2016-11-04 02:38:54 +00:00
Jeffrey Seyfried
cbd24757eb
Move CrateConfig from Crate to ParseSess.
2016-10-29 07:52:58 +00:00
Jeffrey Seyfried
53de24bbd1
Refactor away fields MacroDef::{use_locally, export}.
2016-10-24 00:43:19 +00:00
Eduard-Mihai Burtescu
a6788d0ba8
Rollup merge of #37198 - jseyfried:future_proof_macros_11, r=nrc
...
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-19 08:00:00 +03:00
Jeffrey Seyfried
33e3da831c
Use the macro namespace for custom derives.
2016-10-15 22:55:19 +00:00
Jeffrey Seyfried
d902963b6d
Refactor syntax::ext::base::Resolver::resolve_invoc.
2016-10-15 20:50:02 +00:00
Nicholas Nethercote
029dceedb9
Avoid many CrateConfig clones.
...
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-14 16:38:12 +11:00
Jeffrey Seyfried
31e0e12e69
Add support for undetermined macro invocations.
2016-10-11 03:41:48 +00:00
Jeffrey Seyfried
21b4369322
Refactor away ext::expand::{expand_crate, expand_crate_with_expander}.
2016-10-07 21:54:04 +00:00
Jeffrey Seyfried
09e41b6784
Add macros from plugins in libsyntax_ext::register_builtins.
2016-10-07 21:54:03 +00:00
Jeffrey Seyfried
2df25adbed
Combine std_inject::{no_core, no_std} into std_inject::injected_crate_name.
2016-10-07 21:54:01 +00:00
Jeffrey Seyfried
c9f81190f2
Refactor ext::base::Resolver::add_ext to only define macros in the crate root.
2016-10-02 06:02:47 +00:00
Jonathan Turner
f1ea5cc273
Rollup merge of #36789 - jseyfried:non_inline_mod_in_block, r=nikomatsakis
...
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-28 20:21:52 -07:00
Jeffrey Seyfried
ce5ad1da12
Allow non-inline modules in more places.
2016-09-28 22:16:20 +00:00
bors
a059cb2f33
Auto merge of #36601 - jseyfried:build_reduced_graph_in_expansion, r=nrc
...
Assign def ids and build the module graph during expansion
r? @nrc
2016-09-27 14:11:07 -07:00
Jeffrey Seyfried
f34e49dd90
With --test, make #[test] functions pub in InvocationCollector
...
and expand the `__test_reexports` in the correct scope.
2016-09-27 06:43:49 +00:00
Jeffrey Seyfried
0613dac042
Avoid aborting after expansion from BuildReducedGraphVisitor errors.
2016-09-27 06:43:48 +00:00
Jeffrey Seyfried
4a8467b62d
Remove TokResult.
2016-09-26 04:16:55 +00:00
Jeffrey Seyfried
b4906a93a0
Load macros from #[macro_use] extern crates in resolve.
2016-09-24 20:22:25 +00:00
Jeffrey Seyfried
1599461256
Refactor ext::tt::macro_rules::compile to take a ParseSess instead of an ExtCtxt.
2016-09-24 01:06:53 +00:00
bors
533c04dbb3
Auto merge of #36573 - jseyfried:groundwork, r=nrc
...
resolve: groundwork for building the module graph during expansion
r? @nrc
2016-09-22 19:54:56 -07:00
Jeffrey Seyfried
1ee64e44a9
Use Resolver::visit_expansion only with monotonic expansions.
2016-09-22 21:14:03 +00:00
Nick Cameron
3863834d9c
reviewer comments and rebasing
2016-09-23 07:19:31 +12:00
Nick Cameron
6a2d2c9495
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.
2016-09-22 08:47:57 +12:00
Jeffrey Seyfried
2abdc8805c
Remove MacroRulesTT.
2016-09-15 21:16:51 +00:00
Jeffrey Seyfried
0ddb66c4c7
Allow IdentMacroExpander::expand to access the ident macro invocation's attributes.
2016-09-15 20:57:54 +00:00
Jeffrey Seyfried
b54e1e3997
Differentiate between monotonic and non-monotonic expansion and
...
only assign node ids during monotonic expansion.
2016-09-13 09:40:28 +00:00
Jeffrey Seyfried
c86c8d41a2
Perform node id assignment and macros_at_scope construction during
...
the `InvocationCollector` and `PlaceholderExpander` folds.
2016-09-13 09:40:28 +00:00
Jeffrey Seyfried
72a636975f
Move macro resolution into librustc_resolve.
2016-09-13 09:40:26 +00:00
Jeffrey Seyfried
a9821e1658
Refactor ExtCtxt to use a Resolver instead of a MacroLoader.
2016-09-13 05:31:16 +00:00
Jeffrey Seyfried
50f94f6c95
Avoid needless reexpansions.
2016-09-13 05:11:45 +00:00
Jeffrey Seyfried
d986bbe674
Implement stackless expansion.
2016-09-05 04:53:34 +00:00
Jeffrey Seyfried
79fa9eb643
Refactor SyntaxEnv.
2016-09-05 04:53:32 +00:00