Use empty typeck tables when nesting on items without those
This commit is contained in:
parent
429fc9d7b7
commit
7b3cd1b674
@ -115,15 +115,17 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
|
||||
F: FnOnce(&mut Self),
|
||||
{
|
||||
let item_def_id = self.tcx.hir().local_def_id_from_node_id(item_id);
|
||||
if self.tcx.has_typeck_tables(item_def_id) {
|
||||
let tables = self.tcx.typeck_tables_of(item_def_id);
|
||||
let old_tables = self.save_ctxt.tables;
|
||||
self.save_ctxt.tables = tables;
|
||||
f(self);
|
||||
self.save_ctxt.tables = old_tables;
|
||||
|
||||
let tables = if self.tcx.has_typeck_tables(item_def_id) {
|
||||
self.tcx.typeck_tables_of(item_def_id)
|
||||
} else {
|
||||
f(self);
|
||||
}
|
||||
self.save_ctxt.empty_tables
|
||||
};
|
||||
|
||||
let old_tables = self.save_ctxt.tables;
|
||||
self.save_ctxt.tables = tables;
|
||||
f(self);
|
||||
self.save_ctxt.tables = old_tables;
|
||||
}
|
||||
|
||||
fn span_from_span(&self, span: Span) -> SpanData {
|
||||
|
@ -48,6 +48,9 @@ use log::{debug, error, info};
|
||||
pub struct SaveContext<'l, 'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
tables: &'l ty::TypeckTables<'tcx>,
|
||||
/// Used as a fallback when nesting the typeck tables during item processing
|
||||
/// (if these are not available for that item, e.g. don't own a body)
|
||||
empty_tables: &'l ty::TypeckTables<'tcx>,
|
||||
access_levels: &'l AccessLevels,
|
||||
span_utils: SpanUtils<'tcx>,
|
||||
config: Config,
|
||||
@ -1114,6 +1117,7 @@ pub fn process_crate<'l, 'tcx, H: SaveHandler>(
|
||||
let save_ctxt = SaveContext {
|
||||
tcx,
|
||||
tables: &ty::TypeckTables::empty(None),
|
||||
empty_tables: &ty::TypeckTables::empty(None),
|
||||
access_levels: &access_levels,
|
||||
span_utils: SpanUtils::new(&tcx.sess),
|
||||
config: find_config(config),
|
||||
|
Loading…
x
Reference in New Issue
Block a user