mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
auto merge of #12048 : sanxiyn/rust/crate-config, r=alexcrichton
This commit is contained in:
commit
f039d10cf7
@ -176,7 +176,6 @@ pub fn phase_1_parse_input(sess: Session, cfg: ast::CrateConfig, input: &Input)
|
||||
/// harness if one is to be provided and injection of a dependency on the
|
||||
/// standard library and prelude.
|
||||
pub fn phase_2_configure_and_expand(sess: Session,
|
||||
cfg: ast::CrateConfig,
|
||||
loader: &mut CrateLoader,
|
||||
mut crate: ast::Crate)
|
||||
-> (ast::Crate, syntax::ast_map::Map) {
|
||||
@ -205,7 +204,6 @@ pub fn phase_2_configure_and_expand(sess: Session,
|
||||
crate = time(time_passes, "expansion", crate, |crate| {
|
||||
syntax::ext::expand::expand_crate(sess.parse_sess,
|
||||
loader,
|
||||
cfg.clone(),
|
||||
crate)
|
||||
});
|
||||
// dump the syntax-time crates
|
||||
@ -520,10 +518,10 @@ pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &Input,
|
||||
// possible to keep the peak memory usage low
|
||||
let (outputs, trans) = {
|
||||
let (expanded_crate, ast_map) = {
|
||||
let crate = phase_1_parse_input(sess, cfg.clone(), input);
|
||||
let crate = phase_1_parse_input(sess, cfg, input);
|
||||
if stop_after_phase_1(sess) { return; }
|
||||
let loader = &mut Loader::new(sess);
|
||||
phase_2_configure_and_expand(sess, cfg, loader, crate)
|
||||
phase_2_configure_and_expand(sess, loader, crate)
|
||||
};
|
||||
let outputs = build_output_filenames(input, outdir, output,
|
||||
expanded_crate.attrs, sess);
|
||||
@ -610,12 +608,12 @@ pub fn pretty_print_input(sess: Session,
|
||||
cfg: ast::CrateConfig,
|
||||
input: &Input,
|
||||
ppm: PpMode) {
|
||||
let crate = phase_1_parse_input(sess, cfg.clone(), input);
|
||||
let crate = phase_1_parse_input(sess, cfg, input);
|
||||
|
||||
let (crate, ast_map, is_expanded) = match ppm {
|
||||
PpmExpanded | PpmExpandedIdentified | PpmTyped => {
|
||||
let loader = &mut Loader::new(sess);
|
||||
let (crate, ast_map) = phase_2_configure_and_expand(sess, cfg, loader, crate);
|
||||
let (crate, ast_map) = phase_2_configure_and_expand(sess, loader, crate);
|
||||
(crate, Some(ast_map), true)
|
||||
}
|
||||
_ => (crate, None, false)
|
||||
|
@ -76,9 +76,9 @@ fn get_ast_and_resolve(cpath: &Path,
|
||||
cfg.push(@dummy_spanned(ast::MetaWord(cfg_)));
|
||||
}
|
||||
|
||||
let crate = phase_1_parse_input(sess, cfg.clone(), &input);
|
||||
let crate = phase_1_parse_input(sess, cfg, &input);
|
||||
let loader = &mut Loader::new(sess);
|
||||
let (crate, ast_map) = phase_2_configure_and_expand(sess, cfg, loader, crate);
|
||||
let (crate, ast_map) = phase_2_configure_and_expand(sess, loader, crate);
|
||||
let driver::driver::CrateAnalysis {
|
||||
exported_items, public_items, ty_cx, ..
|
||||
} = phase_3_run_analysis_passes(sess, &crate, ast_map);
|
||||
|
@ -59,9 +59,9 @@ pub fn run(input: &str, matches: &getopts::Matches) -> int {
|
||||
span_diagnostic_handler);
|
||||
|
||||
let cfg = driver::build_configuration(sess);
|
||||
let crate = driver::phase_1_parse_input(sess, cfg.clone(), &input);
|
||||
let crate = driver::phase_1_parse_input(sess, cfg, &input);
|
||||
let loader = &mut Loader::new(sess);
|
||||
let (crate, _) = driver::phase_2_configure_and_expand(sess, cfg, loader, crate);
|
||||
let (crate, _) = driver::phase_2_configure_and_expand(sess, loader, crate);
|
||||
|
||||
let ctx = @core::DocContext {
|
||||
crate: crate,
|
||||
|
@ -800,9 +800,8 @@ impl<'a> Folder for MacroExpander<'a> {
|
||||
|
||||
pub fn expand_crate(parse_sess: @parse::ParseSess,
|
||||
loader: &mut CrateLoader,
|
||||
cfg: ast::CrateConfig,
|
||||
c: Crate) -> Crate {
|
||||
let mut cx = ExtCtxt::new(parse_sess, cfg.clone(), loader);
|
||||
let mut cx = ExtCtxt::new(parse_sess, c.config.clone(), loader);
|
||||
let mut expander = MacroExpander {
|
||||
extsbox: syntax_expander_table(),
|
||||
cx: &mut cx,
|
||||
@ -1033,7 +1032,7 @@ mod test {
|
||||
~[],sess);
|
||||
// should fail:
|
||||
let mut loader = ErrLoader;
|
||||
expand_crate(sess,&mut loader,~[],crate_ast);
|
||||
expand_crate(sess,&mut loader,crate_ast);
|
||||
}
|
||||
|
||||
// make sure that macros can leave scope for modules
|
||||
@ -1048,7 +1047,7 @@ mod test {
|
||||
~[],sess);
|
||||
// should fail:
|
||||
let mut loader = ErrLoader;
|
||||
expand_crate(sess,&mut loader,~[],crate_ast);
|
||||
expand_crate(sess,&mut loader,crate_ast);
|
||||
}
|
||||
|
||||
// macro_escape modules shouldn't cause macros to leave scope
|
||||
@ -1062,7 +1061,7 @@ mod test {
|
||||
~[], sess);
|
||||
// should fail:
|
||||
let mut loader = ErrLoader;
|
||||
expand_crate(sess, &mut loader, ~[], crate_ast);
|
||||
expand_crate(sess, &mut loader, crate_ast);
|
||||
}
|
||||
|
||||
#[test] fn test_contains_flatten (){
|
||||
@ -1135,7 +1134,7 @@ mod test {
|
||||
let (crate_ast,ps) = string_to_crate_and_sess(crate_str);
|
||||
// the cfg argument actually does matter, here...
|
||||
let mut loader = ErrLoader;
|
||||
expand_crate(ps,&mut loader,~[],crate_ast)
|
||||
expand_crate(ps,&mut loader,crate_ast)
|
||||
}
|
||||
|
||||
//fn expand_and_resolve(crate_str: @str) -> ast::crate {
|
||||
|
@ -74,7 +74,7 @@ pub fn parse_crate_from_file(
|
||||
cfg: ast::CrateConfig,
|
||||
sess: @ParseSess
|
||||
) -> ast::Crate {
|
||||
new_parser_from_file(sess, /*bad*/ cfg.clone(), input).parse_crate_mod()
|
||||
new_parser_from_file(sess, cfg, input).parse_crate_mod()
|
||||
// why is there no p.abort_if_errors here?
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ pub fn parse_crate_from_source_str(name: ~str,
|
||||
sess: @ParseSess)
|
||||
-> ast::Crate {
|
||||
let mut p = new_parser_from_source_str(sess,
|
||||
/*bad*/ cfg.clone(),
|
||||
cfg,
|
||||
name,
|
||||
source);
|
||||
maybe_aborted(p.parse_crate_mod(),p)
|
||||
@ -106,7 +106,7 @@ pub fn parse_crate_attrs_from_source_str(name: ~str,
|
||||
sess: @ParseSess)
|
||||
-> ~[ast::Attribute] {
|
||||
let mut p = new_parser_from_source_str(sess,
|
||||
/*bad*/ cfg.clone(),
|
||||
cfg,
|
||||
name,
|
||||
source);
|
||||
let (inner, _) = maybe_aborted(p.parse_inner_attrs_and_next(),p);
|
||||
|
Loading…
Reference in New Issue
Block a user