Skip to content

Commit b5a0e6e

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 4d535bd commit b5a0e6e

File tree

10 files changed

+19
-21
lines changed

10 files changed

+19
-21
lines changed

Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -3052,7 +3052,6 @@ dependencies = [
30523052
"rustc 0.0.0",
30533053
"rustc_data_structures 0.0.0",
30543054
"rustc_errors 0.0.0",
3055-
"rustc_mir 0.0.0",
30563055
"syntax 0.0.0",
30573056
"syntax_pos 0.0.0",
30583057
]

src/librustc_interface/passes.rs

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

463463
time(sess, "maybe building test harness", || {
464-
syntax_ext::test_harness::modify_for_testing(
464+
syntax_ext::test_harness::inject(
465465
&sess.parse_sess,
466466
&mut resolver,
467467
sess.opts.test,
@@ -490,7 +490,7 @@ fn configure_and_expand_inner<'a>(
490490
let num_crate_types = crate_types.len();
491491
let is_proc_macro_crate = crate_types.contains(&config::CrateType::ProcMacro);
492492
let is_test_crate = sess.opts.test;
493-
syntax_ext::proc_macro_decls::modify(
493+
syntax_ext::proc_macro_harness::inject(
494494
&sess.parse_sess,
495495
&mut resolver,
496496
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
@@ -794,7 +794,7 @@ mod tests {
794794
use std::path::PathBuf;
795795
use syntax_pos::{BytePos, Span, NO_EXPANSION, edition::Edition};
796796
use rustc_data_structures::fx::{FxHashSet, FxHashMap};
797-
use rustc_data_structures::sync::Lock;
797+
use rustc_data_structures::sync::{Lock, Once};
798798

799799
fn mk_sess(sm: Lrc<SourceMap>) -> ParseSess {
800800
let emitter = errors::emitter::EmitterWriter::new(Box::new(io::sink()),
@@ -817,6 +817,7 @@ mod tests {
817817
param_attr_spans: Lock::new(Vec::new()),
818818
let_chains_spans: Lock::new(Vec::new()),
819819
async_closure_spans: Lock::new(Vec::new()),
820+
injected_crate_name: Once::new(),
820821
}
821822
}
822823

src/libsyntax_ext/lib.rs

+3-6
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

@@ -10,16 +11,12 @@
1011
#![feature(mem_take)]
1112
#![feature(nll)]
1213
#![feature(rustc_diagnostic_macros)]
13-
#![feature(unicode_internals)]
14-
15-
extern crate proc_macro;
1614

1715
use crate::deriving::*;
1816

1917
use syntax::ast::Ident;
2018
use syntax::edition::Edition;
2119
use syntax::ext::base::{SyntaxExtension, SyntaxExtensionKind, MacroExpanderFn};
22-
use syntax::ext::source_util;
2320
use syntax::symbol::sym;
2421

2522
mod error_codes;
@@ -42,7 +39,7 @@ mod test;
4239
mod trace_macros;
4340

4441
pub mod plugin_macro_defs;
45-
pub mod proc_macro_decls;
42+
pub mod proc_macro_harness;
4643
pub mod standard_library_imports;
4744
pub mod test_harness;
4845

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
@@ -38,7 +38,7 @@ struct CollectProcMacros<'a> {
3838
is_test_crate: bool,
3939
}
4040

41-
pub fn modify(sess: &ParseSess,
41+
pub fn inject(sess: &ParseSess,
4242
resolver: &mut dyn (::syntax::ext::base::Resolver),
4343
mut krate: ast::Crate,
4444
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)