Skip to content

Commit 8fad976

Browse files
authored
Rollup merge of rust-lang#62771 - petrochenkov:depext, r=eddyb
Break dependencies between `syntax_ext` and other crates Move `source_util` macros into `syntax_ext`. Move other early code generation facilities like standard library injection into `syntax_ext`. The only crate that depends on `syntax_ext` now is `rustc_interface` which is one of the "final" crates that depend on everything. Minor: Cleanup dependencies of `rustc_driver`, many of them are no longer used after introduction of `rustc_interface`. r? @eddyb
2 parents 966ba8d + ec5f089 commit 8fad976

Some content is hidden

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

44 files changed

+457
-664
lines changed

Cargo.lock

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2751,20 +2751,6 @@ dependencies = [
27512751
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
27522752
]
27532753

2754-
[[package]]
2755-
name = "rustc_allocator"
2756-
version = "0.0.0"
2757-
dependencies = [
2758-
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
2759-
"rustc 0.0.0",
2760-
"rustc_data_structures 0.0.0",
2761-
"rustc_errors 0.0.0",
2762-
"rustc_target 0.0.0",
2763-
"smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
2764-
"syntax 0.0.0",
2765-
"syntax_pos 0.0.0",
2766-
]
2767-
27682754
[[package]]
27692755
name = "rustc_apfloat"
27702756
version = "0.0.0"
@@ -2822,7 +2808,6 @@ dependencies = [
28222808
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
28232809
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
28242810
"rustc 0.0.0",
2825-
"rustc_allocator 0.0.0",
28262811
"rustc_apfloat 0.0.0",
28272812
"rustc_codegen_utils 0.0.0",
28282813
"rustc_data_structures 0.0.0",
@@ -2877,34 +2862,21 @@ dependencies = [
28772862
name = "rustc_driver"
28782863
version = "0.0.0"
28792864
dependencies = [
2880-
"arena 0.0.0",
28812865
"env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)",
28822866
"graphviz 0.0.0",
28832867
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
28842868
"rustc 0.0.0",
2885-
"rustc-rayon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
2886-
"rustc_allocator 0.0.0",
28872869
"rustc_ast_borrowck 0.0.0",
28882870
"rustc_codegen_utils 0.0.0",
28892871
"rustc_data_structures 0.0.0",
28902872
"rustc_errors 0.0.0",
2891-
"rustc_incremental 0.0.0",
28922873
"rustc_interface 0.0.0",
2893-
"rustc_lint 0.0.0",
28942874
"rustc_metadata 0.0.0",
28952875
"rustc_mir 0.0.0",
2896-
"rustc_passes 0.0.0",
2897-
"rustc_plugin 0.0.0",
2898-
"rustc_privacy 0.0.0",
2899-
"rustc_resolve 0.0.0",
29002876
"rustc_save_analysis 0.0.0",
29012877
"rustc_target 0.0.0",
2902-
"rustc_traits 0.0.0",
2903-
"rustc_typeck 0.0.0",
29042878
"serialize 0.0.0",
2905-
"smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
29062879
"syntax 0.0.0",
2907-
"syntax_ext 0.0.0",
29082880
"syntax_pos 0.0.0",
29092881
]
29102882

@@ -2948,7 +2920,6 @@ dependencies = [
29482920
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
29492921
"rustc 0.0.0",
29502922
"rustc-rayon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
2951-
"rustc_allocator 0.0.0",
29522923
"rustc_ast_borrowck 0.0.0",
29532924
"rustc_codegen_ssa 0.0.0",
29542925
"rustc_codegen_utils 0.0.0",
@@ -3036,7 +3007,6 @@ dependencies = [
30363007
"smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
30373008
"stable_deref_trait 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
30383009
"syntax 0.0.0",
3039-
"syntax_ext 0.0.0",
30403010
"syntax_pos 0.0.0",
30413011
]
30423012

@@ -3081,9 +3051,7 @@ dependencies = [
30813051
"rustc 0.0.0",
30823052
"rustc_data_structures 0.0.0",
30833053
"rustc_errors 0.0.0",
3084-
"rustc_mir 0.0.0",
30853054
"syntax 0.0.0",
3086-
"syntax_ext 0.0.0",
30873055
"syntax_pos 0.0.0",
30883056
]
30893057

src/librustc/hir/lowering.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ use syntax::errors;
6363
use syntax::ext::hygiene::ExpnId;
6464
use syntax::print::pprust;
6565
use syntax::source_map::{respan, ExpnInfo, ExpnKind, DesugaringKind, Spanned};
66-
use syntax::std_inject;
6766
use syntax::symbol::{kw, sym, Symbol};
6867
use syntax::tokenstream::{TokenStream, TokenTree};
6968
use syntax::parse::token::{self, Token};
@@ -241,7 +240,7 @@ pub fn lower_crate(
241240
dep_graph.assert_ignored();
242241

243242
LoweringContext {
244-
crate_root: std_inject::injected_crate_name().map(Symbol::intern),
243+
crate_root: sess.parse_sess.injected_crate_name.try_get().copied(),
245244
sess,
246245
cstore,
247246
resolver,

src/librustc/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ pub mod infer;
112112
pub mod lint;
113113

114114
pub mod middle {
115-
pub mod allocator;
116115
pub mod borrowck;
117116
pub mod expr_use_visitor;
118117
pub mod cstore;

src/librustc/middle/allocator.rs

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/librustc/session/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use rustc_data_structures::fingerprint::Fingerprint;
77

88
use crate::lint;
99
use crate::lint::builtin::BuiltinLintDiagnostics;
10-
use crate::middle::allocator::AllocatorKind;
1110
use crate::middle::dependency_format;
1211
use crate::session::config::{OutputType, PrintRequest, SwitchWithOptPath};
1312
use crate::session::search_paths::{PathKind, SearchPath};
@@ -27,6 +26,7 @@ use errors::emitter::HumanReadableErrorType;
2726
use errors::annotate_snippet_emitter_writer::{AnnotateSnippetEmitterWriter};
2827
use syntax::ast::{self, NodeId};
2928
use syntax::edition::Edition;
29+
use syntax::ext::allocator::AllocatorKind;
3030
use syntax::feature_gate::{self, AttributeType};
3131
use syntax::json::JsonEmitter;
3232
use syntax::source_map;

src/librustc_allocator/Cargo.toml

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/librustc_codegen_llvm/allocator.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ use std::ffi::CString;
22

33
use crate::attributes;
44
use libc::c_uint;
5-
use rustc::middle::allocator::AllocatorKind;
65
use rustc::ty::TyCtxt;
7-
use rustc_allocator::{ALLOCATOR_METHODS, AllocatorTy};
6+
use syntax::ext::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS};
87

98
use crate::ModuleLlvm;
109
use crate::llvm::{self, False, True};

src/librustc_codegen_llvm/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ extern crate flate2;
3232
#[macro_use] extern crate bitflags;
3333
extern crate libc;
3434
#[macro_use] extern crate rustc;
35-
extern crate rustc_allocator;
3635
extern crate rustc_target;
3736
#[macro_use] extern crate rustc_data_structures;
3837
extern crate rustc_incremental;
@@ -52,13 +51,13 @@ use rustc_codegen_ssa::back::lto::{SerializedModule, LtoModuleCodegen, ThinModul
5251
use rustc_codegen_ssa::CompiledModule;
5352
use errors::{FatalError, Handler};
5453
use rustc::dep_graph::WorkProduct;
54+
use syntax::ext::allocator::AllocatorKind;
5555
use syntax_pos::symbol::InternedString;
5656
pub use llvm_util::target_features;
5757
use std::any::Any;
5858
use std::sync::{mpsc, Arc};
5959

6060
use rustc::dep_graph::DepGraph;
61-
use rustc::middle::allocator::AllocatorKind;
6261
use rustc::middle::cstore::{EncodedMetadata, MetadataLoader};
6362
use rustc::session::Session;
6463
use rustc::session::config::{OutputFilenames, OutputType, PrintRequest, OptLevel};

src/librustc_codegen_ssa/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ serialize = { path = "../libserialize" }
2424
syntax = { path = "../libsyntax" }
2525
syntax_pos = { path = "../libsyntax_pos" }
2626
rustc = { path = "../librustc" }
27-
rustc_allocator = { path = "../librustc_allocator" }
2827
rustc_apfloat = { path = "../librustc_apfloat" }
2928
rustc_codegen_utils = { path = "../librustc_codegen_utils" }
3029
rustc_data_structures = { path = "../librustc_data_structures"}

src/librustc_codegen_ssa/back/symbol_export.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::collections::hash_map::Entry::*;
12
use std::sync::Arc;
23

34
use rustc::ty::Instance;
@@ -12,9 +13,8 @@ use rustc::ty::{TyCtxt, SymbolName};
1213
use rustc::ty::query::Providers;
1314
use rustc::ty::subst::SubstsRef;
1415
use rustc::util::nodemap::{FxHashMap, DefIdMap};
15-
use rustc_allocator::ALLOCATOR_METHODS;
1616
use rustc_data_structures::indexed_vec::IndexVec;
17-
use std::collections::hash_map::Entry::*;
17+
use syntax::ext::allocator::ALLOCATOR_METHODS;
1818

1919
pub type ExportedSymbols = FxHashMap<
2020
CrateNum,

src/librustc_codegen_ssa/traits/backend.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ use rustc::ty::Ty;
33

44
use super::write::WriteBackendMethods;
55
use super::CodegenObject;
6-
use rustc::middle::allocator::AllocatorKind;
76
use rustc::middle::cstore::EncodedMetadata;
87
use rustc::session::{Session, config};
98
use rustc::ty::TyCtxt;
109
use rustc_codegen_utils::codegen_backend::CodegenBackend;
1110
use std::sync::Arc;
11+
use syntax::ext::allocator::AllocatorKind;
1212
use syntax_pos::symbol::InternedString;
1313

1414
pub trait BackendTypes {

src/librustc_driver/Cargo.toml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,19 @@ path = "lib.rs"
1010
crate-type = ["dylib"]
1111

1212
[dependencies]
13-
arena = { path = "../libarena" }
1413
graphviz = { path = "../libgraphviz" }
1514
log = "0.4"
1615
env_logger = { version = "0.5", default-features = false }
17-
rayon = { version = "0.2.0", package = "rustc-rayon" }
1816
rustc = { path = "../librustc" }
19-
rustc_allocator = { path = "../librustc_allocator" }
2017
rustc_target = { path = "../librustc_target" }
2118
rustc_ast_borrowck = { path = "../librustc_ast_borrowck" }
2219
rustc_data_structures = { path = "../librustc_data_structures" }
2320
errors = { path = "../librustc_errors", package = "rustc_errors" }
24-
rustc_incremental = { path = "../librustc_incremental" }
25-
rustc_lint = { path = "../librustc_lint" }
2621
rustc_metadata = { path = "../librustc_metadata" }
2722
rustc_mir = { path = "../librustc_mir" }
28-
rustc_passes = { path = "../librustc_passes" }
29-
rustc_plugin = { path = "../librustc_plugin" }
30-
rustc_privacy = { path = "../librustc_privacy" }
31-
rustc_resolve = { path = "../librustc_resolve" }
3223
rustc_save_analysis = { path = "../librustc_save_analysis" }
33-
rustc_traits = { path = "../librustc_traits" }
3424
rustc_codegen_utils = { path = "../librustc_codegen_utils" }
35-
rustc_typeck = { path = "../librustc_typeck" }
3625
rustc_interface = { path = "../librustc_interface" }
3726
serialize = { path = "../libserialize" }
3827
syntax = { path = "../libsyntax" }
39-
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
40-
syntax_ext = { path = "../libsyntax_ext" }
4128
syntax_pos = { path = "../libsyntax_pos" }

src/librustc_interface/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ syntax_ext = { path = "../libsyntax_ext" }
1818
syntax_pos = { path = "../libsyntax_pos" }
1919
serialize = { path = "../libserialize" }
2020
rustc = { path = "../librustc" }
21-
rustc_allocator = { path = "../librustc_allocator" }
2221
rustc_ast_borrowck = { path = "../librustc_ast_borrowck" }
2322
rustc_incremental = { path = "../librustc_incremental" }
2423
rustc_traits = { path = "../librustc_traits" }

src/librustc_interface/passes.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,12 @@ pub fn register_plugins<'a>(
277277

278278
krate = time(sess, "crate injection", || {
279279
let alt_std_name = sess.opts.alt_std_name.as_ref().map(|s| &**s);
280-
syntax::std_inject::maybe_inject_crates_ref(krate, alt_std_name, sess.edition())
280+
let (krate, name) =
281+
syntax_ext::standard_library_imports::inject(krate, alt_std_name, sess.edition());
282+
if let Some(name) = name {
283+
sess.parse_sess.injected_crate_name.set(name);
284+
}
285+
krate
281286
});
282287

283288
let registrars = time(sess, "plugin loading", || {
@@ -452,7 +457,7 @@ fn configure_and_expand_inner<'a>(
452457
sess.profiler(|p| p.end_activity("macro expansion"));
453458

454459
time(sess, "maybe building test harness", || {
455-
syntax::test::modify_for_testing(
460+
syntax_ext::test_harness::inject(
456461
&sess.parse_sess,
457462
&mut resolver,
458463
sess.opts.test,
@@ -481,7 +486,7 @@ fn configure_and_expand_inner<'a>(
481486
let num_crate_types = crate_types.len();
482487
let is_proc_macro_crate = crate_types.contains(&config::CrateType::ProcMacro);
483488
let is_test_crate = sess.opts.test;
484-
syntax_ext::proc_macro_decls::modify(
489+
syntax_ext::proc_macro_harness::inject(
485490
&sess.parse_sess,
486491
&mut resolver,
487492
krate,
@@ -497,7 +502,7 @@ fn configure_and_expand_inner<'a>(
497502
if has_global_allocator {
498503
// Expand global allocators, which are treated as an in-tree proc macro
499504
time(sess, "creating allocators", || {
500-
allocator::expand::modify(
505+
syntax_ext::global_allocator::modify(
501506
&sess.parse_sess,
502507
&mut resolver,
503508
&mut krate,

src/librustc_metadata/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,4 @@ rustc_target = { path = "../librustc_target" }
2121
serialize = { path = "../libserialize" }
2222
stable_deref_trait = "1.0.0"
2323
syntax = { path = "../libsyntax" }
24-
syntax_ext = { path = "../libsyntax_ext" }
2524
syntax_pos = { path = "../libsyntax_pos" }

src/librustc_metadata/creader.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use rustc_data_structures::sync::{Lrc, RwLock, Lock};
88

99
use rustc::hir::def_id::CrateNum;
1010
use rustc_data_structures::svh::Svh;
11-
use rustc::middle::allocator::AllocatorKind;
1211
use rustc::middle::cstore::DepKind;
1312
use rustc::mir::interpret::AllocDecodingState;
1413
use rustc::session::{Session, CrateDisambiguator};
@@ -26,6 +25,7 @@ use std::{cmp, fs};
2625

2726
use syntax::ast;
2827
use syntax::attr;
28+
use syntax::ext::allocator::AllocatorKind;
2929
use syntax::ext::base::{SyntaxExtension, SyntaxExtensionKind};
3030
use syntax::symbol::{Symbol, sym};
3131
use syntax::visit;
@@ -587,8 +587,7 @@ impl<'a> CrateLoader<'a> {
587587
use std::{env, mem};
588588
use crate::dynamic_lib::DynamicLibrary;
589589
use proc_macro::bridge::client::ProcMacro;
590-
use syntax_ext::deriving::custom::ProcMacroDerive;
591-
use syntax_ext::proc_macro_impl::{AttrProcMacro, BangProcMacro};
590+
use syntax::ext::proc_macro::{BangProcMacro, AttrProcMacro, ProcMacroDerive};
592591

593592
let path = match dylib {
594593
Some(dylib) => dylib,

src/librustc_metadata/cstore_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ use syntax::attr;
3131
use syntax::source_map;
3232
use syntax::edition::Edition;
3333
use syntax::ext::base::{SyntaxExtension, SyntaxExtensionKind};
34+
use syntax::ext::proc_macro::BangProcMacro;
3435
use syntax::parse::source_file_to_stream;
3536
use syntax::parse::parser::emit_unclosed_delims;
3637
use syntax::symbol::{Symbol, sym};
37-
use syntax_ext::proc_macro_impl::BangProcMacro;
3838
use syntax_pos::{Span, NO_EXPANSION, FileName};
3939
use rustc_data_structures::bit_set::BitSet;
4040

src/librustc_passes/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ path = "lib.rs"
1111
[dependencies]
1212
log = "0.4"
1313
rustc = { path = "../librustc" }
14-
rustc_mir = { path = "../librustc_mir"}
1514
rustc_data_structures = { path = "../librustc_data_structures" }
1615
syntax = { path = "../libsyntax" }
17-
syntax_ext = { path = "../libsyntax_ext" }
1816
syntax_pos = { path = "../libsyntax_pos" }
1917
errors = { path = "../librustc_errors", package = "rustc_errors" }

src/librustc_passes/ast_validation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ use rustc::session::Session;
1414
use rustc_data_structures::fx::FxHashMap;
1515
use syntax::ast::*;
1616
use syntax::attr;
17+
use syntax::ext::proc_macro::is_proc_macro_attr;
1718
use syntax::feature_gate::is_builtin_attr;
1819
use syntax::source_map::Spanned;
1920
use syntax::symbol::{kw, sym};
2021
use syntax::visit::{self, Visitor};
2122
use syntax::{span_err, struct_span_err, walk_list};
22-
use syntax_ext::proc_macro_decls::is_proc_macro_attr;
2323
use syntax_pos::{Span, MultiSpan};
2424
use errors::{Applicability, FatalError};
2525

0 commit comments

Comments
 (0)