diff --git a/Cargo.lock b/Cargo.lock index bada67eda44..eadac99787f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4308,13 +4308,17 @@ dependencies = [ "parking_lot", "rustc-rayon-core", "rustc_arena", + "rustc_ast", "rustc_data_structures", "rustc_errors", + "rustc_feature", + "rustc_hir", "rustc_index", "rustc_macros", "rustc_serialize", "rustc_session", "rustc_span", + "rustc_target", "smallvec", "tracing", ] diff --git a/compiler/rustc_middle/src/ich.rs b/compiler/rustc_middle/src/ich.rs new file mode 100644 index 00000000000..f0b869558bc --- /dev/null +++ b/compiler/rustc_middle/src/ich.rs @@ -0,0 +1,5 @@ +//! ICH - Incremental Compilation Hash + +pub use rustc_query_system::ich::{NodeIdHashingMode, StableHashingContext}; + +mod impls_ty; diff --git a/compiler/rustc_middle/src/ich/impls_ty.rs b/compiler/rustc_middle/src/ich/impls_ty.rs index 3b0640eb98d..97106b58e0a 100644 --- a/compiler/rustc_middle/src/ich/impls_ty.rs +++ b/compiler/rustc_middle/src/ich/impls_ty.rs @@ -1,7 +1,7 @@ //! This module contains `HashStable` implementations for various data types //! from `rustc_middle::ty` in no particular order. -use crate::ich::{NodeIdHashingMode, StableHashingContext}; +use crate::ich::StableHashingContext; use crate::middle::region; use crate::mir; use crate::ty; @@ -163,37 +163,3 @@ impl<'a> ToStableHashKey> for region::Scope { *self } } - -impl<'a> HashStable> for ty::TyVid { - fn hash_stable(&self, _hcx: &mut StableHashingContext<'a>, _hasher: &mut StableHasher) { - // `TyVid` values are confined to an inference context and hence - // should not be hashed. - bug!("ty::TyKind::hash_stable() - can't hash a TyVid {:?}.", *self) - } -} - -impl<'a> HashStable> for ty::IntVid { - fn hash_stable(&self, _hcx: &mut StableHashingContext<'a>, _hasher: &mut StableHasher) { - // `IntVid` values are confined to an inference context and hence - // should not be hashed. - bug!("ty::TyKind::hash_stable() - can't hash an IntVid {:?}.", *self) - } -} - -impl<'a> HashStable> for ty::FloatVid { - fn hash_stable(&self, _hcx: &mut StableHashingContext<'a>, _hasher: &mut StableHasher) { - // `FloatVid` values are confined to an inference context and hence - // should not be hashed. - bug!("ty::TyKind::hash_stable() - can't hash a FloatVid {:?}.", *self) - } -} - -impl<'a> HashStable> for crate::middle::privacy::AccessLevels { - fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| { - let crate::middle::privacy::AccessLevels { ref map } = *self; - - map.hash_stable(hcx, hasher); - }); - } -} diff --git a/compiler/rustc_middle/src/middle/privacy.rs b/compiler/rustc_middle/src/middle/privacy.rs index a11ca74b25e..f33bd3438b9 100644 --- a/compiler/rustc_middle/src/middle/privacy.rs +++ b/compiler/rustc_middle/src/middle/privacy.rs @@ -3,7 +3,9 @@ //! which are available for use externally when compiled as a library. use rustc_data_structures::fx::FxHashMap; +use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_macros::HashStable; +use rustc_query_system::ich::{NodeIdHashingMode, StableHashingContext}; use rustc_span::def_id::LocalDefId; use std::hash::Hash; @@ -53,3 +55,12 @@ impl Default for AccessLevels { AccessLevels { map: Default::default() } } } + +impl<'a> HashStable> for AccessLevels { + fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { + hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| { + let AccessLevels { ref map } = *self; + map.hash_stable(hcx, hasher); + }); + } +} diff --git a/compiler/rustc_query_system/Cargo.toml b/compiler/rustc_query_system/Cargo.toml index 11c18a497e5..898a8caa3ca 100644 --- a/compiler/rustc_query_system/Cargo.toml +++ b/compiler/rustc_query_system/Cargo.toml @@ -10,12 +10,16 @@ doctest = false rustc_arena = { path = "../rustc_arena" } tracing = "0.1" rustc-rayon-core = "0.3.1" +rustc_ast = { path = "../rustc_ast" } rustc_data_structures = { path = "../rustc_data_structures" } rustc_errors = { path = "../rustc_errors" } -rustc_macros = { path = "../rustc_macros" } +rustc_feature = { path = "../rustc_feature" } +rustc_hir = { path = "../rustc_hir" } rustc_index = { path = "../rustc_index" } +rustc_macros = { path = "../rustc_macros" } rustc_serialize = { path = "../rustc_serialize" } rustc_session = { path = "../rustc_session" } rustc_span = { path = "../rustc_span" } +rustc_target = { path = "../rustc_target" } parking_lot = "0.11" smallvec = { version = "1.6.1", features = ["union", "may_dangle"] } diff --git a/compiler/rustc_middle/src/ich/hcx.rs b/compiler/rustc_query_system/src/ich/hcx.rs similarity index 98% rename from compiler/rustc_middle/src/ich/hcx.rs rename to compiler/rustc_query_system/src/ich/hcx.rs index 98dcd62f795..d3e5189ce76 100644 --- a/compiler/rustc_middle/src/ich/hcx.rs +++ b/compiler/rustc_query_system/src/ich/hcx.rs @@ -206,4 +206,4 @@ impl<'a> rustc_span::HashStableContext for StableHashingContext<'a> { } } -impl rustc_session::HashStableContext for StableHashingContext<'a> {} +impl<'a> rustc_session::HashStableContext for StableHashingContext<'a> {} diff --git a/compiler/rustc_middle/src/ich/impls_hir.rs b/compiler/rustc_query_system/src/ich/impls_hir.rs similarity index 100% rename from compiler/rustc_middle/src/ich/impls_hir.rs rename to compiler/rustc_query_system/src/ich/impls_hir.rs diff --git a/compiler/rustc_middle/src/ich/impls_syntax.rs b/compiler/rustc_query_system/src/ich/impls_syntax.rs similarity index 100% rename from compiler/rustc_middle/src/ich/impls_syntax.rs rename to compiler/rustc_query_system/src/ich/impls_syntax.rs diff --git a/compiler/rustc_middle/src/ich/mod.rs b/compiler/rustc_query_system/src/ich/mod.rs similarity index 96% rename from compiler/rustc_middle/src/ich/mod.rs rename to compiler/rustc_query_system/src/ich/mod.rs index c91b6a8540b..54416902e5f 100644 --- a/compiler/rustc_middle/src/ich/mod.rs +++ b/compiler/rustc_query_system/src/ich/mod.rs @@ -4,10 +4,8 @@ pub use self::hcx::{NodeIdHashingMode, StableHashingContext}; use rustc_span::symbol::{sym, Symbol}; mod hcx; - mod impls_hir; mod impls_syntax; -mod impls_ty; pub const IGNORED_ATTRIBUTES: &[Symbol] = &[ sym::cfg, diff --git a/compiler/rustc_query_system/src/lib.rs b/compiler/rustc_query_system/src/lib.rs index c205f0fb531..bc23de069b0 100644 --- a/compiler/rustc_query_system/src/lib.rs +++ b/compiler/rustc_query_system/src/lib.rs @@ -1,3 +1,4 @@ +#![feature(assert_matches)] #![feature(bool_to_option)] #![feature(core_intrinsics)] #![feature(hash_raw_entry)] @@ -14,4 +15,5 @@ extern crate rustc_macros; pub mod cache; pub mod dep_graph; +pub mod ich; pub mod query; diff --git a/compiler/rustc_session/src/lib.rs b/compiler/rustc_session/src/lib.rs index d5f887f935b..6c86f86ecd9 100644 --- a/compiler/rustc_session/src/lib.rs +++ b/compiler/rustc_session/src/lib.rs @@ -1,4 +1,5 @@ #![feature(crate_visibility_modifier)] +#![feature(min_specialization)] #![feature(once_cell)] #![recursion_limit = "256"]