Skip to content

Commit 0a24e28

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 0c0ddcd commit 0a24e28

File tree

10 files changed

+19
-18
lines changed

10 files changed

+19
-18
lines changed

Cargo.lock

-2
Original file line numberDiff line numberDiff line change
@@ -3007,7 +3007,6 @@ dependencies = [
30073007
"smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
30083008
"stable_deref_trait 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
30093009
"syntax 0.0.0",
3010-
"syntax_ext 0.0.0",
30113010
"syntax_pos 0.0.0",
30123011
]
30133012

@@ -3052,7 +3051,6 @@ dependencies = [
30523051
"rustc 0.0.0",
30533052
"rustc_data_structures 0.0.0",
30543053
"rustc_errors 0.0.0",
3055-
"rustc_mir 0.0.0",
30563054
"syntax 0.0.0",
30573055
"syntax_pos 0.0.0",
30583056
]

src/librustc_interface/passes.rs

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

460460
time(sess, "maybe building test harness", || {
461-
syntax_ext::test_harness::modify_for_testing(
461+
syntax_ext::test_harness::inject(
462462
&sess.parse_sess,
463463
&mut resolver,
464464
sess.opts.test,
@@ -487,7 +487,7 @@ fn configure_and_expand_inner<'a>(
487487
let num_crate_types = crate_types.len();
488488
let is_proc_macro_crate = crate_types.contains(&config::CrateType::ProcMacro);
489489
let is_test_crate = sess.opts.test;
490-
syntax_ext::proc_macro_decls::modify(
490+
syntax_ext::proc_macro_harness::inject(
491491
&sess.parse_sess,
492492
&mut resolver,
493493
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/base.rs

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

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
@@ -784,7 +784,7 @@ mod tests {
784784
use std::path::PathBuf;
785785
use syntax_pos::{BytePos, Span, NO_EXPANSION, edition::Edition};
786786
use rustc_data_structures::fx::{FxHashSet, FxHashMap};
787-
use rustc_data_structures::sync::Lock;
787+
use rustc_data_structures::sync::{Lock, Once};
788788

789789
fn mk_sess(sm: Lrc<SourceMap>) -> ParseSess {
790790
let emitter = errors::emitter::EmitterWriter::new(Box::new(io::sink()),
@@ -807,6 +807,7 @@ mod tests {
807807
param_attr_spans: Lock::new(Vec::new()),
808808
let_chains_spans: Lock::new(Vec::new()),
809809
async_closure_spans: Lock::new(Vec::new()),
810+
injected_crate_name: Once::new(),
810811
}
811812
}
812813

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

@@ -32,7 +33,7 @@ mod source_util;
3233
mod test;
3334
mod trace_macros;
3435

35-
pub mod proc_macro_decls;
36+
pub mod proc_macro_harness;
3637
pub mod standard_library_imports;
3738
pub mod test_harness;
3839

src/libsyntax_ext/proc_macro_decls.rs renamed to 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
@@ -30,7 +30,7 @@ pub fn expand_test_case(
3030

3131
if !ecx.ecfg.should_test { return vec![]; }
3232

33-
let sp = attr_sp.with_ctxt(SyntaxContext::empty().apply_mark(ecx.current_expansion.mark));
33+
let sp = attr_sp.with_ctxt(SyntaxContext::empty().apply_mark(ecx.current_expansion.id));
3434
let mut item = anno_item.expect_item();
3535
item = item.map(|mut item| {
3636
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)