2015-11-24 16:00:26 -06:00
|
|
|
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
2016-01-21 17:26:19 -06:00
|
|
|
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
|
|
|
|
html_root_url = "https://doc.rust-lang.org/nightly/")]
|
2015-11-24 16:00:26 -06:00
|
|
|
|
2016-10-03 11:49:39 -05:00
|
|
|
#![feature(box_patterns)]
|
2017-11-23 10:07:18 -06:00
|
|
|
#![feature(libc)]
|
2018-06-16 09:09:42 -05:00
|
|
|
#![feature(macro_at_most_once_rep)]
|
2018-08-09 00:49:07 -05:00
|
|
|
#![cfg_attr(not(stage0), feature(nll))]
|
2016-10-03 11:49:39 -05:00
|
|
|
#![feature(proc_macro_internals)]
|
2018-04-21 19:05:02 -05:00
|
|
|
#![feature(proc_macro_quote)]
|
2015-11-24 16:00:26 -06:00
|
|
|
#![feature(quote)]
|
|
|
|
#![feature(rustc_diagnostic_macros)]
|
2018-03-30 04:40:25 -05:00
|
|
|
#![feature(slice_sort_by_cached_key)]
|
2016-09-19 15:46:31 -05:00
|
|
|
#![feature(specialization)]
|
2017-05-08 16:36:44 -05:00
|
|
|
#![feature(rustc_private)]
|
2015-11-24 16:00:26 -06:00
|
|
|
|
2018-03-02 23:22:19 -06:00
|
|
|
#![recursion_limit="256"]
|
|
|
|
|
2017-11-23 10:07:18 -06:00
|
|
|
extern crate libc;
|
2016-10-22 08:14:32 -05:00
|
|
|
#[macro_use]
|
|
|
|
extern crate log;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate syntax;
|
2016-06-21 17:08:13 -05:00
|
|
|
extern crate syntax_pos;
|
2017-06-08 16:10:36 -05:00
|
|
|
extern crate flate2;
|
2016-04-11 11:35:26 -05:00
|
|
|
extern crate serialize as rustc_serialize; // used by deriving
|
2016-06-21 17:08:13 -05:00
|
|
|
extern crate rustc_errors as errors;
|
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
|
|
|
extern crate syntax_ext;
|
2016-10-03 11:49:39 -05:00
|
|
|
extern crate proc_macro;
|
2018-07-31 13:07:37 -05:00
|
|
|
extern crate rustc_metadata_utils;
|
2015-11-24 16:00:26 -06:00
|
|
|
|
2016-03-28 16:00:01 -05:00
|
|
|
#[macro_use]
|
2015-11-24 16:00:26 -06:00
|
|
|
extern crate rustc;
|
2017-12-08 13:18:21 -06:00
|
|
|
extern crate rustc_target;
|
2018-03-02 23:17:06 -06:00
|
|
|
#[macro_use]
|
2016-10-03 11:49:39 -05:00
|
|
|
extern crate rustc_data_structures;
|
2015-11-24 16:00:26 -06:00
|
|
|
|
2016-09-08 11:05:50 -05:00
|
|
|
mod diagnostics;
|
2015-11-24 16:00:26 -06:00
|
|
|
|
2016-08-10 13:27:06 -05:00
|
|
|
mod index_builder;
|
2016-09-08 11:05:50 -05:00
|
|
|
mod index;
|
|
|
|
mod encoder;
|
|
|
|
mod decoder;
|
2016-10-19 04:56:39 -05:00
|
|
|
mod cstore_impl;
|
2017-04-27 09:12:57 -05:00
|
|
|
mod isolated_encoder;
|
2016-09-16 09:25:54 -05:00
|
|
|
mod schema;
|
2017-08-30 16:48:57 -05:00
|
|
|
mod native_libs;
|
|
|
|
mod link_args;
|
2018-02-10 16:28:17 -06:00
|
|
|
mod foreign_modules;
|
2016-09-08 11:05:50 -05:00
|
|
|
|
2015-11-24 16:00:26 -06:00
|
|
|
pub mod creader;
|
|
|
|
pub mod cstore;
|
2017-11-23 10:07:18 -06:00
|
|
|
pub mod dynamic_lib;
|
2016-10-19 23:31:14 -05:00
|
|
|
pub mod locator;
|
2016-08-29 09:27:04 -05:00
|
|
|
|
|
|
|
__build_diagnostic_array! { librustc_metadata, DIAGNOSTICS }
|