diff options
| author | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2016-04-30 00:48:03 +0000 |
|---|---|---|
| committer | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2016-05-01 23:30:18 +0000 |
| commit | ca88c44a9092c22ce39797e9b19ed6f7bb179ada (patch) | |
| tree | 8a4a9493d5f4fc223157bc1696859776469ea47c /src/librustc_save_analysis | |
| parent | 02df9f32b1947fe194e2844a11db454b9763ea92 (diff) | |
Avoid using the lowering context in `librustc_save_analysis`
Diffstat (limited to 'src/librustc_save_analysis')
| -rw-r--r-- | src/librustc_save_analysis/dump_visitor.rs | 6 | ||||
| -rw-r--r-- | src/librustc_save_analysis/lib.rs | 20 |
2 files changed, 9 insertions, 17 deletions
diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 724bd7341e3..d12d1c8aae0 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -42,8 +42,6 @@ use syntax::visit::{self, Visitor}; use syntax::print::pprust::{path_to_string, ty_to_string}; use syntax::ptr::P; -use rustc::hir::lowering::lower_expr; - use super::{escape, generated_code, SaveContext, PathCollector}; use super::data::*; use super::dump::Dump; @@ -1222,7 +1220,7 @@ impl<'v, 'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor<'v> for DumpVisitor<'l, 'tcx, visit::walk_expr(self, ex); } ast::ExprKind::Struct(ref path, ref fields, ref base) => { - let hir_expr = lower_expr(self.save_ctxt.lcx, ex); + let hir_expr = self.save_ctxt.tcx.map.expect_expr(ex.id); let adt = self.tcx.expr_ty(&hir_expr).ty_adt_def().unwrap(); let def = self.tcx.resolve_expr(&hir_expr); self.process_struct_lit(ex, path, fields, adt.variant_of_def(def), base) @@ -1241,7 +1239,7 @@ impl<'v, 'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor<'v> for DumpVisitor<'l, 'tcx, ast::ExprKind::TupField(ref sub_ex, idx) => { self.visit_expr(&sub_ex); - let hir_node = lower_expr(self.save_ctxt.lcx, sub_ex); + let hir_node = self.save_ctxt.tcx.map.expect_expr(sub_ex.id); let ty = &self.tcx.expr_ty_adjusted(&hir_node).sty; match *ty { ty::TyStruct(def, _) => { diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 6830735b0ba..85c8f1f8ec9 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -28,7 +28,7 @@ #[macro_use] extern crate syntax; extern crate serialize as rustc_serialize; -use rustc::hir::{self, lowering}; +use rustc::hir; use rustc::hir::map::NodeItem; use rustc::hir::def::Def; use rustc::hir::def_id::DefId; @@ -75,7 +75,6 @@ pub mod recorder { pub struct SaveContext<'l, 'tcx: 'l> { tcx: &'l TyCtxt<'tcx>, - lcx: &'l lowering::LoweringContext<'l>, span_utils: SpanUtils<'tcx>, } @@ -84,20 +83,16 @@ macro_rules! option_try( ); impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { - pub fn new(tcx: &'l TyCtxt<'tcx>, - lcx: &'l lowering::LoweringContext<'l>) - -> SaveContext<'l, 'tcx> { + pub fn new(tcx: &'l TyCtxt<'tcx>) -> SaveContext<'l, 'tcx> { let span_utils = SpanUtils::new(&tcx.sess); - SaveContext::from_span_utils(tcx, lcx, span_utils) + SaveContext::from_span_utils(tcx, span_utils) } pub fn from_span_utils(tcx: &'l TyCtxt<'tcx>, - lcx: &'l lowering::LoweringContext<'l>, span_utils: SpanUtils<'tcx>) -> SaveContext<'l, 'tcx> { SaveContext { tcx: tcx, - lcx: lcx, span_utils: span_utils, } } @@ -378,14 +373,14 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { } pub fn get_expr_data(&self, expr: &ast::Expr) -> Option<Data> { - let hir_node = lowering::lower_expr(self.lcx, expr); + let hir_node = self.tcx.map.expect_expr(expr.id); let ty = self.tcx.expr_ty_adjusted_opt(&hir_node); if ty.is_none() || ty.unwrap().sty == ty::TyError { return None; } match expr.node { ast::ExprKind::Field(ref sub_ex, ident) => { - let hir_node = lowering::lower_expr(self.lcx, sub_ex); + let hir_node = self.tcx.map.expect_expr(sub_ex.id); match self.tcx.expr_ty_adjusted(&hir_node).sty { ty::TyStruct(def, _) => { let f = def.struct_variant().field_named(ident.node.name); @@ -405,7 +400,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { } } ast::ExprKind::Struct(ref path, _, _) => { - let hir_node = lowering::lower_expr(self.lcx, expr); + let hir_node = self.tcx.map.expect_expr(expr.id); match self.tcx.expr_ty_adjusted(&hir_node).sty { ty::TyStruct(def, _) => { let sub_span = self.span_utils.span_for_last_ident(path.span); @@ -704,7 +699,6 @@ impl Format { } pub fn process_crate<'l, 'tcx>(tcx: &'l TyCtxt<'tcx>, - lcx: &'l lowering::LoweringContext<'l>, krate: &ast::Crate, analysis: &'l ty::CrateAnalysis<'l>, cratename: &str, @@ -755,7 +749,7 @@ pub fn process_crate<'l, 'tcx>(tcx: &'l TyCtxt<'tcx>, let output = &mut output_file; let utils: SpanUtils<'tcx> = SpanUtils::new(&tcx.sess); - let save_ctxt = SaveContext::new(tcx, lcx); + let save_ctxt = SaveContext::new(tcx); macro_rules! dump { ($new_dumper: expr) => {{ |
