Skip to content

Commit

Permalink
syntax_ext: proc_macro_decls -> proc_macro_harness
Browse files Browse the repository at this point in the history
Few other minor renamings for consistency.
Remove one unused dependency from `rustc_passes`.
Fix libsyntax tests.
Fix rebase.
  • Loading branch information
petrochenkov committed Jul 20, 2019
1 parent 188330b commit ec5f089
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 32 deletions.
17 changes: 0 additions & 17 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2751,20 +2751,6 @@ dependencies = [
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "rustc_allocator"
version = "0.0.0"
dependencies = [
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_errors 0.0.0",
"rustc_target 0.0.0",
"smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
"syntax 0.0.0",
"syntax_pos 0.0.0",
]

[[package]]
name = "rustc_apfloat"
version = "0.0.0"
Expand Down Expand Up @@ -2822,7 +2808,6 @@ dependencies = [
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_allocator 0.0.0",
"rustc_apfloat 0.0.0",
"rustc_codegen_utils 0.0.0",
"rustc_data_structures 0.0.0",
Expand Down Expand Up @@ -2935,7 +2920,6 @@ dependencies = [
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc-rayon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_allocator 0.0.0",
"rustc_ast_borrowck 0.0.0",
"rustc_codegen_ssa 0.0.0",
"rustc_codegen_utils 0.0.0",
Expand Down Expand Up @@ -3060,7 +3044,6 @@ dependencies = [
"rustc 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_errors 0.0.0",
"rustc_mir 0.0.0",
"syntax 0.0.0",
"syntax_pos 0.0.0",
]
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_interface/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ fn configure_and_expand_inner<'a>(
sess.profiler(|p| p.end_activity("macro expansion"));

time(sess, "maybe building test harness", || {
syntax_ext::test_harness::modify_for_testing(
syntax_ext::test_harness::inject(
&sess.parse_sess,
&mut resolver,
sess.opts.test,
Expand Down Expand Up @@ -486,7 +486,7 @@ fn configure_and_expand_inner<'a>(
let num_crate_types = crate_types.len();
let is_proc_macro_crate = crate_types.contains(&config::CrateType::ProcMacro);
let is_test_crate = sess.opts.test;
syntax_ext::proc_macro_decls::modify(
syntax_ext::proc_macro_harness::inject(
&sess.parse_sess,
&mut resolver,
krate,
Expand Down
1 change: 0 additions & 1 deletion src/librustc_passes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ path = "lib.rs"
[dependencies]
log = "0.4"
rustc = { path = "../librustc" }
rustc_mir = { path = "../librustc_mir"}
rustc_data_structures = { path = "../librustc_data_structures" }
syntax = { path = "../libsyntax" }
syntax_pos = { path = "../libsyntax_pos" }
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ext/proc_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ crate fn add_derived_markers<T: HasAttrs>(
names.insert(unwrap_or!(path.segments.get(0), continue).ident.name);
}

let span = span.fresh_expansion(cx.current_expansion.mark, ExpnInfo::allow_unstable(
let span = span.fresh_expansion(cx.current_expansion.id, ExpnInfo::allow_unstable(
ExpnKind::Macro(MacroKind::Derive, Symbol::intern(&pretty_name)), span,
cx.parse_sess.edition, cx.allow_derive_markers.clone(),
));
Expand Down
3 changes: 2 additions & 1 deletion src/libsyntax/parse/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ mod tests {
use std::path::PathBuf;
use syntax_pos::{BytePos, Span, NO_EXPANSION, edition::Edition};
use rustc_data_structures::fx::{FxHashSet, FxHashMap};
use rustc_data_structures::sync::Lock;
use rustc_data_structures::sync::{Lock, Once};

fn mk_sess(sm: Lrc<SourceMap>) -> ParseSess {
let emitter = errors::emitter::EmitterWriter::new(Box::new(io::sink()),
Expand All @@ -1388,6 +1388,7 @@ mod tests {
param_attr_spans: Lock::new(Vec::new()),
let_chains_spans: Lock::new(Vec::new()),
async_closure_spans: Lock::new(Vec::new()),
injected_crate_name: Once::new(),
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/libsyntax_ext/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Syntax extensions in the Rust compiler.
//! This crate contains implementations of built-in macros and other code generating facilities
//! injecting code into the crate before it is lowered to HIR.

#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]

Expand Down Expand Up @@ -31,7 +32,7 @@ mod test;
mod trace_macros;

pub mod global_allocator;
pub mod proc_macro_decls;
pub mod proc_macro_harness;
pub mod standard_library_imports;
pub mod test_harness;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct CollectProcMacros<'a> {
is_test_crate: bool,
}

pub fn modify(sess: &ParseSess,
pub fn inject(sess: &ParseSess,
resolver: &mut dyn (::syntax::ext::base::Resolver),
mut krate: ast::Crate,
is_proc_macro_crate: bool,
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax_ext/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn expand_test_case(
) -> Vec<Annotatable> {
if !ecx.ecfg.should_test { return vec![]; }

let sp = attr_sp.with_ctxt(SyntaxContext::empty().apply_mark(ecx.current_expansion.mark));
let sp = attr_sp.with_ctxt(SyntaxContext::empty().apply_mark(ecx.current_expansion.id));
let mut item = anno_item.expect_item();
item = item.map(|mut item| {
item.vis = respan(item.vis.span, ast::VisibilityKind::Public);
Expand Down
14 changes: 8 additions & 6 deletions src/libsyntax_ext/test_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ struct TestCtxt<'a> {

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

0 comments on commit ec5f089

Please sign in to comment.