debugging, misc fixes

This commit is contained in:
Nick Cameron 2016-04-18 10:30:55 +12:00
parent 744be0b5aa
commit 1d5a29cf0e
17 changed files with 260 additions and 162 deletions

View file

@ -17,10 +17,10 @@ use super::data::*;
use super::dump::Dump;
use super::span_utils::SpanUtils;
pub struct CsvDumper<'a, 'b, W: 'b> {
pub struct CsvDumper<'tcx, 'b, W: 'b> {
output: &'b mut W,
dump_spans: bool,
span: SpanUtils<'a>
span: SpanUtils<'tcx>
}
impl<'a, 'b, W: Write> CsvDumper<'a, 'b, W> {

View file

@ -42,7 +42,7 @@ 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, LoweringContext};
use rustc::hir::lowering::lower_expr;
use super::{escape, generated_code, SaveContext, PathCollector};
use super::data::*;
@ -60,12 +60,12 @@ macro_rules! down_cast_data {
};
}
pub struct DumpVisitor<'l, 'tcx: 'l, D: 'l> {
pub struct DumpVisitor<'l, 'tcx: 'l, 'll, D: 'll> {
save_ctxt: SaveContext<'l, 'tcx>,
sess: &'l Session,
tcx: &'l TyCtxt<'tcx>,
analysis: &'l ty::CrateAnalysis<'l>,
dumper: &'l mut D,
dumper: &'ll mut D,
span: SpanUtils<'l>,
@ -77,22 +77,19 @@ pub struct DumpVisitor<'l, 'tcx: 'l, D: 'l> {
// one macro use per unique callsite span.
mac_defs: HashSet<Span>,
mac_uses: HashSet<Span>,
}
impl <'l, 'tcx, D> DumpVisitor<'l, 'tcx, D>
where D: Dump
{
impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
pub fn new(tcx: &'l TyCtxt<'tcx>,
lcx: &'l LoweringContext<'l>,
save_ctxt: SaveContext<'l, 'tcx>,
analysis: &'l ty::CrateAnalysis<'l>,
dumper: &'l mut D)
-> DumpVisitor<'l, 'tcx, D> {
dumper: &'ll mut D)
-> DumpVisitor<'l, 'tcx, 'll, D> {
let span_utils = SpanUtils::new(&tcx.sess);
DumpVisitor {
sess: &tcx.sess,
tcx: tcx,
save_ctxt: SaveContext::from_span_utils(tcx, lcx, span_utils.clone()),
save_ctxt: save_ctxt,
analysis: analysis,
dumper: dumper,
span: span_utils.clone(),
@ -103,7 +100,7 @@ where D: Dump
}
fn nest<F>(&mut self, scope_id: NodeId, f: F)
where F: FnOnce(&mut DumpVisitor<'l, 'tcx, D>)
where F: FnOnce(&mut DumpVisitor<'l, 'tcx, 'll, D>)
{
let parent_scope = self.cur_scope;
self.cur_scope = scope_id;
@ -982,7 +979,7 @@ where D: Dump
}
}
impl<'l, 'tcx, 'v, D: Dump + 'l> Visitor<'v> for DumpVisitor<'l, 'tcx, D> {
impl<'v, 'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor<'v> for DumpVisitor<'l, 'tcx, 'll, D> {
fn visit_item(&mut self, item: &ast::Item) {
use syntax::ast::ItemKind::*;
self.process_macro_use(item.span, item.id);

View file

@ -73,7 +73,7 @@ pub mod recorder {
pub struct SaveContext<'l, 'tcx: 'l> {
tcx: &'l TyCtxt<'tcx>,
lcx: &'l lowering::LoweringContext<'l>,
span_utils: SpanUtils<'l>,
span_utils: SpanUtils<'tcx>,
}
macro_rules! option_try(
@ -90,7 +90,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
pub fn from_span_utils(tcx: &'l TyCtxt<'tcx>,
lcx: &'l lowering::LoweringContext<'l>,
span_utils: SpanUtils<'l>)
span_utils: SpanUtils<'tcx>)
-> SaveContext<'l, 'tcx> {
SaveContext {
tcx: tcx,
@ -680,7 +680,7 @@ impl<'v> Visitor<'v> for PathCollector {
pub fn process_crate<'l, 'tcx>(tcx: &'l TyCtxt<'tcx>,
lcx: &'l lowering::LoweringContext<'l>,
krate: &ast::Crate,
analysis: &ty::CrateAnalysis,
analysis: &'l ty::CrateAnalysis<'l>,
cratename: &str,
odir: Option<&Path>) {
let _ignore = tcx.dep_graph.in_ignore();
@ -726,9 +726,10 @@ pub fn process_crate<'l, 'tcx>(tcx: &'l TyCtxt<'tcx>,
});
root_path.pop();
let utils = SpanUtils::new(&tcx.sess);
let utils: SpanUtils<'tcx> = SpanUtils::new(&tcx.sess);
let save_ctxt = SaveContext::new(tcx, lcx);
let mut dumper = CsvDumper::new(&mut output_file, utils);
let mut visitor = DumpVisitor::new(tcx, lcx, analysis, &mut dumper);
let mut visitor = DumpVisitor::new(tcx, save_ctxt, analysis, &mut dumper);
// FIXME: we don't write anything!
visitor.dump_crate_info(cratename, krate);

View file

@ -26,6 +26,8 @@ use syntax::parse::token::{keywords, Token};
#[derive(Clone)]
pub struct SpanUtils<'a> {
pub sess: &'a Session,
// FIXME given that we clone SpanUtils all over the place, this err_count is
// probably useless and any logic relying on it is bogus.
pub err_count: Cell<isize>,
}