Auto merge of #33532 - jseyfried:mutable_lowering_context, r=nrc
Clean up `hir::lowering` Clean up `hir::lowering`: - give lowering functions mutable access to the lowering context - refactor the `lower_*` functions and other functions that take a lowering context into methods - simplify the API that `hir::lowering` exposes to `driver` - other miscellaneous cleanups r? @nrc
This commit is contained in:
commit
dee865a56d
File diff suppressed because it is too large
Load Diff
@ -37,7 +37,7 @@
|
||||
use rustc_privacy;
|
||||
use rustc_plugin::registry::Registry;
|
||||
use rustc_plugin as plugin;
|
||||
use rustc::hir::lowering::{lower_crate, LoweringContext};
|
||||
use rustc::hir::lowering::lower_crate;
|
||||
use rustc_passes::{no_asm, loops, consts, rvalues, static_recursion};
|
||||
use rustc_const_eval::check_match;
|
||||
use super::Compilation;
|
||||
@ -816,8 +816,7 @@ pub fn lower_and_resolve<'a>(sess: &Session,
|
||||
|
||||
// Lower ast -> hir.
|
||||
let hir_forest = time(sess.time_passes(), "lowering ast -> hir", || {
|
||||
let lcx = LoweringContext::new(sess, Some(krate), &mut resolver);
|
||||
hir_map::Forest::new(lower_crate(&lcx, krate), dep_graph)
|
||||
hir_map::Forest::new(lower_crate(krate, sess, &mut resolver), dep_graph)
|
||||
});
|
||||
|
||||
(ty::CrateAnalysis {
|
||||
|
@ -57,7 +57,7 @@
|
||||
#[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: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
@ -1319,11 +1319,11 @@ fn mk_ctxt() -> parse::ParseSess {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn with_testing_context<T, F: FnOnce(LoweringContext) -> T>(f: F) -> T {
|
||||
fn with_testing_context<T, F: FnOnce(&mut LoweringContext) -> T>(f: F) -> T {
|
||||
let assigner = FakeNodeIdAssigner;
|
||||
let mut resolver = DummyResolver;
|
||||
let lcx = LoweringContext::new(&assigner, None, &mut resolver);
|
||||
f(lcx)
|
||||
let mut lcx = LoweringContext::testing_context(&assigner, &mut resolver);
|
||||
f(&mut lcx)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@ -1340,7 +1340,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()));
|
||||
});
|
||||
@ -1350,7 +1350,7 @@ fn foo() {}
|
||||
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()));
|
||||
});
|
||||
@ -1360,7 +1360,7 @@ fn foo() -> isize { 3 + 4 } // first smalltalk program ever executed.
|
||||
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;
|
||||
@ -1380,10 +1380,10 @@ fn eq_int(a: isize, b: isize) -> bool { a == b }
|
||||
).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::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::{lower_crate, 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 lcx = LoweringContext::new(&sess, Some(&krate), &mut dummy_resolver);
|
||||
let krate = lower_crate(&lcx, &krate);
|
||||
let krate = lower_crate(&krate, &sess, &mut dummy_resolver);
|
||||
|
||||
let opts = scrape_test_config(&krate);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user