2016-01-21 17:19:23 -06:00
|
|
|
[package]
|
|
|
|
authors = ["The Rust Project Developers"]
|
|
|
|
name = "rustc_metadata"
|
|
|
|
version = "0.0.0"
|
|
|
|
|
|
|
|
[lib]
|
|
|
|
name = "rustc_metadata"
|
|
|
|
path = "lib.rs"
|
|
|
|
crate-type = ["dylib"]
|
|
|
|
|
|
|
|
[dependencies]
|
2017-12-29 04:24:38 -06:00
|
|
|
flate2 = "1.0"
|
2018-01-07 09:54:05 -06:00
|
|
|
log = "0.4"
|
2016-10-03 11:49:39 -05:00
|
|
|
proc_macro = { path = "../libproc_macro" }
|
2016-01-21 17:19:23 -06:00
|
|
|
rustc = { path = "../librustc" }
|
2017-12-08 13:18:21 -06:00
|
|
|
rustc_target = { path = "../librustc_target" }
|
2016-06-28 15:41:09 -05:00
|
|
|
rustc_data_structures = { path = "../librustc_data_structures" }
|
2016-06-21 17:08:13 -05:00
|
|
|
rustc_errors = { path = "../librustc_errors" }
|
2016-01-21 17:19:23 -06:00
|
|
|
serialize = { path = "../libserialize" }
|
|
|
|
syntax = { path = "../libsyntax" }
|
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-08-22 19:07:11 -05:00
|
|
|
syntax_ext = { path = "../libsyntax_ext" }
|
|
|
|
syntax_pos = { path = "../libsyntax_pos" }
|