mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 22:41:50 +00:00
Adjust assert_default_hashing_controls
This commit is contained in:
parent
5580e5e1dd
commit
560c90f5df
@ -27,6 +27,7 @@ fn compute_ignored_attr_names() -> FxHashSet<Symbol> {
|
|||||||
pub struct StableHashingContext<'a> {
|
pub struct StableHashingContext<'a> {
|
||||||
definitions: &'a Definitions,
|
definitions: &'a Definitions,
|
||||||
cstore: &'a dyn CrateStore,
|
cstore: &'a dyn CrateStore,
|
||||||
|
sess: &'a Session,
|
||||||
pub(super) body_resolver: BodyResolver<'a>,
|
pub(super) body_resolver: BodyResolver<'a>,
|
||||||
// Very often, we are hashing something that does not need the
|
// Very often, we are hashing something that does not need the
|
||||||
// `CachingSourceMapView`, so we initialize it lazily.
|
// `CachingSourceMapView`, so we initialize it lazily.
|
||||||
@ -63,6 +64,7 @@ impl<'a> StableHashingContext<'a> {
|
|||||||
body_resolver: BodyResolver::Forbidden,
|
body_resolver: BodyResolver::Forbidden,
|
||||||
definitions,
|
definitions,
|
||||||
cstore,
|
cstore,
|
||||||
|
sess,
|
||||||
caching_source_map: None,
|
caching_source_map: None,
|
||||||
raw_source_map: sess.source_map(),
|
raw_source_map: sess.source_map(),
|
||||||
hashing_controls: HashingControls {
|
hashing_controls: HashingControls {
|
||||||
@ -197,6 +199,11 @@ impl<'a> rustc_span::HashStableContext for StableHashingContext<'a> {
|
|||||||
self.hashing_controls.hash_spans
|
self.hashing_controls.hash_spans
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn debug_opts_incremental_ignore_spans(&self) -> bool {
|
||||||
|
self.sess.opts.debugging_opts.incremental_ignore_spans
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn def_path_hash(&self, def_id: DefId) -> DefPathHash {
|
fn def_path_hash(&self, def_id: DefId) -> DefPathHash {
|
||||||
self.def_path_hash(def_id)
|
self.def_path_hash(def_id)
|
||||||
|
@ -89,11 +89,11 @@ rustc_index::newtype_index! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assert that the provided `HashStableContext` is configured with the 'default'
|
/// Assert that the provided `HashStableContext` is configured with the 'default'
|
||||||
// `HashingControls`. We should always have bailed out before getting to here
|
/// `HashingControls`. We should always have bailed out before getting to here
|
||||||
// with a non-default mode. With this check in place, we can avoid the need
|
/// with a non-default mode. With this check in place, we can avoid the need
|
||||||
// to maintain separate versions of `ExpnData` hashes for each permutation
|
/// to maintain separate versions of `ExpnData` hashes for each permutation
|
||||||
// of `HashingControls` settings.
|
/// of `HashingControls` settings.
|
||||||
fn assert_default_hashing_controls<CTX: HashStableContext>(ctx: &CTX, msg: &str) {
|
fn assert_default_hashing_controls<CTX: HashStableContext>(ctx: &CTX, msg: &str) {
|
||||||
match ctx.hashing_controls() {
|
match ctx.hashing_controls() {
|
||||||
// Ideally, we would also check that `node_id_hashing_mode` was always
|
// Ideally, we would also check that `node_id_hashing_mode` was always
|
||||||
@ -105,7 +105,13 @@ fn assert_default_hashing_controls<CTX: HashStableContext>(ctx: &CTX, msg: &str)
|
|||||||
// FIXME: Enforce that we don't end up transitively hashing any `HirId`s,
|
// FIXME: Enforce that we don't end up transitively hashing any `HirId`s,
|
||||||
// or ensure that this method is always invoked with the same
|
// or ensure that this method is always invoked with the same
|
||||||
// `NodeIdHashingMode`
|
// `NodeIdHashingMode`
|
||||||
HashingControls { hash_spans: true, node_id_hashing_mode: _ } => {}
|
//
|
||||||
|
// Note that we require that `hash_spans` be set according to the global
|
||||||
|
// `-Z incremental-ignore-spans` option. Normally, this option is disabled,
|
||||||
|
// which will cause us to require that this method always be called with `Span` hashing
|
||||||
|
// enabled.
|
||||||
|
HashingControls { hash_spans, node_id_hashing_mode: _ }
|
||||||
|
if hash_spans == !ctx.debug_opts_incremental_ignore_spans() => {}
|
||||||
other => panic!("Attempted hashing of {msg} with non-default HashingControls: {:?}", other),
|
other => panic!("Attempted hashing of {msg} with non-default HashingControls: {:?}", other),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2058,6 +2058,9 @@ impl InnerSpan {
|
|||||||
pub trait HashStableContext {
|
pub trait HashStableContext {
|
||||||
fn def_path_hash(&self, def_id: DefId) -> DefPathHash;
|
fn def_path_hash(&self, def_id: DefId) -> DefPathHash;
|
||||||
fn hash_spans(&self) -> bool;
|
fn hash_spans(&self) -> bool;
|
||||||
|
/// Accesses `sess.opts.debugging_opts.incremental_ignore_spans` since
|
||||||
|
/// we don't have easy access to a `Session`
|
||||||
|
fn debug_opts_incremental_ignore_spans(&self) -> bool;
|
||||||
fn def_span(&self, def_id: LocalDefId) -> Span;
|
fn def_span(&self, def_id: LocalDefId) -> Span;
|
||||||
fn span_data_to_lines_and_cols(
|
fn span_data_to_lines_and_cols(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
Loading…
Reference in New Issue
Block a user