Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
acca8189
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
acca8189
编写于
3月 13, 2021
作者:
B
bors
浏览文件
操作
浏览文件
下载
差异文件
Auto merge of #83064 - cjgillot:fhash, r=jackh726
Tweaks to stable hashing
上级
e7e1dc15
34e92bbf
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
18 addition
and
20 deletion
+18
-20
compiler/rustc_data_structures/src/stable_hasher.rs
compiler/rustc_data_structures/src/stable_hasher.rs
+1
-0
compiler/rustc_macros/src/hash_stable.rs
compiler/rustc_macros/src/hash_stable.rs
+2
-0
compiler/rustc_middle/src/ich/hcx.rs
compiler/rustc_middle/src/ich/hcx.rs
+0
-7
compiler/rustc_span/src/hygiene.rs
compiler/rustc_span/src/hygiene.rs
+0
-6
compiler/rustc_span/src/lib.rs
compiler/rustc_span/src/lib.rs
+2
-7
library/core/src/hash/mod.rs
library/core/src/hash/mod.rs
+13
-0
未找到文件。
compiler/rustc_data_structures/src/stable_hasher.rs
浏览文件 @
acca8189
...
...
@@ -35,6 +35,7 @@ pub fn new() -> Self {
StableHasher
{
state
:
SipHasher128
::
new_with_keys
(
0
,
0
)
}
}
#[inline]
pub
fn
finish
<
W
:
StableHasherResult
>
(
self
)
->
W
{
W
::
finish
(
self
)
}
...
...
compiler/rustc_macros/src/hash_stable.rs
浏览文件 @
acca8189
...
...
@@ -74,6 +74,7 @@ pub fn hash_stable_generic_derive(mut s: synstructure::Structure<'_>) -> proc_ma
s
.bound_impl
(
quote!
(::
rustc_data_structures
::
stable_hasher
::
HashStable
<
__
CTX
>
),
quote!
{
#[inline]
fn
hash_stable
(
&
self
,
__
hcx
:
&
mut
__
CTX
,
...
...
@@ -119,6 +120,7 @@ pub fn hash_stable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::To
>
),
quote!
{
#[inline]
fn
hash_stable
(
&
self
,
__
hcx
:
&
mut
::
rustc_middle
::
ich
::
StableHashingContext
<
'__ctx
>
,
...
...
compiler/rustc_middle/src/ich/hcx.rs
浏览文件 @
acca8189
...
...
@@ -250,13 +250,6 @@ fn expn_id_cache() -> &'static LocalKey<rustc_span::ExpnIdCache> {
&
CACHE
}
fn
byte_pos_to_line_and_col
(
&
mut
self
,
byte
:
BytePos
,
)
->
Option
<
(
Lrc
<
SourceFile
>
,
usize
,
BytePos
)
>
{
self
.source_map
()
.byte_pos_to_line_and_col
(
byte
)
}
fn
span_data_to_lines_and_cols
(
&
mut
self
,
span
:
&
SpanData
,
...
...
compiler/rustc_span/src/hygiene.rs
浏览文件 @
acca8189
...
...
@@ -1362,12 +1362,6 @@ fn hash_crate_num(&mut self, krate: CrateNum, hasher: &mut StableHasher) {
fn
hash_spans
(
&
self
)
->
bool
{
true
}
fn
byte_pos_to_line_and_col
(
&
mut
self
,
byte
:
BytePos
,
)
->
Option
<
(
Lrc
<
SourceFile
>
,
usize
,
BytePos
)
>
{
self
.caching_source_map
.byte_pos_to_line_and_col
(
byte
)
}
fn
span_data_to_lines_and_cols
(
&
mut
self
,
span
:
&
crate
::
SpanData
,
...
...
compiler/rustc_span/src/lib.rs
浏览文件 @
acca8189
...
...
@@ -1874,10 +1874,6 @@ pub trait HashStableContext {
fn
expn_id_cache
()
->
&
'static
LocalKey
<
ExpnIdCache
>
;
fn
hash_crate_num
(
&
mut
self
,
_
:
CrateNum
,
hasher
:
&
mut
StableHasher
);
fn
hash_spans
(
&
self
)
->
bool
;
fn
byte_pos_to_line_and_col
(
&
mut
self
,
byte
:
BytePos
,
)
->
Option
<
(
Lrc
<
SourceFile
>
,
usize
,
BytePos
)
>
;
fn
span_data_to_lines_and_cols
(
&
mut
self
,
span
:
&
SpanData
,
...
...
@@ -1906,9 +1902,10 @@ fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
return
;
}
self
.ctxt
()
.hash_stable
(
ctx
,
hasher
);
if
self
.is_dummy
()
{
Hash
::
hash
(
&
TAG_INVALID_SPAN
,
hasher
);
self
.ctxt
()
.hash_stable
(
ctx
,
hasher
);
return
;
}
...
...
@@ -1921,7 +1918,6 @@ fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
Some
(
pos
)
=>
pos
,
None
=>
{
Hash
::
hash
(
&
TAG_INVALID_SPAN
,
hasher
);
span
.ctxt
.hash_stable
(
ctx
,
hasher
);
return
;
}
};
...
...
@@ -1948,7 +1944,6 @@ fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
let
len
=
(
span
.hi
-
span
.lo
)
.0
;
Hash
::
hash
(
&
col_line
,
hasher
);
Hash
::
hash
(
&
len
,
hasher
);
span
.ctxt
.hash_stable
(
ctx
,
hasher
);
}
}
...
...
library/core/src/hash/mod.rs
浏览文件 @
acca8189
...
...
@@ -548,10 +548,12 @@ mod impls {
(
$
((
$ty:ident
,
$meth:ident
),)
*
)
=>
{
$
(
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
Hash
for
$ty
{
#[inline]
fn
hash
<
H
:
Hasher
>
(
&
self
,
state
:
&
mut
H
)
{
state
.
$meth
(
*
self
)
}
#[inline]
fn
hash_slice
<
H
:
Hasher
>
(
data
:
&
[
$ty
],
state
:
&
mut
H
)
{
let
newlen
=
data
.len
()
*
mem
::
size_of
::
<
$ty
>
();
let
ptr
=
data
.as_ptr
()
as
*
const
u8
;
...
...
@@ -582,6 +584,7 @@ fn hash_slice<H: Hasher>(data: &[$ty], state: &mut H) {
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
Hash
for
bool
{
#[inline]
fn
hash
<
H
:
Hasher
>
(
&
self
,
state
:
&
mut
H
)
{
state
.write_u8
(
*
self
as
u8
)
}
...
...
@@ -589,6 +592,7 @@ fn hash<H: Hasher>(&self, state: &mut H) {
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
Hash
for
char
{
#[inline]
fn
hash
<
H
:
Hasher
>
(
&
self
,
state
:
&
mut
H
)
{
state
.write_u32
(
*
self
as
u32
)
}
...
...
@@ -596,6 +600,7 @@ fn hash<H: Hasher>(&self, state: &mut H) {
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
Hash
for
str
{
#[inline]
fn
hash
<
H
:
Hasher
>
(
&
self
,
state
:
&
mut
H
)
{
state
.write
(
self
.as_bytes
());
state
.write_u8
(
0xff
)
...
...
@@ -604,6 +609,7 @@ fn hash<H: Hasher>(&self, state: &mut H) {
#[stable(feature
=
"never_hash"
,
since
=
"1.29.0"
)]
impl
Hash
for
!
{
#[inline]
fn
hash
<
H
:
Hasher
>
(
&
self
,
_
:
&
mut
H
)
{
*
self
}
...
...
@@ -613,6 +619,7 @@ fn hash<H: Hasher>(&self, _: &mut H) {
()
=>
(
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
Hash
for
()
{
#[inline]
fn
hash
<
H
:
Hasher
>
(
&
self
,
_
state
:
&
mut
H
)
{}
}
);
...
...
@@ -621,6 +628,7 @@ fn hash<H: Hasher>(&self, _state: &mut H) {}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
$
(
$name
:
Hash
),
+>
Hash
for
(
$
(
$name
,)
+
)
where
last_type!
(
$
(
$name
,)
+
):
?
Sized
{
#[allow(non_snake_case)]
#[inline]
fn
hash
<
S
:
Hasher
>
(
&
self
,
state
:
&
mut
S
)
{
let
(
$
(
ref
$name
,)
+
)
=
*
self
;
$
(
$name
.hash
(
state
);)
+
...
...
@@ -650,6 +658,7 @@ fn hash<S: Hasher>(&self, state: &mut S) {
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
T
:
Hash
>
Hash
for
[
T
]
{
#[inline]
fn
hash
<
H
:
Hasher
>
(
&
self
,
state
:
&
mut
H
)
{
self
.len
()
.hash
(
state
);
Hash
::
hash_slice
(
self
,
state
)
...
...
@@ -658,6 +667,7 @@ fn hash<H: Hasher>(&self, state: &mut H) {
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
T
:
?
Sized
+
Hash
>
Hash
for
&
T
{
#[inline]
fn
hash
<
H
:
Hasher
>
(
&
self
,
state
:
&
mut
H
)
{
(
**
self
)
.hash
(
state
);
}
...
...
@@ -665,6 +675,7 @@ fn hash<H: Hasher>(&self, state: &mut H) {
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
T
:
?
Sized
+
Hash
>
Hash
for
&
mut
T
{
#[inline]
fn
hash
<
H
:
Hasher
>
(
&
self
,
state
:
&
mut
H
)
{
(
**
self
)
.hash
(
state
);
}
...
...
@@ -672,6 +683,7 @@ fn hash<H: Hasher>(&self, state: &mut H) {
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
T
:
?
Sized
>
Hash
for
*
const
T
{
#[inline]
fn
hash
<
H
:
Hasher
>
(
&
self
,
state
:
&
mut
H
)
{
#[cfg(not(bootstrap))]
{
...
...
@@ -701,6 +713,7 @@ fn hash<H: Hasher>(&self, state: &mut H) {
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
T
:
?
Sized
>
Hash
for
*
mut
T
{
#[inline]
fn
hash
<
H
:
Hasher
>
(
&
self
,
state
:
&
mut
H
)
{
#[cfg(not(bootstrap))]
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录