Refactor the hir::lowering::lower_* functions into methods of LoweringContext
This commit is contained in:
parent
8d5c5785d5
commit
946efcd4ca
4 changed files with 1463 additions and 1479 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -37,7 +37,7 @@ use rustc_typeck as typeck;
|
|||
use rustc_privacy;
|
||||
use rustc_plugin::registry::Registry;
|
||||
use rustc_plugin as plugin;
|
||||
use rustc::hir::lowering::{lower_crate, LoweringContext};
|
||||
use rustc::hir::lowering::LoweringContext;
|
||||
use rustc_passes::{no_asm, loops, consts, rvalues, static_recursion};
|
||||
use rustc_const_eval::check_match;
|
||||
use super::Compilation;
|
||||
|
|
@ -787,8 +787,8 @@ pub fn lower_and_resolve<'a>(sess: &Session,
|
|||
|
||||
// Lower ast -> hir.
|
||||
let hir_forest = time(sess.time_passes(), "lowering ast -> hir", || {
|
||||
let mut lcx = LoweringContext::new(sess, Some(krate), &mut resolver);
|
||||
hir_map::Forest::new(lower_crate(&mut lcx, krate), dep_graph)
|
||||
let krate = LoweringContext::new(sess, Some(krate), &mut resolver).lower_crate(krate);
|
||||
hir_map::Forest::new(krate, dep_graph)
|
||||
});
|
||||
|
||||
(ty::CrateAnalysis {
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ use rustc_serialize::{Encodable, EncoderHelpers};
|
|||
#[cfg(test)] use syntax::parse;
|
||||
#[cfg(test)] use syntax::ast::NodeId;
|
||||
#[cfg(test)] use rustc::hir::print as pprust;
|
||||
#[cfg(test)] use rustc::hir::lowering::{lower_item, LoweringContext, DummyResolver};
|
||||
#[cfg(test)] use rustc::hir::lowering::{LoweringContext, DummyResolver};
|
||||
|
||||
struct DecodeContext<'a, 'b, 'tcx: 'a> {
|
||||
tcx: &'a TyCtxt<'tcx>,
|
||||
|
|
@ -1347,7 +1347,7 @@ fn roundtrip(in_item: hir::Item) {
|
|||
fn test_basic() {
|
||||
let cx = mk_ctxt();
|
||||
with_testing_context(|lcx| {
|
||||
roundtrip(lower_item(lcx, "e_item!(&cx,
|
||||
roundtrip(lcx.lower_item("e_item!(&cx,
|
||||
fn foo() {}
|
||||
).unwrap()));
|
||||
});
|
||||
|
|
@ -1357,7 +1357,7 @@ fn test_basic() {
|
|||
fn test_smalltalk() {
|
||||
let cx = mk_ctxt();
|
||||
with_testing_context(|lcx| {
|
||||
roundtrip(lower_item(lcx, "e_item!(&cx,
|
||||
roundtrip(lcx.lower_item("e_item!(&cx,
|
||||
fn foo() -> isize { 3 + 4 } // first smalltalk program ever executed.
|
||||
).unwrap()));
|
||||
});
|
||||
|
|
@ -1367,7 +1367,7 @@ fn test_smalltalk() {
|
|||
fn test_more() {
|
||||
let cx = mk_ctxt();
|
||||
with_testing_context(|lcx| {
|
||||
roundtrip(lower_item(lcx, "e_item!(&cx,
|
||||
roundtrip(lcx.lower_item("e_item!(&cx,
|
||||
fn foo(x: usize, y: usize) -> usize {
|
||||
let z = x + y;
|
||||
return z;
|
||||
|
|
@ -1387,10 +1387,10 @@ fn test_simplification() {
|
|||
).unwrap();
|
||||
let cx = mk_ctxt();
|
||||
with_testing_context(|lcx| {
|
||||
let hir_item = lower_item(lcx, &item);
|
||||
let hir_item = lcx.lower_item(&item);
|
||||
let item_in = InlinedItemRef::Item(&hir_item);
|
||||
let item_out = simplify_ast(item_in);
|
||||
let item_exp = InlinedItem::Item(P(lower_item(lcx, "e_item!(&cx,
|
||||
let item_exp = InlinedItem::Item(P(lcx.lower_item("e_item!(&cx,
|
||||
fn new_int_alist<B>() -> alist<isize, B> {
|
||||
return alist {eq_fn: eq_int, data: Vec::new()};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ use rustc::hir::map as hir_map;
|
|||
use rustc::session::{self, config};
|
||||
use rustc::session::config::{get_unstable_features_setting, OutputType};
|
||||
use rustc::session::search_paths::{SearchPaths, PathKind};
|
||||
use rustc::hir::lowering::{lower_crate, LoweringContext, DummyResolver};
|
||||
use rustc::hir::lowering::{LoweringContext, DummyResolver};
|
||||
use rustc_back::dynamic_lib::DynamicLibrary;
|
||||
use rustc_back::tempdir::TempDir;
|
||||
use rustc_driver::{driver, Compilation};
|
||||
|
|
@ -98,8 +98,7 @@ pub fn run(input: &str,
|
|||
let defs = &RefCell::new(hir_map::collect_definitions(&krate));
|
||||
|
||||
let mut dummy_resolver = DummyResolver;
|
||||
let mut lcx = LoweringContext::new(&sess, Some(&krate), &mut dummy_resolver);
|
||||
let krate = lower_crate(&mut lcx, &krate);
|
||||
let krate = LoweringContext::new(&sess, Some(&krate), &mut dummy_resolver).lower_crate(&krate);
|
||||
|
||||
let opts = scrape_test_config(&krate);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue