Move SVH structure to data structures

This commit is contained in:
Mark Rousskov 2018-08-03 12:22:22 -06:00
parent b73535f1e9
commit bf103700c6
14 changed files with 31 additions and 16 deletions

View File

@ -12,7 +12,7 @@ use super::*;
use dep_graph::{DepGraph, DepKind, DepNodeIndex};
use hir::def_id::{LOCAL_CRATE, CrateNum};
use hir::intravisit::{Visitor, NestedVisitorMap};
use hir::svh::Svh;
use rustc_data_structures::svh::Svh;
use ich::Fingerprint;
use middle::cstore::CrateStore;
use session::CrateDisambiguator;

View File

@ -22,6 +22,7 @@ use hir::def_id::{CRATE_DEF_INDEX, DefId, LocalDefId, DefIndexAddressSpace};
use middle::cstore::CrateStore;
use rustc_target::spec::abi::Abi;
use rustc_data_structures::svh::Svh;
use syntax::ast::{self, Name, NodeId, CRATE_NODE_ID};
use syntax::codemap::Spanned;
use syntax::ext::base::MacroKind;
@ -29,7 +30,6 @@ use syntax_pos::{Span, DUMMY_SP};
use hir::*;
use hir::print::Nested;
use hir::svh::Svh;
use util::nodemap::FxHashMap;
use std::io;

View File

@ -70,7 +70,6 @@ pub mod lowering;
pub mod map;
pub mod pat_util;
pub mod print;
pub mod svh;
/// A HirId uniquely identifies a node in the HIR of the current crate. It is
/// composed of the `owner`, which is the DefIndex of the directly enclosing

View File

@ -25,7 +25,7 @@
use hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
use hir::map as hir_map;
use hir::map::definitions::{DefKey, DefPathTable};
use hir::svh::Svh;
use rustc_data_structures::svh::Svh;
use ty::{self, TyCtxt};
use session::{Session, CrateDisambiguator};
use session::search_paths::PathKind;

View File

@ -18,7 +18,7 @@ use hir::{map as hir_map, FreevarMap, TraitMap};
use hir::def::{Def, CtorKind, ExportMap};
use hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE};
use hir::map::DefPathData;
use hir::svh::Svh;
use rustc_data_structures::svh::Svh;
use ich::Fingerprint;
use ich::StableHashingContext;
use infer::canonical::Canonical;

View File

@ -13,7 +13,7 @@ use errors::DiagnosticBuilder;
use hir::def_id::{CrateNum, DefId, DefIndex};
use hir::def::{Def, Export};
use hir::{self, TraitCandidate, ItemLocalId, CodegenFnAttrs};
use hir::svh::Svh;
use rustc_data_structures::svh::Svh;
use infer::canonical::{self, Canonical};
use lint;
use middle::borrowck::BorrowCheckResult;

View File

@ -11,7 +11,7 @@
use rustc::session::config::{self, OutputFilenames, Input, OutputType};
use rustc::session::Session;
use rustc::middle::cstore::LinkMeta;
use rustc::hir::svh::Svh;
use rustc_data_structures::svh::Svh;
use std::path::{Path, PathBuf};
use syntax::{ast, attr};
use syntax_pos::Span;

View File

@ -46,6 +46,7 @@ extern crate stable_deref_trait;
extern crate rustc_rayon as rayon;
extern crate rustc_rayon_core as rayon_core;
extern crate rustc_hash;
extern crate serialize;
// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
#[allow(unused_extern_crates)]
@ -53,6 +54,7 @@ extern crate rustc_cratesio_shim;
pub use rustc_serialize::hex::ToHex;
pub mod svh;
pub mod accumulate_vec;
pub mod array_vec;
pub mod base_n;

View File

@ -19,6 +19,8 @@ use std::fmt;
use std::hash::{Hash, Hasher};
use serialize::{Encodable, Decodable, Encoder, Decoder};
use stable_hasher;
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct Svh {
hash: u64,
@ -67,6 +69,16 @@ impl Decodable for Svh {
}
}
impl_stable_hash_for!(struct Svh {
hash
});
impl<T> stable_hasher::HashStable<T> for Svh {
#[inline]
fn hash_stable<W: stable_hasher::StableHasherResult>(
&self,
ctx: &mut T,
hasher: &mut stable_hasher::StableHasher<W>
) {
let Svh {
hash
} = *self;
hash.hash_stable(ctx, hasher);
}
}

View File

@ -114,11 +114,11 @@
//! unsupported file system and emit a warning in that case. This is not yet
//! implemented.
use rustc::hir::svh::Svh;
use rustc::session::{Session, CrateDisambiguator};
use rustc::util::fs as fs_util;
use rustc_data_structures::{flock, base_n};
use rustc_data_structures::fx::{FxHashSet, FxHashMap};
use rustc_data_structures::svh::Svh;
use std::fs as std_fs;
use std::io;

View File

@ -16,7 +16,7 @@ use schema::CrateRoot;
use rustc_data_structures::sync::{Lrc, RwLock, Lock};
use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX};
use rustc::hir::svh::Svh;
use rustc_data_structures::svh::Svh;
use rustc::middle::allocator::AllocatorKind;
use rustc::middle::cstore::DepKind;
use rustc::mir::interpret::AllocDecodingState;

View File

@ -30,6 +30,7 @@ use rustc::hir::map::{DefKey, DefPath, DefPathHash};
use rustc::hir::map::blocks::FnLikeNode;
use rustc::hir::map::definitions::DefPathTable;
use rustc::util::nodemap::DefIdMap;
use rustc_data_structures::svh::Svh;
use std::any::Any;
use rustc_data_structures::sync::Lrc;
@ -515,7 +516,7 @@ impl CrateStore for cstore::CStore {
self.get_crate_data(cnum).root.disambiguator
}
fn crate_hash_untracked(&self, cnum: CrateNum) -> hir::svh::Svh
fn crate_hash_untracked(&self, cnum: CrateNum) -> Svh
{
self.get_crate_data(cnum).root.hash
}

View File

@ -226,7 +226,7 @@ use cstore::{MetadataRef, MetadataBlob};
use creader::Library;
use schema::{METADATA_HEADER, rustc_version};
use rustc::hir::svh::Svh;
use rustc_data_structures::svh::Svh;
use rustc::middle::cstore::MetadataLoader;
use rustc::session::{config, Session};
use rustc::session::filesearch::{FileSearch, FileMatches, FileDoesntMatch};

View File

@ -20,6 +20,7 @@ use rustc::mir;
use rustc::session::CrateDisambiguator;
use rustc::ty::{self, Ty, ReprOptions};
use rustc_target::spec::{PanicStrategy, TargetTriple};
use rustc_data_structures::svh::Svh;
use rustc_serialize as serialize;
use syntax::{ast, attr};
@ -187,7 +188,7 @@ pub struct CrateRoot {
pub name: Symbol,
pub triple: TargetTriple,
pub extra_filename: String,
pub hash: hir::svh::Svh,
pub hash: Svh,
pub disambiguator: CrateDisambiguator,
pub panic_strategy: PanicStrategy,
pub edition: Edition,
@ -223,7 +224,7 @@ pub struct CrateRoot {
#[derive(RustcEncodable, RustcDecodable)]
pub struct CrateDep {
pub name: ast::Name,
pub hash: hir::svh::Svh,
pub hash: Svh,
pub kind: DepKind,
pub extra_filename: String,
}