Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
5001c92c
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,发现更多精彩内容 >>
提交
5001c92c
编写于
7月 27, 2016
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
stop hashing nested items, and add a test
上级
775bd93d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
52 addition
and
20 deletion
+52
-20
src/librustc_incremental/calculate_svh.rs
src/librustc_incremental/calculate_svh.rs
+16
-20
src/test/incremental/ich_nested_items.rs
src/test/incremental/ich_nested_items.rs
+36
-0
未找到文件。
src/librustc_incremental/calculate_svh.rs
浏览文件 @
5001c92c
...
...
@@ -182,7 +182,6 @@ enum SawAbiComponent<'a> {
SawMod
,
SawForeignItem
,
SawItem
,
SawDecl
,
SawTy
,
SawGenerics
,
SawFn
,
...
...
@@ -285,24 +284,13 @@ fn saw_expr<'a>(node: &'a Expr_) -> SawExprComponent<'a> {
/// SawStmtComponent is analogous to SawExprComponent, but for statements.
#[derive(Hash)]
pub
enum
SawStmtComponent
{
SawStmtDecl
,
SawStmtExpr
,
SawStmtSemi
,
}
fn
saw_stmt
(
node
:
&
Stmt_
)
->
SawStmtComponent
{
match
*
node
{
StmtDecl
(
..
)
=>
SawStmtDecl
,
StmtExpr
(
..
)
=>
SawStmtExpr
,
StmtSemi
(
..
)
=>
SawStmtSemi
,
}
}
impl
<
'a
,
'tcx
>
Visitor
<
'a
>
for
StrictVersionHashVisitor
<
'a
,
'tcx
>
{
fn
visit_nested_item
(
&
mut
self
,
item
:
ItemId
)
{
let
def_path
=
self
.tcx.map
.def_path_from_id
(
item
.id
)
.unwrap
();
debug!
(
"visit_nested_item: def_path={:?} st={:?}"
,
def_path
,
self
.st
);
self
.hash_def_path
(
&
def_path
);
fn
visit_nested_item
(
&
mut
self
,
_
:
ItemId
)
{
// Each item is hashed independently; ignore nested items.
}
fn
visit_variant_data
(
&
mut
self
,
s
:
&
'a
VariantData
,
name
:
Name
,
...
...
@@ -362,7 +350,20 @@ fn visit_expr(&mut self, ex: &'a Expr) {
fn
visit_stmt
(
&
mut
self
,
s
:
&
'a
Stmt
)
{
debug!
(
"visit_stmt: st={:?}"
,
self
.st
);
SawStmt
(
saw_stmt
(
&
s
.node
))
.hash
(
self
.st
);
visit
::
walk_stmt
(
self
,
s
)
// We don't want to modify the hash for decls, because
// they might be item decls (if they are local decls,
// we'll hash that fact in visit_local); but we do want to
// remember if this was a StmtExpr or StmtSemi (the later
// had an explicit semi-colon; this affects the typing
// rules).
match
s
.node
{
StmtDecl
(
..
)
=>
(),
StmtExpr
(
..
)
=>
SawStmt
(
SawStmtExpr
)
.hash
(
self
.st
),
StmtSemi
(
..
)
=>
SawStmt
(
SawStmtSemi
)
.hash
(
self
.st
),
}
visit
::
walk_stmt
(
self
,
s
)
}
fn
visit_foreign_item
(
&
mut
self
,
i
:
&
'a
ForeignItem
)
{
...
...
@@ -390,11 +391,6 @@ fn visit_mod(&mut self, m: &'a Mod, _s: Span, n: NodeId) {
SawMod
.hash
(
self
.st
);
visit
::
walk_mod
(
self
,
m
,
n
)
}
fn
visit_decl
(
&
mut
self
,
d
:
&
'a
Decl
)
{
debug!
(
"visit_decl: st={:?}"
,
self
.st
);
SawDecl
.hash
(
self
.st
);
visit
::
walk_decl
(
self
,
d
)
}
fn
visit_ty
(
&
mut
self
,
t
:
&
'a
Ty
)
{
debug!
(
"visit_ty: st={:?}"
,
self
.st
);
SawTy
.hash
(
self
.st
);
visit
::
walk_ty
(
self
,
t
)
...
...
src/test/incremental/ich_nested_items.rs
0 → 100644
浏览文件 @
5001c92c
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Check that the hash of `foo` doesn't change just because we ordered
// the nested items (or even added new ones).
// revisions: rpass1 rpass2
#![feature(rustc_attrs)]
#[cfg(rpass1)]
fn
foo
()
{
fn
bar
()
{
}
fn
baz
()
{
}
}
#[cfg(rpass2)]
#[rustc_clean(label=
"Hir"
,
cfg=
"rpass2"
)]
fn
foo
()
{
#[rustc_clean(label=
"Hir"
,
cfg=
"rpass2"
)]
fn
baz
()
{
}
// order is different...
#[rustc_clean(label=
"Hir"
,
cfg=
"rpass2"
)]
fn
bar
()
{
}
// but that doesn't matter.
fn
bap
()
{
}
// neither does adding a new item
}
fn
main
()
{
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录