Commit Graph

42 Commits

Author SHA1 Message Date
Jeffrey Seyfried 36c8f6b0d3 Cleanup `InternedString`. 2016-11-21 09:00:56 +00:00
Jeffrey Seyfried d2f8fb0a0a Move `syntax::util::interner` -> `syntax::symbol`, cleanup. 2016-11-20 23:40:20 +00:00
Jeffrey Seyfried a2626410d7 Refactor `MetaItemKind` to use `Name`s instead of `InternedString`s. 2016-11-20 11:46:06 +00:00
Niko Matsakis 3fd67eba87 fallout from separating impl-items from impls
Basically adding `visit_impl_item` in various places and so forth.
2016-11-16 13:57:43 -05:00
Niko Matsakis 36fbf8c53c refactor Visitor into ItemLikeVisitor and intravisit::Visitor
There are now three patterns (shallow, deep, and nested visit).  These
are described in detail on the docs in `itemlikevisit::ItemLikeVisitor`.
2016-11-16 13:51:36 -05:00
iirelu e593c3b893 Changed most vec! invocations to use square braces
Most of the Rust community agrees that the vec! macro is clearer when
called using square brackets [] instead of regular brackets (). Most of
these ocurrences are from before macros allowed using different types of
brackets.

There is one left unchanged in a pretty-print test, as the pretty
printer still wants it to have regular brackets.
2016-10-31 22:51:40 +00:00
Jeffrey Seyfried cbd24757eb Move `CrateConfig` from `Crate` to `ParseSess`. 2016-10-29 07:52:58 +00:00
Jeffrey Seyfried 2b43fac2b9 Remove `CrateReader`, use `CrateLoader` instead. 2016-10-22 20:01:38 +00:00
Jeffrey Seyfried 77958d56bc Forbid user-defined macros named "macro_rules". 2016-09-26 00:22:40 +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
bors 86995dc8c5 Auto merge of #36240 - leeopop:master, r=jseyfried
Allow CompilerControllers to access rustc_plugin::registry::Registry

fixes #36064

I chose to put ructc_plugin::registry::Registry structure
into CompilerState structure, instead of Session structure.
This will preserve dependencies among librustc, libructc_driver, and libructc_plugin.

@jseyfried @sanxiyn
2016-09-04 18:36:42 -07:00
Keunhong Lee ca5dfd0c97 Allow CompilerControllers to access rustc_plugin::registry::Registry structure. 2016-09-04 03:22:56 +00:00
Alex Crichton ecc6c39e87 rustc: Implement custom derive (macros 1.1)
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-09-02 12:52:56 -07:00
Chiu-Hsiang Hsu 3f7432a399 Change 'rustc::plugin' to 'rustc_plugin' in doc comment 2016-08-31 22:45:37 +08:00
Jeffrey Seyfried bfb01bbb26 Refactor away `AttrMetaMethods`. 2016-08-25 20:41:40 +00:00
Jeffrey Seyfried 4eb08bb2ab Refactor away `AttrNestedMetaItemMethods`. 2016-08-25 20:41:32 +00:00
Sergio Benitez 8250a26b5b Implement RFC#1559: allow all literals in attributes. 2016-08-25 13:25:22 -07:00
Michael Woerister 65eb024542 Remove the 'cfg' field from session::config::Options.
The 'cfg' in the Options struct is only the commandline-specified
subset of the crate configuration and it's almost always wrong to
read that instead of the CrateConfig in HIR crate node.
2016-08-11 09:56:00 -04:00
Jeffrey Seyfried 542ba8c5f7 Fix `Cargo.toml`s 2016-06-27 18:30:46 +00:00
Jonathan Turner 6ae3502134 Move errors from libsyntax to its own crate 2016-06-23 08:07:35 -04:00
Ariel Ben-Yehuda 70c25c848c remove the librustc_trans -> librustc_mir dependency 2016-06-08 23:58:53 +03:00
Eduard Burtescu 7462da5c38 rustc: use a simpler scheme for plugin registrar symbol names. 2016-05-25 01:20:55 +03:00
Oliver Schneider 46de0fadb5
fix Registry::args for plugins loaded with --extra-plugins 2016-05-10 13:36:39 +02:00
Leo Testard 03ab057f97 Remove the MacroVisitor pass.
This pass was supposed to check use of gated features before
`#[cfg]`-stripping but this was not the case since it in fact happens
after. Checks that are actually important and must be done before macro
expansion are now made where the features are actually used. Close #32648.
Also ensure that attributes on macro-generated macro invocations are
checked as well. Close #32782 and #32655.
2016-04-22 01:40:33 +02:00
Eduard Burtescu 8b0937293b rustc: move rustc_front to rustc::hir. 2016-04-06 09:01:55 +03:00
Michael Woerister 2eebb7b605 Make the compiler emit an error if the crate graph contains two crates with the same crate-name and crate-salt but different SVHs. 2016-03-25 14:07:18 -04:00
bors c21644ad16 Auto merge of #31916 - nagisa:mir-passmgr-2, r=arielb1
Add Pass manager for MIR

A new PR, since rebasing the original one (https://github.com/rust-lang/rust/pull/31448) properly was a pain. Since then there has been several changes most notable of which:

1. Removed the pretty-printing with `#[rustc_mir(graphviz/pretty)]`, mostly because we now have `--unpretty=mir`, IMHO that’s the direction we should expand this functionality into;
2. Reverted the infercx change done for typeck, because typeck can make an infercx for itself by being a `MirMapPass`

r? @nikomatsakis
2016-03-13 05:33:28 -07:00
Alex Crichton b53764c73b std: Clean out deprecated APIs
Removes all unstable and deprecated APIs prior to the 1.8 release. All APIs that
are deprecated in the 1.8 release are sticking around for the rest of this
cycle.

Some notable changes are:

* The `dynamic_lib` module was moved into `rustc_back` as the compiler still
  relies on a few bits and pieces.
* The `DebugTuple` formatter now special-cases an empty struct name with only
  one field to append a trailing comma.
2016-03-12 12:31:13 -08:00
Simonas Kazlauskas 811b874716 Add Pass manager for MIR 2016-03-04 15:20:10 +02:00
Alex Crichton 95761417c3 rustbuild: Sync some Cargo.toml/lib.rs dependencies
The standard library doesn't depend on rustc_bitflags, so move it to explicit
dependencies on all other crates. Additionally, the arena/fmt_macros deps could
be dropped from libsyntax.
2016-02-21 09:49:13 -08:00
Jonas Schievink d12adae719 Autoderef in librustc_plugin 2016-02-12 19:28:42 +01:00
Alex Crichton 2581b14147 bootstrap: Add a bunch of Cargo.toml files
These describe the structure of all our crate dependencies.
2016-02-11 11:12:32 -08:00
Oliver Schneider 4b067183ba Allow registering MIR-passes through compiler plugins 2016-02-09 16:53:43 +01:00
Niko Matsakis 35b6e2b0bb Instrument a bunch of tasks that employ the HIR map in one way or
another and were not previously instrumented.
2016-02-05 13:19:55 -05:00
Alex Crichton 2273b52023 mk: Move from `-D warnings` to `#![deny(warnings)]`
This commit removes the `-D warnings` flag being passed through the makefiles to
all crates to instead be a crate attribute. We want these attributes always
applied for all our standard builds, and this is more amenable to Cargo-based
builds as well.

Note that all `deny(warnings)` attributes are gated with a `cfg(stage0)`
attribute currently to match the same semantics we have today
2016-01-24 20:35:55 -08:00
Nick Cameron 95dc7efad0 use structured errors 2015-12-30 14:27:59 +13:00
Alex Crichton cd1848a1a6 Register new snapshots
Lots of cruft to remove!
2015-12-21 09:26:21 -08:00
Nick Cameron 6309b0f5bb move error handling from libsyntax/diagnostics.rs to libsyntax/errors/*
Also split out emitters into their own module.
2015-12-17 09:35:50 +13:00
Ariel Ben-Yehuda 0a8bb4c509 split the metadata code into rustc_metadata
tests & rustdoc still broken
2015-11-26 18:22:40 +02:00
Ariel Ben-Yehuda 1430a35000 move librustc/plugin to librustc_plugin
this is a [breaking-change] to all plugin authors - sorry
2015-11-26 18:22:39 +02:00