Skip to content

Commit 6ef02ef

Browse files
committed
Auto merge of #30043 - arielb1:split-metadata, r=nikomatsakis
This improves bootstrap times because of better parallelism - though I need to measure how much - and allows metadata to be modified without triggering a full recompile. This also ensures that metadata handling and the rest of rustc remain decoupled, which is a first step for switching to a new metadata format. This is a [breaking-change] to all plugin authors because of the following renames: * `rustc::plugin` is now `rustc_plugin` * `rustc::metadata` is now `rustc_metadata` * Most data types from `rustc::metadata`, along with `LOCAL_CRATE`, are now in `rustc::middle::cstore`. * The CStore methods were split between the `rustc::middle::CrateStore` trait (and trait object) and the `rustc_metadata::cstore::CStore`, with an `Rc<CrateStore>` stored in the `Session`. The inner `CStore` can be accessed via the inner `Any` bound, but this is deprecated. r? @nikomatsakis
2 parents 6f3becb + 43a6deb commit 6ef02ef

File tree

105 files changed

+1760
-1244
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+1760
-1244
lines changed

mk/crates.mk

+7-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ TARGET_CRATES := libc std flate arena term \
5656
alloc_system
5757
RUSTC_CRATES := rustc rustc_typeck rustc_mir rustc_borrowck rustc_resolve rustc_driver \
5858
rustc_trans rustc_back rustc_llvm rustc_privacy rustc_lint \
59-
rustc_data_structures rustc_front rustc_platform_intrinsics
59+
rustc_data_structures rustc_front rustc_platform_intrinsics \
60+
rustc_plugin rustc_metadata
6061
HOST_CRATES := syntax $(RUSTC_CRATES) rustdoc fmt_macros
6162
TOOLS := compiletest rustdoc rustc rustbook error-index-generator
6263

@@ -87,21 +88,23 @@ DEPS_test := std getopts serialize rbml term native:rust_test_helpers
8788

8889
DEPS_syntax := std term serialize log fmt_macros arena libc rustc_bitflags
8990

90-
DEPS_rustc := syntax flate arena serialize getopts rbml rustc_front\
91+
DEPS_rustc := syntax flate arena serialize getopts rustc_front\
9192
log graphviz rustc_llvm rustc_back rustc_data_structures
9293
DEPS_rustc_back := std syntax rustc_llvm rustc_front flate log libc
9394
DEPS_rustc_borrowck := rustc rustc_front log graphviz syntax
9495
DEPS_rustc_data_structures := std log serialize
9596
DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \
9697
rustc_typeck rustc_mir rustc_resolve log syntax serialize rustc_llvm \
97-
rustc_trans rustc_privacy rustc_lint rustc_front
98-
98+
rustc_trans rustc_privacy rustc_lint rustc_front rustc_plugin \
99+
rustc_metadata
99100
DEPS_rustc_front := std syntax log serialize
100101
DEPS_rustc_lint := rustc log syntax
101102
DEPS_rustc_llvm := native:rustllvm libc std rustc_bitflags
103+
DEPS_rustc_metadata := rustc rustc_front syntax rbml
102104
DEPS_rustc_mir := rustc rustc_front syntax
103105
DEPS_rustc_resolve := rustc rustc_front log syntax
104106
DEPS_rustc_platform_intrinsics := rustc rustc_llvm
107+
DEPS_rustc_plugin := rustc rustc_metadata syntax
105108
DEPS_rustc_privacy := rustc rustc_front log syntax
106109
DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back rustc_mir \
107110
log syntax serialize rustc_llvm rustc_front rustc_platform_intrinsics

src/doc/book/compiler-plugins.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ extend the compiler's behavior with new syntax extensions, lint checks, etc.
88
A plugin is a dynamic library crate with a designated *registrar* function that
99
registers extensions with `rustc`. Other crates can load these extensions using
1010
the crate attribute `#![plugin(...)]`. See the
11-
[`rustc::plugin`](../rustc/plugin/index.html) documentation for more about the
11+
[`rustc_plugin`](../rustc_plugin/index.html) documentation for more about the
1212
mechanics of defining and loading a plugin.
1313

1414
If present, arguments passed as `#![plugin(foo(... args ...))]` are not
1515
interpreted by rustc itself. They are provided to the plugin through the
16-
`Registry`'s [`args` method](../rustc/plugin/registry/struct.Registry.html#method.args).
16+
`Registry`'s [`args` method](../rustc_plugin/registry/struct.Registry.html#method.args).
1717

1818
In the vast majority of cases, a plugin should *only* be used through
1919
`#![plugin]` and not through an `extern crate` item. Linking a plugin would
@@ -43,13 +43,14 @@ that implements Roman numeral integer literals.
4343
4444
extern crate syntax;
4545
extern crate rustc;
46+
extern crate rustc_plugin;
4647
4748
use syntax::codemap::Span;
4849
use syntax::parse::token;
4950
use syntax::ast::TokenTree;
5051
use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager};
5152
use syntax::ext::build::AstBuilder; // trait for expr_usize
52-
use rustc::plugin::Registry;
53+
use rustc_plugin::Registry;
5354
5455
fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
5556
-> Box<MacResult + 'static> {
@@ -120,7 +121,7 @@ The advantages over a simple `fn(&str) -> u32` are:
120121
In addition to procedural macros, you can define new
121122
[`derive`](../reference.html#derive)-like attributes and other kinds of
122123
extensions. See
123-
[`Registry::register_syntax_extension`](../rustc/plugin/registry/struct.Registry.html#method.register_syntax_extension)
124+
[`Registry::register_syntax_extension`](../rustc_plugin/registry/struct.Registry.html#method.register_syntax_extension)
124125
and the [`SyntaxExtension`
125126
enum](https://doc.rust-lang.org/syntax/ext/base/enum.SyntaxExtension.html). For
126127
a more involved macro example, see
@@ -189,10 +190,11 @@ extern crate syntax;
189190
// Load rustc as a plugin to get macros
190191
#[macro_use]
191192
extern crate rustc;
193+
extern crate rustc_plugin;
192194
193195
use rustc::lint::{EarlyContext, LintContext, LintPass, EarlyLintPass,
194196
EarlyLintPassObject, LintArray};
195-
use rustc::plugin::Registry;
197+
use rustc_plugin::Registry;
196198
use syntax::ast;
197199
198200
declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");

src/doc/complement-lang-faq.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ can be combined to control the exact logging you want to see. For example, when
158158
debugging linking in the compiler, you might set the following:
159159

160160
```sh
161-
RUST_LOG=rustc::metadata::creader,rustc::util::filesearch,rustc::back::rpath
161+
RUST_LOG=rustc_metadata::creader,rustc::util::filesearch,rustc::back::rpath
162162
```
163163

164164
For a full description, see [the logging crate][1].

src/grammar/verify.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ use std::path::Path;
2525
use syntax::parse;
2626
use syntax::parse::lexer;
2727
use rustc::session::{self, config};
28+
use rustc::middle::cstore::DummyCrateStore;
2829

30+
use std::rc::Rc;
2931
use syntax::ast;
3032
use syntax::ast::Name;
3133
use syntax::codemap;
@@ -286,7 +288,8 @@ fn main() {
286288

287289
let options = config::basic_options();
288290
let session = session::build_session(options, None,
289-
syntax::diagnostics::registry::Registry::new(&[]));
291+
syntax::diagnostics::registry::Registry::new(&[]),
292+
Rc::new(DummyCrateStore));
290293
let filemap = session.parse_sess.codemap().new_filemap(String::from("<n/a>"), code);
291294
let mut lexer = lexer::StringReader::new(session.diagnostic(), filemap);
292295
let cm = session.codemap();

src/librustc/diagnostics.rs

-61
Original file line numberDiff line numberDiff line change
@@ -1899,51 +1899,6 @@ contain references (with a maximum lifetime of `'a`).
18991899
[1]: https://github.com/rust-lang/rfcs/pull/1156
19001900
"##,
19011901

1902-
E0454: r##"
1903-
A link name was given with an empty name. Erroneous code example:
1904-
1905-
```
1906-
#[link(name = "")] extern {} // error: #[link(name = "")] given with empty name
1907-
```
1908-
1909-
The rust compiler cannot link to an external library if you don't give it its
1910-
name. Example:
1911-
1912-
```
1913-
#[link(name = "some_lib")] extern {} // ok!
1914-
```
1915-
"##,
1916-
1917-
E0458: r##"
1918-
An unknown "kind" was specified for a link attribute. Erroneous code example:
1919-
1920-
```
1921-
#[link(kind = "wonderful_unicorn")] extern {}
1922-
// error: unknown kind: `wonderful_unicorn`
1923-
```
1924-
1925-
Please specify a valid "kind" value, from one of the following:
1926-
* static
1927-
* dylib
1928-
* framework
1929-
"##,
1930-
1931-
E0459: r##"
1932-
A link was used without a name parameter. Erroneous code example:
1933-
1934-
```
1935-
#[link(kind = "dylib")] extern {}
1936-
// error: #[link(...)] specified without `name = "foo"`
1937-
```
1938-
1939-
Please add the name parameter to allow the rust compiler to find the library
1940-
you want. Example:
1941-
1942-
```
1943-
#[link(kind = "dylib", name = "some_lib")] extern {} // ok!
1944-
```
1945-
"##,
1946-
19471902
E0493: r##"
19481903
A type with a destructor was assigned to an invalid type of variable. Erroneous
19491904
code example:
@@ -2144,20 +2099,6 @@ register_diagnostics! {
21442099
E0400, // overloaded derefs are not allowed in constants
21452100
E0452, // malformed lint attribute
21462101
E0453, // overruled by outer forbid
2147-
E0455, // native frameworks are only available on OSX targets
2148-
E0456, // plugin `..` is not available for triple `..`
2149-
E0457, // plugin `..` only found in rlib format, but must be available...
2150-
E0460, // found possibly newer version of crate `..`
2151-
E0461, // couldn't find crate `..` with expected target triple ..
2152-
E0462, // found staticlib `..` instead of rlib or dylib
2153-
E0463, // can't find crate for `..`
2154-
E0464, // multiple matching crates for `..`
2155-
E0465, // multiple .. candidates for `..` found
2156-
E0466, // bad macro import
2157-
E0467, // bad macro reexport
2158-
E0468, // an `extern crate` loading macros must be at the crate root
2159-
E0469, // imported macro not found
2160-
E0470, // reexported macro not found
21612102
E0471, // constant evaluation error: ..
21622103
E0472, // asm! is unsupported on this target
21632104
E0473, // dereference of reference outside its lifetime
@@ -2181,6 +2122,4 @@ register_diagnostics! {
21812122
E0491, // in type `..`, reference has a longer lifetime than the data it...
21822123
E0492, // cannot borrow a constant which contains interior mutability
21832124
E0495, // cannot infer an appropriate lifetime due to conflicting requirements
2184-
E0498, // malformed plugin attribute
2185-
E0514, // metadata version mismatch
21862125
}

src/librustc/front/map/definitions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use metadata::cstore::LOCAL_CRATE;
11+
use middle::cstore::LOCAL_CRATE;
1212
use middle::def_id::{DefId, DefIndex};
1313
use rustc_data_structures::fnv::FnvHashMap;
1414
use rustc_front::hir;

src/librustc/front/map/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use self::MapEntry::*;
1414
use self::collector::NodeCollector;
1515
pub use self::definitions::{Definitions, DefKey, DefPath, DefPathData, DisambiguatedDefPathData};
1616

17-
use metadata::inline::InlinedItem;
18-
use metadata::inline::InlinedItem as II;
17+
use middle::cstore::InlinedItem;
18+
use middle::cstore::InlinedItem as II;
1919
use middle::def_id::DefId;
2020

2121
use syntax::abi;

src/librustc/lib.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#![feature(const_fn)]
3434
#![feature(core)]
3535
#![feature(duration_span)]
36-
#![feature(dynamic_lib)]
3736
#![feature(enumset)]
3837
#![feature(hashmap_hasher)]
3938
#![feature(into_cow)]
@@ -68,7 +67,6 @@ extern crate rustc_back;
6867
extern crate rustc_front;
6968
extern crate rustc_data_structures;
7069
extern crate serialize;
71-
extern crate rbml;
7270
extern crate collections;
7371
#[macro_use] extern crate log;
7472
#[macro_use] extern crate syntax;
@@ -100,9 +98,8 @@ pub mod front {
10098
}
10199

102100
pub mod middle {
103-
pub mod expr_use_visitor; // STAGE0: increase glitch immunity
104101
pub mod astconv_util;
105-
pub mod astencode;
102+
pub mod expr_use_visitor; // STAGE0: increase glitch immunity
106103
pub mod cfg;
107104
pub mod check_const;
108105
pub mod check_static_recursion;
@@ -111,6 +108,7 @@ pub mod middle {
111108
pub mod check_no_asm;
112109
pub mod check_rvalues;
113110
pub mod const_eval;
111+
pub mod cstore;
114112
pub mod dataflow;
115113
pub mod dead;
116114
pub mod def;
@@ -138,12 +136,8 @@ pub mod middle {
138136
pub mod weak_lang_items;
139137
}
140138

141-
pub mod metadata;
142-
143139
pub mod session;
144140

145-
pub mod plugin;
146-
147141
pub mod lint;
148142

149143
pub mod util {

0 commit comments

Comments
 (0)