Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
0954e664
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,发现更多精彩内容 >>
提交
0954e664
编写于
9月 05, 2013
作者:
J
John Clements
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
uncomment mtwt_resolve calls
上级
d9ba61c7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
53 addition
and
23 deletion
+53
-23
src/librustc/middle/resolve.rs
src/librustc/middle/resolve.rs
+10
-4
src/libsyntax/ast_util.rs
src/libsyntax/ast_util.rs
+21
-17
src/libsyntax/ext/tt/macro_parser.rs
src/libsyntax/ext/tt/macro_parser.rs
+2
-2
src/libsyntax/parse/token.rs
src/libsyntax/parse/token.rs
+20
-0
未找到文件。
src/librustc/middle/resolve.rs
浏览文件 @
0954e664
...
...
@@ -23,7 +23,7 @@
use
syntax
::
ast
::
*
;
use
syntax
::
ast
;
use
syntax
::
ast_util
::{
def_id_of_def
,
local_def
};
// mtwt_resolve
use
syntax
::
ast_util
::{
def_id_of_def
,
local_def
,
mtwt_resolve
};
use
syntax
::
ast_util
::{
path_to_ident
,
walk_pat
,
trait_method_to_ty_method
};
use
syntax
::
ast_util
::{
Privacy
,
Public
,
Private
};
use
syntax
::
ast_util
::{
variant_visibility_to_privacy
,
visibility_to_privacy
};
...
...
@@ -4067,10 +4067,14 @@ pub fn resolve_local(@mut self, local: @Local, visitor: &mut ResolveVisitor) {
None
,
visitor
);
}
// build a map from pattern identifiers to binding-info's.
// this is done hygienically. This could arise for a macro
// that expands into an or-pattern where one 'x' was from the
// user and one 'x' came from the macro.
pub
fn
binding_mode_map
(
@
mut
self
,
pat
:
@
Pat
)
->
BindingMap
{
let
mut
result
=
HashMap
::
new
();
do
pat_bindings
(
self
.def_map
,
pat
)
|
binding_mode
,
_
id
,
sp
,
path
|
{
let
name
=
path_to_ident
(
path
)
.name
;
//
mtwt_resolve(path_to_ident(path));
let
name
=
mtwt_resolve
(
path_to_ident
(
path
));
result
.insert
(
name
,
binding_info
{
span
:
sp
,
binding_mode
:
binding_mode
});
...
...
@@ -4078,6 +4082,8 @@ pub fn binding_mode_map(@mut self, pat: @Pat) -> BindingMap {
return
result
;
}
// check that all of the arms in an or-pattern have exactly the
// same set of bindings, with the same binding modes for each.
pub
fn
check_consistent_bindings
(
@
mut
self
,
arm
:
&
Arm
)
{
if
arm
.pats
.len
()
==
0
{
return
;
}
let
map_0
=
self
.binding_mode_map
(
arm
.pats
[
0
]);
...
...
@@ -4293,7 +4299,7 @@ pub fn resolve_pattern(@mut self,
// what you want).
let
ident
=
path
.segments
[
0
]
.identifier
;
let
renamed
=
ident
.name
;
//
mtwt_resolve(ident);
let
renamed
=
mtwt_resolve
(
ident
);
match
self
.resolve_bare_identifier_pattern
(
ident
)
{
FoundStructOrEnumVariant
(
def
)
...
...
@@ -4833,7 +4839,7 @@ pub fn resolve_identifier_in_local_ribs(@mut self,
let
search_result
;
match
namespace
{
ValueNS
=>
{
let
renamed
=
ident
.name
;
//
mtwt_resolve(ident);
let
renamed
=
mtwt_resolve
(
ident
);
search_result
=
self
.search_ribs
(
self
.value_ribs
,
renamed
,
span
,
DontAllowCapturingSelf
);
...
...
src/libsyntax/ast_util.rs
浏览文件 @
0954e664
...
...
@@ -991,20 +991,19 @@ pub fn getLast(arr: &~[Mrk]) -> uint {
pub
fn
path_name_eq
(
a
:
&
ast
::
Path
,
b
:
&
ast
::
Path
)
->
bool
{
(
a
.span
==
b
.span
)
&&
(
a
.global
==
b
.global
)
// NOTE: ident->name in lifetimes!
&&
(
a
.rp
==
b
.rp
)
// NOTE: can a type contain an ident?
&&
(
a
.types
==
b
.types
)
&&
(
idents_name_eq
(
a
.idents
,
b
.idents
))
&&
(
segments_name_eq
(
a
.segments
,
b
.segments
))
}
// are two arrays of
id
ents equal when compared unhygienically?
pub
fn
idents_name_eq
(
a
:
&
[
ast
::
ident
],
b
:
&
[
ast
::
id
ent
])
->
bool
{
// are two arrays of
segm
ents equal when compared unhygienically?
pub
fn
segments_name_eq
(
a
:
&
[
ast
::
PathSegment
],
b
:
&
[
ast
::
PathSegm
ent
])
->
bool
{
if
(
a
.len
()
!=
b
.len
())
{
false
}
else
{
for
a
.iter
()
.enumerate
()
.advance
|(
idx
,
id
)|{
if
(
id
.name
!=
b
[
idx
]
.name
)
{
for
(
idx
,
seg
)
in
a
.iter
()
.enumerate
()
{
if
(
seg
.identifier.name
!=
b
[
idx
]
.identifier.name
)
// ident -> name problems in lifetime comparison?
||
(
seg
.lifetime
!=
b
[
idx
]
.lifetime
)
||
(
seg
.types
!=
b
[
idx
]
.types
)
{
return
false
;
}
}
...
...
@@ -1017,16 +1016,21 @@ mod test {
use
ast
::
*
;
use
super
::
*
;
use
std
::
io
;
use
opt_vec
;
fn
ident_to_segment
(
id
:
&
ident
)
->
PathSegment
{
PathSegment
{
identifier
:
id
.clone
(),
lifetime
:
None
,
types
:
opt_vec
::
Empty
}
}
#[test]
fn
idents_name_eq_test
()
{
assert
!
(
idents_name_eq
(
~
[
ident
{
name
:
3
,
ctxt
:
4
},
ident
{
name
:
78
,
ctxt
:
82
}]
,
~
[
ident
{
name
:
3
,
ctxt
:
104
},
ident
{
name
:
78
,
ctxt
:
182
}]
));
assert
!
(
!
idents_name_eq
(
~
[
ident
{
name
:
3
,
ctxt
:
4
},
ident
{
name
:
78
,
ctxt
:
82
}]
,
~
[
ident
{
name
:
3
,
ctxt
:
104
},
ident
{
name
:
77
,
ctxt
:
182
}]
));
assert
!
(
segments_name_eq
(
[
ident
{
name
:
3
,
ctxt
:
4
},
ident
{
name
:
78
,
ctxt
:
82
}]
.map
(
ident_to_segment
)
,
[
ident
{
name
:
3
,
ctxt
:
104
},
ident
{
name
:
78
,
ctxt
:
182
}]
.map
(
ident_to_segment
)
));
assert
!
(
!
segments_name_eq
(
[
ident
{
name
:
3
,
ctxt
:
4
},
ident
{
name
:
78
,
ctxt
:
82
}]
.map
(
ident_to_segment
)
,
[
ident
{
name
:
3
,
ctxt
:
104
},
ident
{
name
:
77
,
ctxt
:
182
}]
.map
(
ident_to_segment
)
));
}
#[test]
fn
xorpush_test
()
{
...
...
src/libsyntax/ext/tt/macro_parser.rs
浏览文件 @
0954e664
...
...
@@ -355,8 +355,8 @@ pub fn parse(
match_nonterminal
(
_
,
_
,
_
)
=>
{
bb_eis
.push
(
ei
)
}
match_tok
(
ref
t
)
=>
{
let
mut
ei_t
=
ei
.clone
();
if
(
token_name_eq
(
t
,
&
tok
))
{
//
if (token::mtwt_token_eq(t,&tok)) {
//
if (token_name_eq(t,&tok)) {
if
(
token
::
mtwt_token_eq
(
t
,
&
tok
))
{
ei_t
.idx
+=
1
;
next_eis
.push
(
ei_t
);
}
...
...
src/libsyntax/parse/token.rs
浏览文件 @
0954e664
...
...
@@ -720,6 +720,15 @@ pub fn is_reserved_keyword(tok: &Token) -> bool {
}
}
pub
fn
mtwt_token_eq
(
t1
:
&
Token
,
t2
:
&
Token
)
->
bool
{
match
(
t1
,
t2
)
{
(
&
IDENT
(
id1
,
_
),
&
IDENT
(
id2
,
_
))
=>
ast_util
::
mtwt_resolve
(
id1
)
==
ast_util
::
mtwt_resolve
(
id2
),
_
=>
*
t1
==
*
t2
}
}
#[cfg(test)]
mod
test
{
use
super
::
*
;
...
...
@@ -728,6 +737,17 @@ mod test {
use
ast
;
use
ast_util
;
fn
mark_ident
(
id
:
ast
::
ident
,
m
:
ast
::
Mrk
)
->
ast
::
ident
{
ast
::
ident
{
name
:
id
.name
,
ctxt
:
ast_util
::
new_mark
(
m
,
id
.ctxt
)}
}
#[test]
fn
mtwt_token_eq_test
()
{
assert
!
(
mtwt_token_eq
(
&
GT
,
&
GT
));
let
a
=
str_to_ident
(
"bac"
);
let
a1
=
mark_ident
(
a
,
92
);
assert
!
(
mtwt_token_eq
(
&
IDENT
(
a
,
true
),
&
IDENT
(
a1
,
false
)));
}
#[test]
fn
str_ptr_eq_tests
(){
let
a
=
@
"abc"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录