Commit Graph

50 Commits

Author SHA1 Message Date
Jeffrey Seyfried
6cb33a089f Cleanup formatting. 2016-11-17 08:16:32 +00:00
Jeffrey Seyfried
9c88650080 Add feature use_extern_macros. 2016-11-17 08:08:06 +00:00
Jeffrey Seyfried
1bbf7a43d3 Add field expansion: Mark to NameBinding. 2016-11-17 08:07:46 +00:00
Jeffrey Seyfried
83aac43f52 Refactor Resolver::builtin_macros to use NameBindings instead of DefIds. 2016-11-17 08:07:45 +00:00
Jeffrey Seyfried
641274f907 Resolve imports during expansion. 2016-11-17 08:07:44 +00:00
Jeffrey Seyfried
907120637e Add field module.unresolved_invocations. 2016-11-17 08:07:41 +00:00
bors
3dced6f71e Auto merge of #37645 - jseyfried:fix_crate_var_in_custom_derives, r=nrc
Fix regression involving custom derives on items with `$crate`

The regression was introduced in #37213.

I believe we cannot make the improvements from #37213 work with the current custom derive setup (c.f. https://github.com/rust-lang/rust/issues/37637#issuecomment-258959145) -- we'll have to wait for `TokenStream`'s API to improve.

Fixes #37637.
r? @nrc
2016-11-10 11:25:17 -08:00
Jeffrey Seyfried
11195676a0 Elimite $crate before invokng custom derives. 2016-11-10 10:23:35 +00:00
Jeffrey Seyfried
872943c317 Improve macro reexports. 2016-11-10 10:04:24 +00:00
bors
09fc1af9d8 Auto merge of #37506 - jseyfried:improve_shadowing_checks, r=nrc
macros: improve shadowing checks

This PR improves macro-expanded shadowing checks to work with out-of-(pre)order expansion.

Out-of-order expansion became possible in #37084, so this technically a [breaking-change] for nightly.
The regression test from this PR is an example of code that would break.

r? @nrc
2016-11-06 19:12:28 -08:00
Jeffrey Seyfried
076c5d445b Fix shadowing checking. 2016-11-02 07:42:37 +00:00
Seo Sanghyeon
07c8a25f42 Remove unused type aliases 2016-10-31 23:14:27 +09:00
Jeffrey Seyfried
6c4b551403 Cleanup Resolver::disallowed_shadowing. 2016-10-31 06:56:06 +00:00
Jeffrey Seyfried
53de24bbd1 Refactor away fields MacroDef::{use_locally, export}. 2016-10-24 00:43:19 +00:00
Jeffrey Seyfried
8b0c292a72 Improve $crate. 2016-10-19 10:03:06 +00: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
Jeffrey Seyfried
a4c0daab6d Remove LegacyBindingKind::MacroUse. 2016-10-11 05:14:10 +00:00
Jeffrey Seyfried
111caef9a3 Clean up the scopes of expanded #[macro_use] imports. 2016-10-11 05:14:08 +00:00
Jeffrey Seyfried
31e0e12e69 Add support for undetermined macro invocations. 2016-10-11 03:41:48 +00:00
Jeffrey Seyfried
6808b0a2b7 Check for shadowing errors after all invocations have been expanded. 2016-10-11 03:28:54 +00:00
Jeffrey Seyfried
53fd3b0acc Avoid quadratic complexity. 2016-10-10 09:35:25 +00:00
Jeffrey Seyfried
fbc96e18ad Persistent macro scopes. 2016-10-08 03:41:55 +00:00
Jeffrey Seyfried
a23bdd2769 Rename resolve::macros::{ExpansionData -> InvocationData}. 2016-10-07 21:54:37 +00:00
Jeffrey Seyfried
2cf964967c Immutable ExpansionData. 2016-10-07 21:54:05 +00:00
bors
f3745653e1 Auto merge of #36767 - jseyfried:enforce_rfc_1560_shadowing, r=nrc
Enforce the shadowing restrictions from RFC 1560 for today's macros

This PR enforces a weakened version of the shadowing restrictions from RFC 1560. More specifically,
 - If a macro expansion contains a `macro_rules!` macro definition that is used outside of the expansion, the defined macro may not shadow an existing macro.
 - If a macro expansion contains a `#[macro_use] extern crate` macro import that is used outside of the expansion, the imported macro may not shadow an existing macro.

This is a [breaking-change]. For example,
```rust
macro_rules! m { () => {} }
macro_rules! n { () => {
    macro_rules! m { () => {} } //< This shadows an existing macro.
    m!(); //< This is inside the expansion that generated `m`'s definition, so it is OK.
} }
n!();
m!(); //< This use of `m` is outside the expansion, so it causes the shadowing to be an error.
```

r? @nrc
2016-10-03 01:30:32 -07:00
Jeffrey Seyfried
ed1e00268b Enforce the weakened shadowing restriction. 2016-10-02 08:25:27 +00:00
Jeffrey Seyfried
1817ca4686 Refactor out resolve_macro_name. 2016-10-02 06:07:20 +00:00
Jeffrey Seyfried
2df4f2a126 Add field backtrace: SyntaxContext to ExpansionData. 2016-10-02 06:07:08 +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
Jeffrey Seyfried
797eb57aa8 Refactor field expansion_data of Resolver to use a Mark instead of a u32. 2016-10-02 04:25:31 +00:00
Jeffrey Seyfried
5c2d76d23e Add struct macros::NameBinding. 2016-10-02 04:25:27 +00:00
Jeffrey Seyfried
316f7bb1a8 Fix ICE on a macro in a constant integer position that expands into other macros. 2016-09-29 02:25:21 +00:00
Jeffrey Seyfried
d854c362fe Fix def id collection for const_integers in the AST. 2016-09-27 06:43:51 +00: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
634ecf038d Merge ModuleData and ModuleS. 2016-09-27 06:43:43 +00:00
Jeffrey Seyfried
b3a81ee844 Build the reduced graph during expansion. 2016-09-27 06:42:10 +00:00
Jeffrey Seyfried
ebaaafcd5d Peform def id assignment during expansion. 2016-09-27 06:42:09 +00:00
bors
d0623cf7bd Auto merge of #36678 - TimNN:fix-dist, r=alexcrichton
emit feature help in cheat mode (fix nightlies)

This should fix the `distcheck` failure in the latest nightly.

cc #36539

It's probably not ideal to check the environment that often and the code ist duplicated from `librustc/session/config.rs` but this was the easiest fix I could think of.

A cleaner solution would probably be to move the `unstable_features` from `Options` to `ParseSess` and change the `diag` parameter of `emit_feature_err` to take `ParseSess` instead of a `Handler`.
2016-09-26 17:44:25 -07:00
Tim Neumann
f0e1738e51 fix rebase fallout 2016-09-26 17:21:45 +02:00
Jeffrey Seyfried
77958d56bc Forbid user-defined macros named "macro_rules". 2016-09-26 00:22:40 +00:00
Jeffrey Seyfried
b4906a93a0 Load macros from #[macro_use] extern crates in resolve. 2016-09-24 20:22:25 +00:00
Jeffrey Seyfried
7b5c59ea65 Load extern crates in resolve. 2016-09-23 06:35:33 +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
bors
3a5d975fdc Auto merge of #36154 - nrc:proc-macro-init, r=@jseyfried
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-22 16:33:41 -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
Eduard Burtescu
fc363cb482 rustc_metadata: go only through rustc_serialize in astencode. 2016-09-20 20:07:54 +03: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