Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
8bccfe7a
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,发现更多精彩内容 >>
提交
8bccfe7a
编写于
5月 27, 2018
作者:
V
varkor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor counting methods
上级
3bcb006f
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
29 addition
and
36 deletion
+29
-36
src/librustc/hir/intravisit.rs
src/librustc/hir/intravisit.rs
+2
-2
src/librustc/hir/lowering.rs
src/librustc/hir/lowering.rs
+4
-4
src/librustc/hir/mod.rs
src/librustc/hir/mod.rs
+1
-1
src/librustc/ich/impls_hir.rs
src/librustc/ich/impls_hir.rs
+2
-2
src/librustc/middle/resolve_lifetime.rs
src/librustc/middle/resolve_lifetime.rs
+7
-10
src/librustc_typeck/astconv.rs
src/librustc_typeck/astconv.rs
+6
-8
src/librustc_typeck/check/method/confirm.rs
src/librustc_typeck/check/method/confirm.rs
+5
-7
src/libsyntax/visit.rs
src/libsyntax/visit.rs
+2
-2
未找到文件。
src/librustc/hir/intravisit.rs
浏览文件 @
8bccfe7a
...
...
@@ -745,8 +745,8 @@ pub fn walk_ty_param_bound<'v, V: Visitor<'v>>(visitor: &mut V, bound: &'v TyPar
pub
fn
walk_generic_param
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
param
:
&
'v
GenericParam
)
{
visitor
.visit_id
(
param
.id
);
match
param
.kind
{
GenericParamKind
::
Lifetime
{
ref
bounds
,
ref
lifetime
_deprecated
,
..
}
=>
{
match
lifetime
_deprecated
.name
{
GenericParamKind
::
Lifetime
{
ref
bounds
,
ref
lifetime
,
..
}
=>
{
match
lifetime
.name
{
LifetimeName
::
Name
(
name
)
=>
{
visitor
.visit_name
(
param
.span
,
name
);
}
...
...
src/librustc/hir/lowering.rs
浏览文件 @
8bccfe7a
...
...
@@ -705,7 +705,7 @@ fn collect_in_band_defs<T, F>(
name
:
hir_name
,
bounds
:
vec!
[]
.into
(),
in_band
:
true
,
lifetime
_deprecated
:
hir
::
Lifetime
{
lifetime
:
hir
::
Lifetime
{
id
:
def_node_id
,
span
,
name
:
hir_name
,
...
...
@@ -1424,7 +1424,7 @@ fn visit_lifetime(&mut self, lifetime: &'v hir::Lifetime) {
name
,
bounds
:
vec!
[]
.into
(),
in_band
:
false
,
lifetime
_deprecated
:
hir
::
Lifetime
{
lifetime
:
hir
::
Lifetime
{
id
:
def_node_id
,
span
:
lifetime
.span
,
name
,
...
...
@@ -1947,7 +1947,7 @@ fn lower_generic_param(&mut self,
itctx
:
ImplTraitContext
)
->
hir
::
GenericParam
{
match
param
.kind
{
GenericParamKind
::
Lifetime
{
ref
bounds
,
ref
lifetime
,
..
}
=>
{
GenericParamKind
::
Lifetime
{
ref
bounds
,
ref
lifetime
}
=>
{
let
was_collecting_in_band
=
self
.is_collecting_in_band_lifetimes
;
self
.is_collecting_in_band_lifetimes
=
false
;
...
...
@@ -1960,7 +1960,7 @@ fn lower_generic_param(&mut self,
name
:
lifetime
.name
,
bounds
:
bounds
.iter
()
.map
(|
lt
|
self
.lower_lifetime
(
lt
))
.collect
(),
in_band
:
false
,
lifetime
_deprecated
:
lifetime
,
lifetime
,
}
};
...
...
src/librustc/hir/mod.rs
浏览文件 @
8bccfe7a
...
...
@@ -462,7 +462,7 @@ pub enum GenericParamKind {
// `fn foo(x: &'a u8) -> &'a u8 { x }`
in_band
:
bool
,
// We keep a `Lifetime` around for now just so we can `visit_lifetime`.
lifetime
_deprecated
:
Lifetime
,
lifetime
:
Lifetime
,
},
Type
{
name
:
Name
,
...
...
src/librustc/ich/impls_hir.rs
浏览文件 @
8bccfe7a
...
...
@@ -208,11 +208,11 @@ fn hash_stable<W: StableHasherResult>(&self,
mem
::
discriminant
(
self
)
.hash_stable
(
hcx
,
hasher
);
match
self
{
hir
::
GenericParamKind
::
Lifetime
{
name
,
ref
bounds
,
in_band
,
ref
lifetime
_deprecated
}
=>
{
ref
lifetime
}
=>
{
name
.hash_stable
(
hcx
,
hasher
);
bounds
.hash_stable
(
hcx
,
hasher
);
in_band
.hash_stable
(
hcx
,
hasher
);
lifetime
_deprecated
.hash_stable
(
hcx
,
hasher
);
lifetime
.hash_stable
(
hcx
,
hasher
);
}
hir
::
GenericParamKind
::
Type
{
name
,
ref
bounds
,
ref
default
,
synthetic
,
attrs
}
=>
{
name
.hash_stable
(
hcx
,
hasher
);
...
...
src/librustc/middle/resolve_lifetime.rs
浏览文件 @
8bccfe7a
...
...
@@ -1220,20 +1220,17 @@ fn compute_object_lifetime_defaults(
.map
(|
set
|
match
*
set
{
Set1
::
Empty
=>
"BaseDefault"
.to_string
(),
Set1
::
One
(
Region
::
Static
)
=>
"'static"
.to_string
(),
Set1
::
One
(
Region
::
EarlyBound
(
i
,
_
,
_
))
=>
{
let
mut
j
=
0
;
generics
.params
.iter
()
.find
(|
param
|
match
param
.kind
{
Set1
::
One
(
Region
::
EarlyBound
(
mut
i
,
_
,
_
))
=>
{
generics
.params
.iter
()
.find_map
(|
param
|
match
param
.kind
{
GenericParamKind
::
Lifetime
{
..
}
=>
{
if
i
==
j
{
return
true
;
if
i
==
0
{
return
Some
(
param
.name
()
.to_string
())
;
}
j
+
=
1
;
fals
e
i
-
=
1
;
Non
e
}
_
=>
fals
e
,
_
=>
Non
e
,
})
.unwrap
()
.name
()
.to_string
()
}
Set1
::
One
(
_
)
=>
bug!
(),
Set1
::
Many
=>
"Ambiguous"
.to_string
(),
...
...
src/librustc_typeck/astconv.rs
浏览文件 @
8bccfe7a
...
...
@@ -274,15 +274,14 @@ fn create_substs_for_ast_path(&self,
let
substs
=
Substs
::
for_item
(
tcx
,
def_id
,
|
param
,
substs
|
{
match
param
.kind
{
GenericParamDefKind
::
Lifetime
=>
{
let
i
=
param
.index
as
usize
-
own_self
;
let
mut
j
=
0
;
let
mut
i
=
param
.index
as
usize
-
own_self
;
for
arg
in
&
generic_args
.args
{
match
arg
{
GenericArg
::
Lifetime
(
lt
)
=>
{
if
i
==
j
{
if
i
==
0
{
return
self
.ast_region_to_region
(
lt
,
Some
(
param
))
.into
();
}
j
+
=
1
;
i
-
=
1
;
}
_
=>
{}
}
...
...
@@ -297,17 +296,16 @@ fn create_substs_for_ast_path(&self,
return
ty
.into
();
}
let
i
=
i
-
(
lt_accepted
+
own_self
);
let
mut
i
=
i
-
(
lt_accepted
+
own_self
);
if
i
<
ty_provided
{
// A provided type parameter.
let
mut
j
=
0
;
for
arg
in
&
generic_args
.args
{
match
arg
{
GenericArg
::
Type
(
ty
)
=>
{
if
i
==
j
{
if
i
==
0
{
return
self
.ast_ty_to_ty
(
ty
)
.into
();
}
j
+
=
1
;
i
-
=
1
;
}
_
=>
{}
}
...
...
src/librustc_typeck/check/method/confirm.rs
浏览文件 @
8bccfe7a
...
...
@@ -325,21 +325,20 @@ fn instantiate_method_substs(
let
provided
=
&
segment
.args
;
let
own_counts
=
method_generics
.own_counts
();
Substs
::
for_item
(
self
.tcx
,
pick
.item.def_id
,
|
param
,
_
|
{
let
i
=
param
.index
as
usize
;
let
mut
i
=
param
.index
as
usize
;
if
i
<
parent_substs
.len
()
{
parent_substs
[
i
]
}
else
{
match
param
.kind
{
GenericParamDefKind
::
Lifetime
=>
{
if
let
Some
(
lifetime
)
=
provided
.as_ref
()
.and_then
(|
data
|
{
let
mut
j
=
0
;
for
arg
in
&
data
.args
{
match
arg
{
GenericArg
::
Lifetime
(
lt
)
=>
{
if
i
-
parent_substs
.len
()
==
j
{
if
i
==
parent_substs
.len
()
{
return
Some
(
lt
);
}
j
+
=
1
;
i
-
=
1
;
}
_
=>
{}
}
...
...
@@ -352,14 +351,13 @@ fn instantiate_method_substs(
}
GenericParamDefKind
::
Type
{
..
}
=>
{
if
let
Some
(
ast_ty
)
=
provided
.as_ref
()
.and_then
(|
data
|
{
let
mut
j
=
0
;
for
arg
in
&
data
.args
{
match
arg
{
GenericArg
::
Type
(
ty
)
=>
{
if
i
-
parent_substs
.len
()
-
own_counts
.lifetimes
==
j
{
if
i
==
parent_substs
.len
()
+
own_counts
.lifetimes
{
return
Some
(
ty
);
}
j
+
=
1
;
i
-
=
1
;
}
_
=>
{}
}
...
...
src/libsyntax/visit.rs
浏览文件 @
8bccfe7a
...
...
@@ -492,12 +492,12 @@ pub fn walk_ty_param_bound<'a, V: Visitor<'a>>(visitor: &mut V, bound: &'a TyPar
pub
fn
walk_generic_param
<
'a
,
V
:
Visitor
<
'a
>>
(
visitor
:
&
mut
V
,
param
:
&
'a
GenericParam
)
{
match
param
.kind
{
GenericParamKind
::
Lifetime
{
ref
bounds
,
ref
lifetime
,
..
}
=>
{
GenericParamKind
::
Lifetime
{
ref
bounds
,
ref
lifetime
}
=>
{
visitor
.visit_ident
(
param
.ident
);
walk_list!
(
visitor
,
visit_lifetime
,
bounds
);
walk_list!
(
visitor
,
visit_attribute
,
param
.attrs
.iter
());
}
GenericParamKind
::
Type
{
ref
bounds
,
ref
default
,
..
}
=>
{
GenericParamKind
::
Type
{
ref
bounds
,
ref
default
}
=>
{
visitor
.visit_ident
(
t
.ident
);
walk_list!
(
visitor
,
visit_ty_param_bound
,
bounds
);
walk_list!
(
visitor
,
visit_ty
,
default
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录