Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
f59afbc2
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,发现更多精彩内容 >>
提交
f59afbc2
编写于
6月 11, 2016
作者:
V
Vadim Petrochenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove last traces of identifier hygiene from HIR
上级
a267d6ce
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
13 addition
and
42 deletion
+13
-42
src/librustc/hir/lowering.rs
src/librustc/hir/lowering.rs
+6
-29
src/librustc/hir/mod.rs
src/librustc/hir/mod.rs
+2
-2
src/librustc/middle/resolve_lifetime.rs
src/librustc/middle/resolve_lifetime.rs
+1
-2
src/librustc_const_eval/check_match.rs
src/librustc_const_eval/check_match.rs
+1
-2
src/librustc_lint/builtin.rs
src/librustc_lint/builtin.rs
+1
-1
src/librustc_trans/debuginfo/create_scope_map.rs
src/librustc_trans/debuginfo/create_scope_map.rs
+2
-2
src/libsyntax/ast.rs
src/libsyntax/ast.rs
+0
-4
未找到文件。
src/librustc/hir/lowering.rs
浏览文件 @
f59afbc2
...
...
@@ -51,10 +51,9 @@
use
std
::
iter
;
use
syntax
::
ast
::
*
;
use
syntax
::
attr
::{
ThinAttributes
,
ThinAttributesExt
};
use
syntax
::
ext
::
mtwt
;
use
syntax
::
ptr
::
P
;
use
syntax
::
codemap
::{
respan
,
Spanned
,
Span
};
use
syntax
::
parse
::
token
::{
self
,
keywords
}
;
use
syntax
::
parse
::
token
;
use
syntax
::
std_inject
;
use
syntax
::
visit
::{
self
,
Visitor
};
...
...
@@ -184,16 +183,8 @@ fn with_parent_def<T, F>(&mut self, parent_id: NodeId, f: F) -> T
result
}
fn
lower_ident
(
&
mut
self
,
ident
:
Ident
)
->
Name
{
if
ident
.name
!=
keywords
::
Invalid
.name
()
{
mtwt
::
resolve
(
ident
)
}
else
{
ident
.name
}
}
fn
lower_opt_sp_ident
(
&
mut
self
,
o_id
:
Option
<
Spanned
<
Ident
>>
)
->
Option
<
Spanned
<
Name
>>
{
o_id
.map
(|
sp_ident
|
respan
(
sp_ident
.span
,
s
elf
.lower_ident
(
sp_ident
.node
)
))
o_id
.map
(|
sp_ident
|
respan
(
sp_ident
.span
,
s
p_ident
.node.name
))
}
fn
lower_attrs
(
&
mut
self
,
attrs
:
&
Vec
<
Attribute
>
)
->
hir
::
HirVec
<
Attribute
>
{
...
...
@@ -338,18 +329,14 @@ fn lower_variant(&mut self, v: &Variant) -> hir::Variant {
}
}
fn
lower_path
_full
(
&
mut
self
,
p
:
&
Path
,
rename
:
bool
)
->
hir
::
Path
{
fn
lower_path
(
&
mut
self
,
p
:
&
Path
)
->
hir
::
Path
{
hir
::
Path
{
global
:
p
.global
,
segments
:
p
.segments
.iter
()
.map
(|
&
PathSegment
{
identifier
,
ref
parameters
}|
{
hir
::
PathSegment
{
name
:
if
rename
{
self
.lower_ident
(
identifier
)
}
else
{
identifier
.name
},
name
:
identifier
.name
,
parameters
:
self
.lower_path_parameters
(
parameters
),
}
})
...
...
@@ -358,10 +345,6 @@ fn lower_path_full(&mut self, p: &Path, rename: bool) -> hir::Path {
}
}
fn
lower_path
(
&
mut
self
,
p
:
&
Path
)
->
hir
::
Path
{
self
.lower_path_full
(
p
,
false
)
}
fn
lower_path_parameters
(
&
mut
self
,
path_parameters
:
&
PathParameters
)
->
hir
::
PathParameters
{
match
*
path_parameters
{
PathParameters
::
AngleBracketed
(
ref
data
)
=>
...
...
@@ -870,8 +853,7 @@ fn lower_pat(&mut self, p: &Pat) -> P<hir::Pat> {
// `None` can occur in body-less function signatures
None
|
Some
(
Def
::
Local
(
..
))
=>
{
hir
::
PatKind
::
Binding
(
this
.lower_binding_mode
(
binding_mode
),
respan
(
pth1
.span
,
this
.lower_ident
(
pth1
.node
)),
respan
(
pth1
.span
,
pth1
.node.name
),
sub
.as_ref
()
.map
(|
x
|
this
.lower_pat
(
x
)))
}
_
=>
hir
::
PatKind
::
Path
(
hir
::
Path
::
from_name
(
pth1
.span
,
pth1
.node.name
))
...
...
@@ -1238,12 +1220,7 @@ fn make_struct(this: &mut LoweringContext,
position
:
position
,
}
});
// Only local variables are renamed
let
rename
=
match
self
.resolver
.get_resolution
(
e
.id
)
.map
(|
d
|
d
.base_def
)
{
Some
(
Def
::
Local
(
..
))
|
Some
(
Def
::
Upvar
(
..
))
=>
true
,
_
=>
false
,
};
hir
::
ExprPath
(
hir_qself
,
self
.lower_path_full
(
path
,
rename
))
hir
::
ExprPath
(
hir_qself
,
self
.lower_path
(
path
))
}
ExprKind
::
Break
(
opt_ident
)
=>
hir
::
ExprBreak
(
self
.lower_opt_sp_ident
(
opt_ident
)),
ExprKind
::
Again
(
opt_ident
)
=>
hir
::
ExprAgain
(
self
.lower_opt_sp_ident
(
opt_ident
)),
...
...
src/librustc/hir/mod.rs
浏览文件 @
f59afbc2
...
...
@@ -1138,7 +1138,7 @@ pub enum SelfKind {
impl
Arg
{
pub
fn
to_self
(
&
self
)
->
Option
<
ExplicitSelf
>
{
if
let
PatKind
::
Binding
(
BindByValue
(
mutbl
),
name
,
_
)
=
self
.pat.node
{
if
name
.node
.unhygienize
()
==
keywords
::
SelfValue
.name
()
{
if
name
.node
==
keywords
::
SelfValue
.name
()
{
return
match
self
.ty.node
{
TyInfer
=>
Some
(
respan
(
self
.pat.span
,
SelfKind
::
Value
(
mutbl
))),
TyRptr
(
lt
,
MutTy
{
ref
ty
,
mutbl
})
if
ty
.node
==
TyInfer
=>
{
...
...
@@ -1154,7 +1154,7 @@ pub fn to_self(&self) -> Option<ExplicitSelf> {
pub
fn
is_self
(
&
self
)
->
bool
{
if
let
PatKind
::
Binding
(
_
,
name
,
_
)
=
self
.pat.node
{
name
.node
.unhygienize
()
==
keywords
::
SelfValue
.name
()
name
.node
==
keywords
::
SelfValue
.name
()
}
else
{
false
}
...
...
src/librustc/middle/resolve_lifetime.rs
浏览文件 @
f59afbc2
...
...
@@ -456,8 +456,7 @@ fn visit_item(&mut self, _: &hir::Item) {
fn
expression_label
(
ex
:
&
hir
::
Expr
)
->
Option
<
(
ast
::
Name
,
Span
)
>
{
match
ex
.node
{
hir
::
ExprWhile
(
_
,
_
,
Some
(
label
))
|
hir
::
ExprLoop
(
_
,
Some
(
label
))
=>
Some
((
label
.node
.unhygienize
(),
label
.span
)),
hir
::
ExprLoop
(
_
,
Some
(
label
))
=>
Some
((
label
.node
,
label
.span
)),
_
=>
None
,
}
}
...
...
src/librustc_const_eval/check_match.rs
浏览文件 @
f59afbc2
...
...
@@ -247,8 +247,7 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat)
if
let
ty
::
TyEnum
(
edef
,
_
)
=
pat_ty
.sty
{
if
let
Def
::
Local
(
..
)
=
cx
.tcx
.expect_def
(
p
.id
)
{
if
edef
.variants
.iter
()
.any
(|
variant
|
variant
.name
==
name
.node
.unhygienize
()
&&
variant
.kind
()
==
VariantKind
::
Unit
variant
.name
==
name
.node
&&
variant
.kind
()
==
VariantKind
::
Unit
)
{
let
ty_path
=
cx
.tcx
.item_path_str
(
edef
.did
);
let
mut
err
=
struct_span_warn!
(
cx
.tcx.sess
,
p
.span
,
E0170
,
...
...
src/librustc_lint/builtin.rs
浏览文件 @
f59afbc2
...
...
@@ -163,7 +163,7 @@ fn check_pat(&mut self, cx: &LateContext, pat: &hir::Pat) {
continue
;
}
if
let
PatKind
::
Binding
(
_
,
ident
,
None
)
=
fieldpat
.node.pat.node
{
if
ident
.node
.unhygienize
()
==
fieldpat
.node.name
{
if
ident
.node
==
fieldpat
.node.name
{
cx
.span_lint
(
NON_SHORTHAND_FIELD_PATTERNS
,
fieldpat
.span
,
&
format!
(
"the `{}:` in this pattern is redundant and can
\
be removed"
,
ident
.node
))
...
...
src/librustc_trans/debuginfo/create_scope_map.rs
浏览文件 @
f59afbc2
...
...
@@ -51,7 +51,7 @@ pub fn create_scope_map(cx: &CrateContext,
for
arg
in
args
{
pat_util
::
pat_bindings
(
&
arg
.pat
,
|
_
,
node_id
,
_
,
path1
|
{
scope_stack
.push
(
ScopeStackEntry
{
scope_metadata
:
fn_metadata
,
name
:
Some
(
path1
.node
.unhygienize
()
)
});
name
:
Some
(
path1
.node
)
});
scope_map
.insert
(
node_id
,
fn_metadata
);
})
}
...
...
@@ -260,7 +260,7 @@ fn walk_pattern(cx: &CrateContext,
// N.B.: this comparison must be UNhygienic... because
// gdb knows nothing about the context, so any two
// variables with the same name will cause the problem.
let
name
=
path1
.node
.unhygienize
()
;
let
name
=
path1
.node
;
let
need_new_scope
=
scope_stack
.iter
()
.any
(|
entry
|
entry
.name
==
Some
(
name
));
...
...
src/libsyntax/ast.rs
浏览文件 @
f59afbc2
...
...
@@ -60,10 +60,6 @@ impl Name {
pub
fn
as_str
(
self
)
->
token
::
InternedString
{
token
::
InternedString
::
new_from_name
(
self
)
}
pub
fn
unhygienize
(
self
)
->
Name
{
token
::
intern
(
&
self
.as_str
())
}
}
impl
fmt
::
Debug
for
Name
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录