Skip to content

Commit 01d7e7a

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 7811ae8 + 0a24e28 commit 01d7e7a

32 files changed

+395
-546
lines changed

Cargo.lock

-14
Original file line numberDiff line numberDiff line change
@@ -2863,31 +2863,20 @@ dependencies = [
28632863
name = "rustc_driver"
28642864
version = "0.0.0"
28652865
dependencies = [
2866-
"arena 0.0.0",
28672866
"env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)",
28682867
"graphviz 0.0.0",
28692868
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
28702869
"rustc 0.0.0",
2871-
"rustc-rayon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
28722870
"rustc_ast_borrowck 0.0.0",
28732871
"rustc_codegen_utils 0.0.0",
28742872
"rustc_data_structures 0.0.0",
28752873
"rustc_errors 0.0.0",
2876-
"rustc_incremental 0.0.0",
28772874
"rustc_interface 0.0.0",
2878-
"rustc_lint 0.0.0",
28792875
"rustc_metadata 0.0.0",
28802876
"rustc_mir 0.0.0",
2881-
"rustc_passes 0.0.0",
2882-
"rustc_plugin 0.0.0",
2883-
"rustc_privacy 0.0.0",
2884-
"rustc_resolve 0.0.0",
28852877
"rustc_save_analysis 0.0.0",
28862878
"rustc_target 0.0.0",
2887-
"rustc_traits 0.0.0",
2888-
"rustc_typeck 0.0.0",
28892879
"serialize 0.0.0",
2890-
"smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
28912880
"syntax 0.0.0",
28922881
"syntax_pos 0.0.0",
28932882
]
@@ -3019,7 +3008,6 @@ dependencies = [
30193008
"smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
30203009
"stable_deref_trait 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
30213010
"syntax 0.0.0",
3022-
"syntax_ext 0.0.0",
30233011
"syntax_pos 0.0.0",
30243012
]
30253013

@@ -3064,9 +3052,7 @@ dependencies = [
30643052
"rustc 0.0.0",
30653053
"rustc_data_structures 0.0.0",
30663054
"rustc_errors 0.0.0",
3067-
"rustc_mir 0.0.0",
30683055
"syntax 0.0.0",
3069-
"syntax_ext 0.0.0",
30703056
"syntax_pos 0.0.0",
30713057
]
30723058

src/librustc/hir/lowering.rs

+1-2
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_driver/Cargo.toml

-11
Original file line numberDiff line numberDiff line change
@@ -10,30 +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" }
1917
rustc_target = { path = "../librustc_target" }
2018
rustc_ast_borrowck = { path = "../librustc_ast_borrowck" }
2119
rustc_data_structures = { path = "../librustc_data_structures" }
2220
errors = { path = "../librustc_errors", package = "rustc_errors" }
23-
rustc_incremental = { path = "../librustc_incremental" }
24-
rustc_lint = { path = "../librustc_lint" }
2521
rustc_metadata = { path = "../librustc_metadata" }
2622
rustc_mir = { path = "../librustc_mir" }
27-
rustc_passes = { path = "../librustc_passes" }
28-
rustc_plugin = { path = "../librustc_plugin" }
29-
rustc_privacy = { path = "../librustc_privacy" }
30-
rustc_resolve = { path = "../librustc_resolve" }
3123
rustc_save_analysis = { path = "../librustc_save_analysis" }
32-
rustc_traits = { path = "../librustc_traits" }
3324
rustc_codegen_utils = { path = "../librustc_codegen_utils" }
34-
rustc_typeck = { path = "../librustc_typeck" }
3525
rustc_interface = { path = "../librustc_interface" }
3626
rustc_serialize = { path = "../libserialize", package = "serialize" }
3727
syntax = { path = "../libsyntax" }
38-
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
3928
syntax_pos = { path = "../libsyntax_pos" }

src/librustc_interface/passes.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,12 @@ pub fn register_plugins<'a>(
278278

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

284289
let registrars = time(sess, "plugin loading", || {
@@ -453,7 +458,7 @@ fn configure_and_expand_inner<'a>(
453458
sess.profiler(|p| p.end_activity("macro expansion"));
454459

455460
time(sess, "maybe building test harness", || {
456-
syntax::test::modify_for_testing(
461+
syntax_ext::test_harness::inject(
457462
&sess.parse_sess,
458463
&mut resolver,
459464
sess.opts.test,
@@ -482,7 +487,7 @@ fn configure_and_expand_inner<'a>(
482487
let num_crate_types = crate_types.len();
483488
let is_proc_macro_crate = crate_types.contains(&config::CrateType::ProcMacro);
484489
let is_test_crate = sess.opts.test;
485-
syntax_ext::proc_macro_decls::modify(
490+
syntax_ext::proc_macro_harness::inject(
486491
&sess.parse_sess,
487492
&mut resolver,
488493
krate,

src/librustc_metadata/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,4 @@ rustc_target = { path = "../librustc_target" }
2121
rustc_serialize = { path = "../libserialize", package = "serialize" }
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

+1-2
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,7 @@ impl<'a> CrateLoader<'a> {
586586
use std::{env, mem};
587587
use crate::dynamic_lib::DynamicLibrary;
588588
use proc_macro::bridge::client::ProcMacro;
589-
use syntax_ext::deriving::custom::ProcMacroDerive;
590-
use syntax_ext::proc_macro_impl::{AttrProcMacro, BangProcMacro};
589+
use syntax::ext::proc_macro::{BangProcMacro, AttrProcMacro, ProcMacroDerive};
591590

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

src/librustc_metadata/cstore_impl.rs

+1-1
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

-2
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

+1-1
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

src/librustc_resolve/build_reduced_graph.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ use syntax::ext::tt::macro_rules;
3535
use syntax::feature_gate::is_builtin_attr;
3636
use syntax::parse::token::{self, Token};
3737
use syntax::span_err;
38-
use syntax::std_inject::injected_crate_name;
3938
use syntax::symbol::{kw, sym};
4039
use syntax::visit::{self, Visitor};
4140

@@ -368,8 +367,10 @@ impl<'a> Resolver<'a> {
368367
};
369368

370369
self.populate_module_if_necessary(module);
371-
if injected_crate_name().map_or(false, |name| ident.name.as_str() == name) {
372-
self.injected_crate = Some(module);
370+
if let Some(name) = self.session.parse_sess.injected_crate_name.try_get() {
371+
if name.as_str() == ident.name.as_str() {
372+
self.injected_crate = Some(module);
373+
}
373374
}
374375

375376
let used = self.process_legacy_macro_imports(item, module, &parent_scope);

src/libsyntax/ext/base.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::ast::{self, Attribute, Name, PatKind};
22
use crate::attr::{HasAttrs, Stability, Deprecation};
3-
use crate::source_map::{SourceMap, Spanned, FileName, respan};
3+
use crate::source_map::{SourceMap, Spanned, respan};
44
use crate::edition::Edition;
55
use crate::ext::expand::{self, AstFragment, Invocation};
66
use crate::ext::hygiene::{ExpnId, SyntaxContext, Transparency};
@@ -14,7 +14,7 @@ use crate::tokenstream::{self, TokenStream, TokenTree};
1414

1515
use errors::{DiagnosticBuilder, DiagnosticId};
1616
use smallvec::{smallvec, SmallVec};
17-
use syntax_pos::{Span, MultiSpan, DUMMY_SP};
17+
use syntax_pos::{FileName, Span, MultiSpan, DUMMY_SP};
1818
use syntax_pos::hygiene::{ExpnInfo, ExpnKind};
1919

2020
use rustc_data_structures::fx::FxHashMap;

src/libsyntax/ext/derive.rs

-72
This file was deleted.

src/libsyntax/ext/expand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::attr::{self, HasAttrs};
44
use crate::source_map::{dummy_spanned, respan};
55
use crate::config::StripUnconfigured;
66
use crate::ext::base::*;
7-
use crate::ext::derive::{add_derived_markers, collect_derives};
7+
use crate::ext::proc_macro::{add_derived_markers, collect_derives};
88
use crate::ext::hygiene::{ExpnId, SyntaxContext, ExpnInfo, ExpnKind};
99
use crate::ext::placeholders::{placeholder, PlaceholderExpander};
1010
use crate::feature_gate::{self, Features, GateIssue, is_builtin_attr, emit_feature_err};

0 commit comments

Comments
 (0)