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.
This commit is contained in:
parent
4d535bdf59
commit
b5a0e6ea80
10 changed files with 19 additions and 21 deletions
|
@ -3052,7 +3052,6 @@ dependencies = [
|
||||||
"rustc 0.0.0",
|
"rustc 0.0.0",
|
||||||
"rustc_data_structures 0.0.0",
|
"rustc_data_structures 0.0.0",
|
||||||
"rustc_errors 0.0.0",
|
"rustc_errors 0.0.0",
|
||||||
"rustc_mir 0.0.0",
|
|
||||||
"syntax 0.0.0",
|
"syntax 0.0.0",
|
||||||
"syntax_pos 0.0.0",
|
"syntax_pos 0.0.0",
|
||||||
]
|
]
|
||||||
|
|
|
@ -461,7 +461,7 @@ fn configure_and_expand_inner<'a>(
|
||||||
sess.profiler(|p| p.end_activity("macro expansion"));
|
sess.profiler(|p| p.end_activity("macro expansion"));
|
||||||
|
|
||||||
time(sess, "maybe building test harness", || {
|
time(sess, "maybe building test harness", || {
|
||||||
syntax_ext::test_harness::modify_for_testing(
|
syntax_ext::test_harness::inject(
|
||||||
&sess.parse_sess,
|
&sess.parse_sess,
|
||||||
&mut resolver,
|
&mut resolver,
|
||||||
sess.opts.test,
|
sess.opts.test,
|
||||||
|
@ -490,7 +490,7 @@ fn configure_and_expand_inner<'a>(
|
||||||
let num_crate_types = crate_types.len();
|
let num_crate_types = crate_types.len();
|
||||||
let is_proc_macro_crate = crate_types.contains(&config::CrateType::ProcMacro);
|
let is_proc_macro_crate = crate_types.contains(&config::CrateType::ProcMacro);
|
||||||
let is_test_crate = sess.opts.test;
|
let is_test_crate = sess.opts.test;
|
||||||
syntax_ext::proc_macro_decls::modify(
|
syntax_ext::proc_macro_harness::inject(
|
||||||
&sess.parse_sess,
|
&sess.parse_sess,
|
||||||
&mut resolver,
|
&mut resolver,
|
||||||
krate,
|
krate,
|
||||||
|
|
|
@ -11,7 +11,6 @@ path = "lib.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
rustc = { path = "../librustc" }
|
rustc = { path = "../librustc" }
|
||||||
rustc_mir = { path = "../librustc_mir"}
|
|
||||||
rustc_data_structures = { path = "../librustc_data_structures" }
|
rustc_data_structures = { path = "../librustc_data_structures" }
|
||||||
syntax = { path = "../libsyntax" }
|
syntax = { path = "../libsyntax" }
|
||||||
syntax_pos = { path = "../libsyntax_pos" }
|
syntax_pos = { path = "../libsyntax_pos" }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::ast::{self, Attribute, Name, PatKind};
|
use crate::ast::{self, Attribute, Name, PatKind};
|
||||||
use crate::attr::{HasAttrs, Stability, Deprecation};
|
use crate::attr::{HasAttrs, Stability, Deprecation};
|
||||||
use crate::source_map::{SourceMap, Spanned, FileName, respan};
|
use crate::source_map::{SourceMap, Spanned, respan};
|
||||||
use crate::edition::Edition;
|
use crate::edition::Edition;
|
||||||
use crate::ext::expand::{self, AstFragment, Invocation};
|
use crate::ext::expand::{self, AstFragment, Invocation};
|
||||||
use crate::ext::hygiene::{ExpnId, SyntaxContext, Transparency};
|
use crate::ext::hygiene::{ExpnId, SyntaxContext, Transparency};
|
||||||
|
|
|
@ -231,7 +231,7 @@ crate fn add_derived_markers<T: HasAttrs>(
|
||||||
names.insert(unwrap_or!(path.segments.get(0), continue).ident.name);
|
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,
|
ExpnKind::Macro(MacroKind::Derive, Symbol::intern(&pretty_name)), span,
|
||||||
cx.parse_sess.edition, cx.allow_derive_markers.clone(),
|
cx.parse_sess.edition, cx.allow_derive_markers.clone(),
|
||||||
));
|
));
|
||||||
|
|
|
@ -794,7 +794,7 @@ mod tests {
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use syntax_pos::{BytePos, Span, NO_EXPANSION, edition::Edition};
|
use syntax_pos::{BytePos, Span, NO_EXPANSION, edition::Edition};
|
||||||
use rustc_data_structures::fx::{FxHashSet, FxHashMap};
|
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 {
|
fn mk_sess(sm: Lrc<SourceMap>) -> ParseSess {
|
||||||
let emitter = errors::emitter::EmitterWriter::new(Box::new(io::sink()),
|
let emitter = errors::emitter::EmitterWriter::new(Box::new(io::sink()),
|
||||||
|
@ -817,6 +817,7 @@ mod tests {
|
||||||
param_attr_spans: Lock::new(Vec::new()),
|
param_attr_spans: Lock::new(Vec::new()),
|
||||||
let_chains_spans: Lock::new(Vec::new()),
|
let_chains_spans: Lock::new(Vec::new()),
|
||||||
async_closure_spans: Lock::new(Vec::new()),
|
async_closure_spans: Lock::new(Vec::new()),
|
||||||
|
injected_crate_name: Once::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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/")]
|
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||||
|
|
||||||
|
@ -10,16 +11,12 @@
|
||||||
#![feature(mem_take)]
|
#![feature(mem_take)]
|
||||||
#![feature(nll)]
|
#![feature(nll)]
|
||||||
#![feature(rustc_diagnostic_macros)]
|
#![feature(rustc_diagnostic_macros)]
|
||||||
#![feature(unicode_internals)]
|
|
||||||
|
|
||||||
extern crate proc_macro;
|
|
||||||
|
|
||||||
use crate::deriving::*;
|
use crate::deriving::*;
|
||||||
|
|
||||||
use syntax::ast::Ident;
|
use syntax::ast::Ident;
|
||||||
use syntax::edition::Edition;
|
use syntax::edition::Edition;
|
||||||
use syntax::ext::base::{SyntaxExtension, SyntaxExtensionKind, MacroExpanderFn};
|
use syntax::ext::base::{SyntaxExtension, SyntaxExtensionKind, MacroExpanderFn};
|
||||||
use syntax::ext::source_util;
|
|
||||||
use syntax::symbol::sym;
|
use syntax::symbol::sym;
|
||||||
|
|
||||||
mod error_codes;
|
mod error_codes;
|
||||||
|
@ -42,7 +39,7 @@ mod test;
|
||||||
mod trace_macros;
|
mod trace_macros;
|
||||||
|
|
||||||
pub mod plugin_macro_defs;
|
pub mod plugin_macro_defs;
|
||||||
pub mod proc_macro_decls;
|
pub mod proc_macro_harness;
|
||||||
pub mod standard_library_imports;
|
pub mod standard_library_imports;
|
||||||
pub mod test_harness;
|
pub mod test_harness;
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ struct CollectProcMacros<'a> {
|
||||||
is_test_crate: bool,
|
is_test_crate: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn modify(sess: &ParseSess,
|
pub fn inject(sess: &ParseSess,
|
||||||
resolver: &mut dyn (::syntax::ext::base::Resolver),
|
resolver: &mut dyn (::syntax::ext::base::Resolver),
|
||||||
mut krate: ast::Crate,
|
mut krate: ast::Crate,
|
||||||
is_proc_macro_crate: bool,
|
is_proc_macro_crate: bool,
|
|
@ -30,7 +30,7 @@ pub fn expand_test_case(
|
||||||
|
|
||||||
if !ecx.ecfg.should_test { return vec![]; }
|
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();
|
let mut item = anno_item.expect_item();
|
||||||
item = item.map(|mut item| {
|
item = item.map(|mut item| {
|
||||||
item.vis = respan(item.vis.span, ast::VisibilityKind::Public);
|
item.vis = respan(item.vis.span, ast::VisibilityKind::Public);
|
||||||
|
|
|
@ -37,12 +37,14 @@ struct TestCtxt<'a> {
|
||||||
|
|
||||||
// Traverse the crate, collecting all the test functions, eliding any
|
// Traverse the crate, collecting all the test functions, eliding any
|
||||||
// existing main functions, and synthesizing a main test harness
|
// existing main functions, and synthesizing a main test harness
|
||||||
pub fn modify_for_testing(sess: &ParseSess,
|
pub fn inject(
|
||||||
|
sess: &ParseSess,
|
||||||
resolver: &mut dyn Resolver,
|
resolver: &mut dyn Resolver,
|
||||||
should_test: bool,
|
should_test: bool,
|
||||||
krate: &mut ast::Crate,
|
krate: &mut ast::Crate,
|
||||||
span_diagnostic: &errors::Handler,
|
span_diagnostic: &errors::Handler,
|
||||||
features: &Features) {
|
features: &Features,
|
||||||
|
) {
|
||||||
// Check for #[reexport_test_harness_main = "some_name"] which
|
// Check for #[reexport_test_harness_main = "some_name"] which
|
||||||
// creates a `use __test::main as some_name;`. This needs to be
|
// creates a `use __test::main as some_name;`. This needs to be
|
||||||
// unconditional, so that the attribute is still marked as used in
|
// unconditional, so that the attribute is still marked as used in
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue