incr.comp.: Do some various cleanup.

This commit is contained in:
Michael Woerister 2017-09-22 12:57:33 +02:00
parent fecd92a7fe
commit a7428da415
3 changed files with 12 additions and 18 deletions

View File

@ -97,6 +97,17 @@ impl serialize::UseSpecializedDecodable for CrateNum {
RustcDecodable, Hash, Copy)]
pub struct DefIndex(u32);
impl Idx for DefIndex {
fn new(value: usize) -> Self {
assert!(value < (u32::MAX) as usize);
DefIndex(value as u32)
}
fn index(self) -> usize {
self.0 as usize
}
}
impl fmt::Debug for DefIndex {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f,

View File

@ -876,20 +876,10 @@ impl<'hir> Map<'hir> {
Some(RootCrate(_)) => self.forest.krate.span,
Some(NotPresent) | None => {
// Some nodes, notably macro definitions, are not
// present in the map for whatever reason, but
// they *do* have def-ids. So if we encounter an
// empty hole, check for that case.
if let Some(def_index) = self.definitions.opt_def_index(id) {
let def_path_hash = self.definitions.def_path_hash(def_index);
self.dep_graph.read(def_path_hash.to_dep_node(DepKind::Hir));
DUMMY_SP
} else {
bug!("hir::map::Map::span: id not in map: {:?}", id)
}
}
}
}
pub fn span_if_local(&self, id: DefId) -> Option<Span> {
self.as_local_node_id(id).map(|id| self.span(id))

View File

@ -20,7 +20,6 @@ use {abort_on_err, driver};
use rustc::ty::{self, TyCtxt, GlobalArenas, Resolutions};
use rustc::cfg;
use rustc::cfg::graphviz::LabelledCFG;
use rustc::dep_graph::DepGraph;
use rustc::middle::cstore::CrateStore;
use rustc::session::Session;
use rustc::session::config::{Input, OutputFilenames};
@ -848,9 +847,6 @@ pub fn print_after_parsing(sess: &Session,
krate: &ast::Crate,
ppm: PpMode,
ofile: Option<&Path>) {
let dep_graph = DepGraph::new(false);
let _ignore = dep_graph.in_ignore();
let (src, src_name) = get_source(input, sess);
let mut rdr = &*src;
@ -893,9 +889,6 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
output_filenames: &OutputFilenames,
opt_uii: Option<UserIdentifiedItem>,
ofile: Option<&Path>) {
let dep_graph = DepGraph::new(false);
let _ignore = dep_graph.in_ignore();
if ppm.needs_analysis() {
print_with_analysis(sess,
cstore,