Do not clone Arc when hashing span.
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_data_structures::stable_hasher::{HashStable, HashingControls, StableHasher};
|
use rustc_data_structures::stable_hasher::{HashStable, HashingControls, StableHasher};
|
||||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||||
@@ -7,7 +5,9 @@ use rustc_hir::definitions::DefPathHash;
|
|||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
use rustc_session::cstore::Untracked;
|
use rustc_session::cstore::Untracked;
|
||||||
use rustc_span::source_map::SourceMap;
|
use rustc_span::source_map::SourceMap;
|
||||||
use rustc_span::{BytePos, CachingSourceMapView, DUMMY_SP, SourceFile, Span, SpanData, Symbol};
|
use rustc_span::{
|
||||||
|
BytePos, CachingSourceMapView, DUMMY_SP, Span, SpanData, StableSourceFileId, Symbol,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::ich;
|
use crate::ich;
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ impl<'a> rustc_span::HashStableContext for StableHashingContext<'a> {
|
|||||||
fn span_data_to_lines_and_cols(
|
fn span_data_to_lines_and_cols(
|
||||||
&mut self,
|
&mut self,
|
||||||
span: &SpanData,
|
span: &SpanData,
|
||||||
) -> Option<(Arc<SourceFile>, usize, BytePos, usize, BytePos)> {
|
) -> Option<(StableSourceFileId, usize, BytePos, usize, BytePos)> {
|
||||||
self.source_map().span_data_to_lines_and_cols(span)
|
self.source_map().span_data_to_lines_and_cols(span)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use std::ops::Range;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::source_map::SourceMap;
|
use crate::source_map::SourceMap;
|
||||||
use crate::{BytePos, Pos, RelativeBytePos, SourceFile, SpanData};
|
use crate::{BytePos, Pos, RelativeBytePos, SourceFile, SpanData, StableSourceFileId};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct CacheEntry {
|
struct CacheEntry {
|
||||||
@@ -114,7 +114,7 @@ impl<'sm> CachingSourceMapView<'sm> {
|
|||||||
pub fn span_data_to_lines_and_cols(
|
pub fn span_data_to_lines_and_cols(
|
||||||
&mut self,
|
&mut self,
|
||||||
span_data: &SpanData,
|
span_data: &SpanData,
|
||||||
) -> Option<(Arc<SourceFile>, usize, BytePos, usize, BytePos)> {
|
) -> Option<(StableSourceFileId, usize, BytePos, usize, BytePos)> {
|
||||||
self.time_stamp += 1;
|
self.time_stamp += 1;
|
||||||
|
|
||||||
// Check if lo and hi are in the cached lines.
|
// Check if lo and hi are in the cached lines.
|
||||||
@@ -132,7 +132,7 @@ impl<'sm> CachingSourceMapView<'sm> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
(
|
(
|
||||||
Arc::clone(&lo.file),
|
lo.file.stable_id,
|
||||||
lo.line_number,
|
lo.line_number,
|
||||||
span_data.lo - lo.line.start,
|
span_data.lo - lo.line.start,
|
||||||
hi.line_number,
|
hi.line_number,
|
||||||
@@ -226,7 +226,7 @@ impl<'sm> CachingSourceMapView<'sm> {
|
|||||||
assert_eq!(lo.file_index, hi.file_index);
|
assert_eq!(lo.file_index, hi.file_index);
|
||||||
|
|
||||||
Some((
|
Some((
|
||||||
Arc::clone(&lo.file),
|
lo.file.stable_id,
|
||||||
lo.line_number,
|
lo.line_number,
|
||||||
span_data.lo - lo.line.start,
|
span_data.lo - lo.line.start,
|
||||||
hi.line_number,
|
hi.line_number,
|
||||||
|
|||||||
@@ -2600,7 +2600,7 @@ pub trait HashStableContext {
|
|||||||
fn span_data_to_lines_and_cols(
|
fn span_data_to_lines_and_cols(
|
||||||
&mut self,
|
&mut self,
|
||||||
span: &SpanData,
|
span: &SpanData,
|
||||||
) -> Option<(Arc<SourceFile>, usize, BytePos, usize, BytePos)>;
|
) -> Option<(StableSourceFileId, usize, BytePos, usize, BytePos)>;
|
||||||
fn hashing_controls(&self) -> HashingControls;
|
fn hashing_controls(&self) -> HashingControls;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2657,7 +2657,7 @@ where
|
|||||||
};
|
};
|
||||||
|
|
||||||
Hash::hash(&TAG_VALID_SPAN, hasher);
|
Hash::hash(&TAG_VALID_SPAN, hasher);
|
||||||
Hash::hash(&file.stable_id, hasher);
|
Hash::hash(&file, hasher);
|
||||||
|
|
||||||
// Hash both the length and the end location (line/column) of a span. If we
|
// Hash both the length and the end location (line/column) of a span. If we
|
||||||
// hash only the length, for example, then two otherwise equal spans with
|
// hash only the length, for example, then two otherwise equal spans with
|
||||||
|
|||||||
Reference in New Issue
Block a user