Skip to content

Commit ec5f089

Browse files
committed
syntax_ext: proc_macro_decls -> proc_macro_harness
Few other minor renamings for consistency. Remove one unused dependency from `rustc_passes`. Fix libsyntax tests. Fix rebase.
1 parent 188330b commit ec5f089

File tree

9 files changed

+18
-32
lines changed

9 files changed

+18
-32
lines changed

Cargo.lock

-17
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",
@@ -2935,7 +2920,6 @@ dependencies = [
29352920
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
29362921
"rustc 0.0.0",
29372922
"rustc-rayon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
2938-
"rustc_allocator 0.0.0",
29392923
"rustc_ast_borrowck 0.0.0",
29402924
"rustc_codegen_ssa 0.0.0",
29412925
"rustc_codegen_utils 0.0.0",
@@ -3060,7 +3044,6 @@ dependencies = [
30603044
"rustc 0.0.0",
30613045
"rustc_data_structures 0.0.0",
30623046
"rustc_errors 0.0.0",
3063-
"rustc_mir 0.0.0",
30643047
"syntax 0.0.0",
30653048
"syntax_pos 0.0.0",
30663049
]

src/librustc_interface/passes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ fn configure_and_expand_inner<'a>(
457457
sess.profiler(|p| p.end_activity("macro expansion"));
458458

459459
time(sess, "maybe building test harness", || {
460-
syntax_ext::test_harness::modify_for_testing(
460+
syntax_ext::test_harness::inject(
461461
&sess.parse_sess,
462462
&mut resolver,
463463
sess.opts.test,
@@ -486,7 +486,7 @@ fn configure_and_expand_inner<'a>(
486486
let num_crate_types = crate_types.len();
487487
let is_proc_macro_crate = crate_types.contains(&config::CrateType::ProcMacro);
488488
let is_test_crate = sess.opts.test;
489-
syntax_ext::proc_macro_decls::modify(
489+
syntax_ext::proc_macro_harness::inject(
490490
&sess.parse_sess,
491491
&mut resolver,
492492
krate,

src/librustc_passes/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ 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" }
1716
syntax_pos = { path = "../libsyntax_pos" }

src/libsyntax/ext/proc_macro.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ crate fn add_derived_markers<T: HasAttrs>(
231231
names.insert(unwrap_or!(path.segments.get(0), continue).ident.name);
232232
}
233233

234-
let span = span.fresh_expansion(cx.current_expansion.mark, ExpnInfo::allow_unstable(
234+
let span = span.fresh_expansion(cx.current_expansion.id, ExpnInfo::allow_unstable(
235235
ExpnKind::Macro(MacroKind::Derive, Symbol::intern(&pretty_name)), span,
236236
cx.parse_sess.edition, cx.allow_derive_markers.clone(),
237237
));

src/libsyntax/parse/lexer/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,7 @@ mod tests {
13651365
use std::path::PathBuf;
13661366
use syntax_pos::{BytePos, Span, NO_EXPANSION, edition::Edition};
13671367
use rustc_data_structures::fx::{FxHashSet, FxHashMap};
1368-
use rustc_data_structures::sync::Lock;
1368+
use rustc_data_structures::sync::{Lock, Once};
13691369

13701370
fn mk_sess(sm: Lrc<SourceMap>) -> ParseSess {
13711371
let emitter = errors::emitter::EmitterWriter::new(Box::new(io::sink()),
@@ -1388,6 +1388,7 @@ mod tests {
13881388
param_attr_spans: Lock::new(Vec::new()),
13891389
let_chains_spans: Lock::new(Vec::new()),
13901390
async_closure_spans: Lock::new(Vec::new()),
1391+
injected_crate_name: Once::new(),
13911392
}
13921393
}
13931394

src/libsyntax_ext/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//! Syntax extensions in the Rust compiler.
1+
//! This crate contains implementations of built-in macros and other code generating facilities
2+
//! injecting code into the crate before it is lowered to HIR.
23
34
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
45

@@ -31,7 +32,7 @@ mod test;
3132
mod trace_macros;
3233

3334
pub mod global_allocator;
34-
pub mod proc_macro_decls;
35+
pub mod proc_macro_harness;
3536
pub mod standard_library_imports;
3637
pub mod test_harness;
3738

src/libsyntax_ext/proc_macro_decls.rs src/libsyntax_ext/proc_macro_harness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct CollectProcMacros<'a> {
4040
is_test_crate: bool,
4141
}
4242

43-
pub fn modify(sess: &ParseSess,
43+
pub fn inject(sess: &ParseSess,
4444
resolver: &mut dyn (::syntax::ext::base::Resolver),
4545
mut krate: ast::Crate,
4646
is_proc_macro_crate: bool,

src/libsyntax_ext/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub fn expand_test_case(
2626
) -> Vec<Annotatable> {
2727
if !ecx.ecfg.should_test { return vec![]; }
2828

29-
let sp = attr_sp.with_ctxt(SyntaxContext::empty().apply_mark(ecx.current_expansion.mark));
29+
let sp = attr_sp.with_ctxt(SyntaxContext::empty().apply_mark(ecx.current_expansion.id));
3030
let mut item = anno_item.expect_item();
3131
item = item.map(|mut item| {
3232
item.vis = respan(item.vis.span, ast::VisibilityKind::Public);

src/libsyntax_ext/test_harness.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ struct TestCtxt<'a> {
3737

3838
// Traverse the crate, collecting all the test functions, eliding any
3939
// existing main functions, and synthesizing a main test harness
40-
pub fn modify_for_testing(sess: &ParseSess,
41-
resolver: &mut dyn Resolver,
42-
should_test: bool,
43-
krate: &mut ast::Crate,
44-
span_diagnostic: &errors::Handler,
45-
features: &Features) {
40+
pub fn inject(
41+
sess: &ParseSess,
42+
resolver: &mut dyn Resolver,
43+
should_test: bool,
44+
krate: &mut ast::Crate,
45+
span_diagnostic: &errors::Handler,
46+
features: &Features,
47+
) {
4648
// Check for #[reexport_test_harness_main = "some_name"] which
4749
// creates a `use __test::main as some_name;`. This needs to be
4850
// unconditional, so that the attribute is still marked as used in

0 commit comments

Comments
 (0)