Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
d2d21446
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,发现更多精彩内容 >>
提交
d2d21446
编写于
1月 26, 2016
作者:
J
Jeffrey Seyfried
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor away NameSearchType
上级
1fcde2bd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
11 addition
and
55 deletion
+11
-55
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+10
-52
src/librustc_resolve/resolve_imports.rs
src/librustc_resolve/resolve_imports.rs
+1
-3
未找到文件。
src/librustc_resolve/lib.rs
浏览文件 @
d2d21446
...
...
@@ -44,7 +44,6 @@
use
self
::
UseLexicalScopeFlag
::
*
;
use
self
::
ModulePrefixResult
::
*
;
use
self
::
AssocItemResolveResult
::
*
;
use
self
::
NameSearchType
::
*
;
use
self
::
BareIdentifierPatternResolution
::
*
;
use
self
::
ParentLink
::
*
;
use
self
::
FallbackChecks
::
*
;
...
...
@@ -784,16 +783,6 @@ enum AssocItemResolveResult {
ResolveAttempt
(
Option
<
PathResolution
>
),
}
#[derive(Copy,
Clone,
PartialEq)]
enum
NameSearchType
{
/// We're doing a name search in order to resolve a `use` directive.
ImportSearch
,
/// We're doing a name search in order to resolve a path type, a path
/// expression, or a path pattern.
PathSearch
,
}
#[derive(Copy,
Clone)]
enum
BareIdentifierPatternResolution
{
FoundStructOrEnumVariant
(
Def
,
LastPrivate
),
...
...
@@ -1370,7 +1359,6 @@ fn resolve_module_path_from_root(&mut self,
module_path
:
&
[
Name
],
index
:
usize
,
span
:
Span
,
name_search_type
:
NameSearchType
,
lp
:
LastPrivate
)
->
ResolveResult
<
(
Module
<
'a
>
,
LastPrivate
)
>
{
fn
search_parent_externals
<
'a
>
(
needle
:
Name
,
module
:
Module
<
'a
>
)
...
...
@@ -1396,11 +1384,7 @@ fn search_parent_externals<'a>(needle: Name, module: Module<'a>)
// modules as we go.
while
index
<
module_path_len
{
let
name
=
module_path
[
index
];
match
self
.resolve_name_in_module
(
search_module
,
name
,
TypeNS
,
name_search_type
,
false
)
{
match
self
.resolve_name_in_module
(
search_module
,
name
,
TypeNS
,
false
)
{
Failed
(
None
)
=>
{
let
segment_name
=
name
.as_str
();
let
module_name
=
module_to_string
(
search_module
);
...
...
@@ -1477,8 +1461,7 @@ fn resolve_module_path(&mut self,
module_
:
Module
<
'a
>
,
module_path
:
&
[
Name
],
use_lexical_scope
:
UseLexicalScopeFlag
,
span
:
Span
,
name_search_type
:
NameSearchType
)
span
:
Span
)
->
ResolveResult
<
(
Module
<
'a
>
,
LastPrivate
)
>
{
let
module_path_len
=
module_path
.len
();
assert
!
(
module_path_len
>
0
);
...
...
@@ -1559,7 +1542,6 @@ fn resolve_module_path(&mut self,
module_path
,
start_index
,
span
,
name_search_type
,
last_private
)
}
...
...
@@ -1658,11 +1640,7 @@ fn resolve_item_in_lexical_scope(&mut self,
}
// Resolve the name in the parent module.
match
self
.resolve_name_in_module
(
search_module
,
name
,
namespace
,
PathSearch
,
true
)
{
match
self
.resolve_name_in_module
(
search_module
,
name
,
namespace
,
true
)
{
Failed
(
Some
((
span
,
msg
)))
=>
{
resolve_error
(
self
,
span
,
ResolutionError
::
FailedToResolve
(
&*
msg
));
}
...
...
@@ -1787,7 +1765,6 @@ fn resolve_name_in_module(&mut self,
module_
:
Module
<
'a
>
,
name
:
Name
,
namespace
:
Namespace
,
name_search_type
:
NameSearchType
,
allow_private_imports
:
bool
)
->
ResolveResult
<
(
Target
<
'a
>
,
bool
)
>
{
debug!
(
"(resolving name in module) resolving `{}` in `{}`"
,
...
...
@@ -3167,11 +3144,7 @@ fn resolve_module_relative_path(&mut self,
let
containing_module
;
let
last_private
;
let
current_module
=
self
.current_module
;
match
self
.resolve_module_path
(
current_module
,
&
module_path
[
..
],
UseLexicalScope
,
span
,
PathSearch
)
{
match
self
.resolve_module_path
(
current_module
,
&
module_path
,
UseLexicalScope
,
span
)
{
Failed
(
err
)
=>
{
let
(
span
,
msg
)
=
match
err
{
Some
((
span
,
msg
))
=>
(
span
,
msg
),
...
...
@@ -3193,11 +3166,7 @@ fn resolve_module_relative_path(&mut self,
}
let
name
=
segments
.last
()
.unwrap
()
.identifier.name
;
let
def
=
match
self
.resolve_name_in_module
(
containing_module
,
name
,
namespace
,
NameSearchType
::
PathSearch
,
false
)
{
let
def
=
match
self
.resolve_name_in_module
(
containing_module
,
name
,
namespace
,
false
)
{
Success
((
Target
{
binding
,
..
},
_
))
=>
{
let
(
def
,
lp
)
=
binding
.def_and_lp
();
(
def
,
last_private
.or
(
lp
))
...
...
@@ -3232,7 +3201,6 @@ fn resolve_crate_relative_path(&mut self,
&
module_path
[
..
],
0
,
span
,
PathSearch
,
LastMod
(
AllPublic
))
{
Failed
(
err
)
=>
{
let
(
span
,
msg
)
=
match
err
{
...
...
@@ -3257,11 +3225,7 @@ fn resolve_crate_relative_path(&mut self,
}
let
name
=
segments
.last
()
.unwrap
()
.identifier.name
;
match
self
.resolve_name_in_module
(
containing_module
,
name
,
namespace
,
NameSearchType
::
PathSearch
,
false
)
{
match
self
.resolve_name_in_module
(
containing_module
,
name
,
namespace
,
false
)
{
Success
((
Target
{
binding
,
..
},
_
))
=>
{
let
(
def
,
lp
)
=
binding
.def_and_lp
();
Some
((
def
,
last_private
.or
(
lp
)))
...
...
@@ -3303,7 +3267,6 @@ fn resolve_identifier_in_local_ribs(&mut self,
if
let
Success
((
target
,
_
))
=
self
.resolve_name_in_module
(
module
,
ident
.unhygienic_name
,
namespace
,
PathSearch
,
true
)
{
if
let
Some
(
def
)
=
target
.binding
.def
()
{
return
Some
(
LocalDef
::
from_def
(
def
));
...
...
@@ -3399,11 +3362,7 @@ fn get_module<'a, 'tcx>(this: &mut Resolver<'a, 'tcx>,
}
}
}
else
{
match
this
.resolve_module_path
(
root
,
&
name_path
[
..
],
UseLexicalScope
,
span
,
PathSearch
)
{
match
this
.resolve_module_path
(
root
,
&
name_path
,
UseLexicalScope
,
span
)
{
Success
((
module
,
_
))
=>
Some
(
module
),
_
=>
None
,
}
...
...
@@ -3649,10 +3608,9 @@ fn resolve_expr(&mut self, expr: &Expr) {
let
current_module
=
self
.current_module
;
match
self
.resolve_module_path
(
current_module
,
&
name_path
[
..
],
UseLexicalScope
,
expr
.span
,
PathSearch
)
{
&
name_path
[
..
],
UseLexicalScope
,
expr
.span
)
{
Success
(
_
)
=>
{
context
=
UnresolvedNameContext
::
PathIsMod
(
expr
.id
);
},
...
...
src/librustc_resolve/resolve_imports.rs
浏览文件 @
d2d21446
...
...
@@ -16,7 +16,6 @@
use
{
NameBindings
,
NameBinding
};
use
NamespaceResult
::{
BoundResult
,
UnboundResult
,
UnknownResult
};
use
NamespaceResult
;
use
NameSearchType
;
use
ResolveResult
;
use
Resolver
;
use
UseLexicalScopeFlag
;
...
...
@@ -321,8 +320,7 @@ fn resolve_import_for_module(&mut self,
match
self
.resolver
.resolve_module_path
(
module_
,
&
module_path
[
..
],
UseLexicalScopeFlag
::
DontUseLexicalScope
,
import_directive
.span
,
NameSearchType
::
ImportSearch
)
{
import_directive
.span
)
{
ResolveResult
::
Failed
(
err
)
=>
{
resolution_result
=
ResolveResult
::
Failed
(
err
);
None
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录