Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
97431a40
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,发现更多精彩内容 >>
提交
97431a40
编写于
12月 03, 2018
作者:
J
John Kåre Alsaker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Create a derive macro for HashStable
上级
a9da8fc9
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
63 addition
and
7 deletion
+63
-7
src/librustc/Cargo.toml
src/librustc/Cargo.toml
+1
-0
src/librustc/hir/mod.rs
src/librustc/hir/mod.rs
+2
-1
src/librustc/ich/impls_hir.rs
src/librustc/ich/impls_hir.rs
+0
-6
src/librustc/lib.rs
src/librustc/lib.rs
+1
-0
src/librustc_macros/Cargo.toml
src/librustc_macros/Cargo.toml
+13
-0
src/librustc_macros/src/hash_stable.rs
src/librustc_macros/src/hash_stable.rs
+31
-0
src/librustc_macros/src/lib.rs
src/librustc_macros/src/lib.rs
+14
-0
src/tools/tidy/src/deps.rs
src/tools/tidy/src/deps.rs
+1
-0
未找到文件。
src/librustc/Cargo.toml
浏览文件 @
97431a40
...
...
@@ -24,6 +24,7 @@ rustc-rayon = "0.1.2"
rustc-rayon-core
=
"0.1.2"
rustc_apfloat
=
{
path
=
"../librustc_apfloat"
}
rustc_target
=
{
path
=
"../librustc_target"
}
rustc_macros
=
{
path
=
"../librustc_macros"
}
rustc_data_structures
=
{
path
=
"../librustc_data_structures"
}
errors
=
{
path
=
"../librustc_errors"
,
package
=
"rustc_errors"
}
serialize
=
{
path
=
"../libserialize"
}
...
...
src/librustc/hir/mod.rs
浏览文件 @
97431a40
...
...
@@ -32,6 +32,7 @@
use
rustc_data_structures
::
sync
::{
ParallelIterator
,
par_iter
,
Send
,
Sync
};
use
rustc_data_structures
::
thin_vec
::
ThinVec
;
use
rustc_macros
::
HashStable
;
use
serialize
::{
self
,
Encoder
,
Encodable
,
Decoder
,
Decodable
};
use
std
::
collections
::{
BTreeSet
,
BTreeMap
};
...
...
@@ -149,7 +150,7 @@ pub struct ItemLocalId { .. }
pub
const
DUMMY_ITEM_LOCAL_ID
:
ItemLocalId
=
ItemLocalId
::
MAX
;
#[derive(Clone,
RustcEncodable,
RustcDecodable,
Copy)]
#[derive(Clone,
RustcEncodable,
RustcDecodable,
Copy
,
HashStable
)]
pub
struct
Lifetime
{
pub
hir_id
:
HirId
,
pub
span
:
Span
,
...
...
src/librustc/ich/impls_hir.rs
浏览文件 @
97431a40
...
...
@@ -157,12 +157,6 @@ fn hash_stable<W: StableHasherResult>(&self,
ident
});
impl_stable_hash_for!
(
struct
hir
::
Lifetime
{
hir_id
,
span
,
name
});
impl_stable_hash_for!
(
struct
hir
::
Path
{
span
,
def
,
...
...
src/librustc/lib.rs
浏览文件 @
97431a40
...
...
@@ -148,6 +148,7 @@ pub mod util {
#[doc(hidden)]
mod
rustc
{
pub
use
crate
::
lint
;
pub
use
crate
::
ich
;
}
// FIXME(#27438): right now the unit tests of librustc don't refer to any actual
...
...
src/librustc_macros/Cargo.toml
0 → 100644
浏览文件 @
97431a40
[package]
name
=
"rustc_macros"
version
=
"0.1.0"
authors
=
[
"The Rust Project Developers"
]
[lib]
proc-macro
=
true
[dependencies]
synstructure
=
"0.10.1"
syn
=
{
version
=
"0.15.22"
,
features
=
["full"]
}
proc-macro2
=
"0.4.24"
quote
=
"0.6.10"
\ No newline at end of file
src/librustc_macros/src/hash_stable.rs
0 → 100644
浏览文件 @
97431a40
use
synstructure
;
use
syn
;
use
proc_macro2
;
pub
fn
hash_stable_derive
(
mut
s
:
synstructure
::
Structure
)
->
proc_macro2
::
TokenStream
{
let
generic
:
syn
::
GenericParam
=
parse_quote!
(
'__ctx
);
s
.add_bounds
(
synstructure
::
AddBounds
::
Generics
);
s
.add_impl_generic
(
generic
);
let
body
=
s
.each
(|
bi
|
quote!
{
::
rustc_data_structures
::
stable_hasher
::
HashStable
::
hash_stable
(
#
bi
,
__
hcx
,
__
hasher
);
});
let
discriminant
=
match
s
.ast
()
.data
{
syn
::
Data
::
Enum
(
_
)
=>
quote!
{
::
std
::
mem
::
discriminant
(
self
)
.hash_stable
(
__
hcx
,
__
hasher
);
},
syn
::
Data
::
Struct
(
_
)
=>
quote!
{},
syn
::
Data
::
Union
(
_
)
=>
panic!
(
"cannot derive on union"
),
};
s
.bound_impl
(
quote!
(::
rustc_data_structures
::
stable_hasher
::
HashStable
<
::
rustc
::
ich
::
StableHashingContext
<
'__ctx
>>
),
quote!
{
fn
hash_stable
<
__
W
:
::
rustc_data_structures
::
stable_hasher
::
StableHasherResult
>
(
&
self
,
__
hcx
:
&
mut
::
rustc
::
ich
::
StableHashingContext
<
'__ctx
>
,
__
hasher
:
&
mut
::
rustc_data_structures
::
stable_hasher
::
StableHasher
<
__
W
>
)
{
#
discriminant
match
*
self
{
#
body
}
}
})
}
src/librustc_macros/src/lib.rs
0 → 100644
浏览文件 @
97431a40
#![feature(proc_macro_hygiene)]
#[macro_use]
extern
crate
syn
;
#[macro_use]
extern
crate
synstructure
;
#[macro_use]
extern
crate
quote
;
extern
crate
proc_macro
;
extern
crate
proc_macro2
;
mod
hash_stable
;
decl_derive!
([
HashStable
]
=>
hash_stable
::
hash_stable_derive
);
src/tools/tidy/src/deps.rs
浏览文件 @
97431a40
...
...
@@ -137,6 +137,7 @@
Crate
(
"smallvec"
),
Crate
(
"stable_deref_trait"
),
Crate
(
"syn"
),
Crate
(
"synstructure"
),
Crate
(
"tempfile"
),
Crate
(
"termcolor"
),
Crate
(
"terminon"
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录