Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
831b5c02
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,发现更多精彩内容 >>
提交
831b5c02
编写于
5月 31, 2018
作者:
V
varkor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Take advantage of the lifetime refactoring
上级
6015edf9
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
50 addition
and
66 deletion
+50
-66
src/librustc/hir/intravisit.rs
src/librustc/hir/intravisit.rs
+5
-6
src/librustc/hir/lowering.rs
src/librustc/hir/lowering.rs
+4
-4
src/librustc/hir/map/collector.rs
src/librustc/hir/map/collector.rs
+1
-8
src/librustc/middle/resolve_lifetime.rs
src/librustc/middle/resolve_lifetime.rs
+5
-6
src/librustc_passes/ast_validation.rs
src/librustc_passes/ast_validation.rs
+2
-2
src/libsyntax/ast.rs
src/libsyntax/ast.rs
+1
-1
src/libsyntax/fold.rs
src/libsyntax/fold.rs
+29
-31
src/libsyntax/visit.rs
src/libsyntax/visit.rs
+3
-8
未找到文件。
src/librustc/hir/intravisit.rs
浏览文件 @
831b5c02
...
...
@@ -743,20 +743,19 @@ pub fn walk_param_bound<'v, V: Visitor<'v>>(visitor: &mut V, bound: &'v ParamBou
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
lifeti
me
,
..
}
=>
{
match
l
ifetime
.
name
{
GenericParamKind
::
Lifetime
{
ref
lt_na
me
,
..
}
=>
{
match
l
t_
name
{
LifetimeName
::
Name
(
name
)
=>
{
visitor
.visit_name
(
param
.span
,
name
);
visitor
.visit_name
(
param
.span
,
*
name
);
}
LifetimeName
::
Fresh
(
_
)
|
LifetimeName
::
Static
|
LifetimeName
::
Implicit
|
LifetimeName
::
Underscore
=>
{}
}
walk_list!
(
visitor
,
visit_lifetime
,
bounds
);
}
GenericParamKind
::
Type
{
name
,
ref
bounds
,
ref
default
,
ref
attrs
,
..
}
=>
{
visitor
.visit_name
(
param
.span
,
name
);
GenericParamKind
::
Type
{
ref
default
,
ref
attrs
,
..
}
=>
{
visitor
.visit_name
(
param
.span
,
param
.
name
);
walk_list!
(
visitor
,
visit_ty
,
default
);
walk_list!
(
visitor
,
visit_attribute
,
attrs
.iter
());
}
...
...
src/librustc/hir/lowering.rs
浏览文件 @
831b5c02
...
...
@@ -1747,8 +1747,8 @@ fn lower_angle_bracketed_parameter_data(
fn
lower_parenthesized_parameter_data
(
&
mut
self
,
data
:
&
Parenthesized
Parameter
Data
,
)
->
(
hir
::
PathParameter
s
,
bool
)
{
data
:
&
Parenthesized
Arg
Data
,
)
->
(
hir
::
GenericArg
s
,
bool
)
{
// Switch to `PassThrough` mode for anonymous lifetimes: this
// means that we permit things like `&Ref<T>`, where `Ref` has
// a hidden lifetime parameter. This is needed for backwards
...
...
@@ -1758,7 +1758,7 @@ fn lower_parenthesized_parameter_data(
AnonymousLifetimeMode
::
PassThrough
,
|
this
|
{
const
DISALLOWED
:
ImplTraitContext
=
ImplTraitContext
::
Disallowed
;
let
&
Parenthesized
Parameter
Data
{
ref
inputs
,
ref
output
,
span
}
=
data
;
let
&
Parenthesized
Arg
Data
{
ref
inputs
,
ref
output
,
span
}
=
data
;
let
inputs
=
inputs
.iter
()
.map
(|
ty
|
this
.lower_ty
(
ty
,
DISALLOWED
))
.collect
();
let
mk_tup
=
|
this
:
&
mut
Self
,
tys
,
span
|
{
let
LoweredNodeId
{
node_id
,
hir_id
}
=
this
.next_id
();
...
...
@@ -1767,7 +1767,7 @@ fn lower_parenthesized_parameter_data(
(
hir
::
GenericArgs
{
parameter
s
:
hir_vec!
[
GenericArg
::
Type
(
mk_tup
(
this
,
inputs
,
span
))],
arg
s
:
hir_vec!
[
GenericArg
::
Type
(
mk_tup
(
this
,
inputs
,
span
))],
bindings
:
hir_vec!
[
hir
::
TypeBinding
{
id
:
this
.next_id
()
.node_id
,
...
...
src/librustc/hir/map/collector.rs
浏览文件 @
831b5c02
...
...
@@ -347,14 +347,7 @@ fn visit_foreign_item(&mut self, foreign_item: &'hir ForeignItem) {
}
fn
visit_generic_param
(
&
mut
self
,
param
:
&
'hir
GenericParam
)
{
match
param
.kind
{
GenericParamKind
::
Lifetime
{
ref
lifetime_deprecated
,
..
}
=>
{
self
.insert
(
param
.id
,
NodeLifetime
(
lifetime_deprecated
));
}
GenericParamKind
::
Type
{
..
}
=>
{
self
.insert
(
param
.id
,
NodeGenericParam
(
param
));
}
}
self
.insert
(
param
.id
,
NodeGenericParam
(
param
));
intravisit
::
walk_generic_param
(
self
,
param
);
}
...
...
src/librustc/middle/resolve_lifetime.rs
浏览文件 @
831b5c02
...
...
@@ -110,8 +110,8 @@ fn late(hir_map: &Map, param: &hir::GenericParam) -> (hir::LifetimeName, Region)
let
depth
=
ty
::
INNERMOST
;
let
(
name
,
def_id
,
origin
)
=
new_region
(
hir_map
,
param
);
debug!
(
"Region::late:
def
={:?} depth={:?} def_id={:?} origin={:?}"
,
def
,
"Region::late:
param
={:?} depth={:?} def_id={:?} origin={:?}"
,
param
,
depth
,
def_id
,
origin
,
...
...
@@ -2243,8 +2243,7 @@ fn check_lifetime_params(&mut self, old_scope: ScopeRef, params: &'tcx [hir::Gen
for
(
i
,
(
lifetime_i
,
lifetime_i_name
))
in
lifetimes
.iter
()
.enumerate
()
{
match
lifetime_i_name
{
hir
::
LifetimeName
::
Static
|
hir
::
LifetimeName
::
Underscore
=>
{
let
lifetime
=
lifetime_i
.lifetime
;
let
name
=
lifetime_i
.name
();
let
name
=
lifetime_i
.name
;
let
mut
err
=
struct_span_err!
(
self
.tcx.sess
,
lifetime_i
.span
,
...
...
@@ -2518,10 +2517,10 @@ fn insert_late_bound_lifetimes(
for
param
in
&
generics
.params
{
match
param
.kind
{
hir
::
GenericParamKind
::
Lifetime
{
..
}
=>
{
hir
::
GenericParamKind
::
Lifetime
{
lt_name
,
..
}
=>
{
if
!
param
.bounds
.is_empty
()
{
// `'a: 'b` means both `'a` and `'b` are referenced
appears_in_where_clause
.regions
.insert
(
l
ifetime_def
.lifetime.
name
);
appears_in_where_clause
.regions
.insert
(
l
t_
name
);
}
}
hir
::
GenericParamKind
::
Type
{
..
}
=>
{}
...
...
src/librustc_passes/ast_validation.rs
浏览文件 @
831b5c02
...
...
@@ -431,8 +431,8 @@ fn visit_generics(&mut self, generics: &'a Generics) {
}
fn
visit_generic_param
(
&
mut
self
,
param
:
&
'a
GenericParam
)
{
if
let
GenericParam
::
Lifetime
(
ref
ld
)
=
*
param
{
self
.check_lifetime
(
ld
.lifetime
.ident
);
if
let
GenericParam
Kind
::
Lifetime
{
..
}
=
param
.kind
{
self
.check_lifetime
(
param
.ident
);
}
visit
::
walk_generic_param
(
self
,
param
);
}
...
...
src/libsyntax/ast.rs
浏览文件 @
831b5c02
...
...
@@ -309,8 +309,8 @@ pub enum GenericParamKind {
#[derive(Clone,
PartialEq,
Eq,
RustcEncodable,
RustcDecodable,
Hash,
Debug)]
pub
struct
GenericParam
{
pub
ident
:
Ident
,
pub
id
:
NodeId
,
pub
ident
:
Ident
,
pub
attrs
:
ThinVec
<
Attribute
>
,
pub
bounds
:
ParamBounds
,
...
...
src/libsyntax/fold.rs
浏览文件 @
831b5c02
...
...
@@ -143,6 +143,10 @@ fn fold_ty(&mut self, t: P<Ty>) -> P<Ty> {
noop_fold_ty
(
t
,
self
)
}
fn
fold_lifetime
(
&
mut
self
,
l
:
Lifetime
)
->
Lifetime
{
noop_fold_lifetime
(
l
,
self
)
}
fn
fold_ty_binding
(
&
mut
self
,
t
:
TypeBinding
)
->
TypeBinding
{
noop_fold_ty_binding
(
t
,
self
)
}
...
...
@@ -240,10 +244,6 @@ fn fold_variant_data(&mut self, vdata: VariantData) -> VariantData {
noop_fold_variant_data
(
vdata
,
self
)
}
fn
fold_ty_param
(
&
mut
self
,
tp
:
TyParam
)
->
TyParam
{
noop_fold_ty_param
(
tp
,
self
)
}
fn
fold_generic_param
(
&
mut
self
,
param
:
GenericParam
)
->
GenericParam
{
noop_fold_generic_param
(
param
,
self
)
}
...
...
@@ -268,17 +268,16 @@ fn fold_interpolated(&mut self, nt: token::Nonterminal) -> token::Nonterminal {
noop_fold_interpolated
(
nt
,
self
)
}
fn
fold_opt_bounds
(
&
mut
self
,
b
:
Option
<
TyParamBounds
>
)
->
Option
<
Ty
ParamBounds
>
{
fn
fold_opt_bounds
(
&
mut
self
,
b
:
Option
<
ParamBounds
>
)
->
Option
<
ParamBounds
>
{
noop_fold_opt_bounds
(
b
,
self
)
}
fn
fold_bounds
(
&
mut
self
,
b
:
ParamBounds
)
->
ParamBounds
{
fn
fold_bounds
(
&
mut
self
,
b
:
ParamBounds
)
->
ParamBounds
{
noop_fold_bounds
(
b
,
self
)
}
fn
fold_
ty_
param_bound
(
&
mut
self
,
tpb
:
ParamBound
)
->
ParamBound
{
noop_fold_
ty_
param_bound
(
tpb
,
self
)
fn
fold_param_bound
(
&
mut
self
,
tpb
:
ParamBound
)
->
ParamBound
{
noop_fold_param_bound
(
tpb
,
self
)
}
fn
fold_mt
(
&
mut
self
,
mt
:
MutTy
)
->
MutTy
{
...
...
@@ -391,10 +390,10 @@ pub fn noop_fold_ty<T: Folder>(t: P<Ty>, fld: &mut T) -> P<Ty> {
TyKind
::
Typeof
(
fld
.fold_anon_const
(
expr
))
}
TyKind
::
TraitObject
(
bounds
,
syntax
)
=>
{
TyKind
::
TraitObject
(
bounds
.move_map
(|
b
|
fld
.fold_
ty_
param_bound
(
b
)),
syntax
)
TyKind
::
TraitObject
(
bounds
.move_map
(|
b
|
fld
.fold_param_bound
(
b
)),
syntax
)
}
TyKind
::
ImplTrait
(
bounds
)
=>
{
TyKind
::
ImplTrait
(
bounds
.move_map
(|
b
|
fld
.fold_
ty_
param_bound
(
b
)))
TyKind
::
ImplTrait
(
bounds
.move_map
(|
b
|
fld
.fold_param_bound
(
b
)))
}
TyKind
::
Mac
(
mac
)
=>
{
TyKind
::
Mac
(
fld
.fold_mac
(
mac
))
...
...
@@ -677,32 +676,31 @@ pub fn noop_fold_fn_decl<T: Folder>(decl: P<FnDecl>, fld: &mut T) -> P<FnDecl> {
})
}
pub
fn
noop_fold_
ty_param_bound
<
T
>
(
tpb
:
ParamBound
,
fld
:
&
mut
T
)
->
ParamBound
where
T
:
Folder
{
match
tpb
{
TraitTyParamBound
(
ty
,
modifier
)
=>
TraitTyParamBound
(
fld
.fold_poly_trait_ref
(
ty
),
modifier
),
pub
fn
noop_fold_
param_bound
<
T
>
(
pb
:
ParamBound
,
fld
:
&
mut
T
)
->
ParamBound
where
T
:
Folder
{
match
pb
{
TraitTyParamBound
(
ty
,
modifier
)
=>
{
TraitTyParamBound
(
fld
.fold_poly_trait_ref
(
ty
),
modifier
)
}
Outlives
(
lifetime
)
=>
Outlives
(
noop_fold_lifetime
(
lifetime
,
fld
)),
}
}
pub
fn
noop_fold_generic_param
<
T
:
Folder
>
(
param
:
GenericParam
,
fld
:
&
mut
T
)
->
GenericParam
{
match
param
.kind
{
GenericParamKind
::
Lifetime
{
bounds
,
lifetime
}
=>
{
let
attrs
:
Vec
<
_
>
=
param
.attrs
.into
();
GenericParamKind
::
Lifetime
(
LifetimeDef
{
attrs
:
attrs
.into_iter
()
let
attrs
:
Vec
<
_
>
=
param
.attrs
.into
();
GenericParam
{
ident
:
fld
.fold_ident
(
param
.ident
),
id
:
fld
.new_id
(
param
.id
),
attrs
:
attrs
.into_iter
()
.flat_map
(|
x
|
fld
.fold_attribute
(
x
)
.into_iter
())
.collect
::
<
Vec
<
_
>>
()
.into
(),
lifetime
:
Lifetime
{
id
:
fld
.new_id
(
param
.id
),
ident
:
fld
.fold_ident
(
param
.ident
)
,
},
bounds
:
bounds
.move_map
(|
l
|
noop_fold_lifetime
(
l
,
fld
)),
}
)
bounds
:
param
.bounds
.move_map
(|
l
|
noop_fold_param_bound
(
l
,
fld
)),
kind
:
match
param
.kind
{
GenericParamKind
::
Lifetime
=>
GenericParamKind
::
Lifetime
,
GenericParamKind
::
Type
{
default
}
=>
GenericParamKind
::
Type
{
default
:
default
.map
(|
ty
|
fld
.fold_ty
(
ty
))
}
}
GenericParamKind
::
Type
{
..
}
=>
GenericParamKind
::
Type
(
fld
.fold_ty_param
(
param
)),
}
}
...
...
@@ -760,7 +758,7 @@ pub fn noop_fold_where_predicate<T: Folder>(
ast
::
WherePredicate
::
BoundPredicate
(
ast
::
WhereBoundPredicate
{
bound_generic_params
:
fld
.fold_generic_params
(
bound_generic_params
),
bounded_ty
:
fld
.fold_ty
(
bounded_ty
),
bounds
:
bounds
.move_map
(|
x
|
fld
.fold_
ty_
param_bound
(
x
)),
bounds
:
bounds
.move_map
(|
x
|
fld
.fold_param_bound
(
x
)),
span
:
fld
.new_span
(
span
)
})
}
...
...
@@ -770,7 +768,7 @@ pub fn noop_fold_where_predicate<T: Folder>(
ast
::
WherePredicate
::
RegionPredicate
(
ast
::
WhereRegionPredicate
{
span
:
fld
.new_span
(
span
),
lifetime
:
noop_fold_lifetime
(
lifetime
,
fld
),
bounds
:
bounds
.move_map
(|
bound
|
noop_fold_
lifetime
(
bound
,
fld
))
bounds
:
bounds
.move_map
(|
bound
|
noop_fold_
param_bound
(
bound
,
fld
))
})
}
ast
::
WherePredicate
::
EqPredicate
(
ast
::
WhereEqPredicate
{
id
,
...
...
@@ -856,7 +854,7 @@ pub fn noop_fold_opt_bounds<T: Folder>(b: Option<ParamBounds>, folder: &mut T)
fn
noop_fold_bounds
<
T
:
Folder
>
(
bounds
:
ParamBounds
,
folder
:
&
mut
T
)
->
ParamBounds
{
bounds
.move_map
(|
bound
|
folder
.fold_
ty_
param_bound
(
bound
))
bounds
.move_map
(|
bound
|
folder
.fold_param_bound
(
bound
))
}
pub
fn
noop_fold_block
<
T
:
Folder
>
(
b
:
P
<
Block
>
,
folder
:
&
mut
T
)
->
P
<
Block
>
{
...
...
src/libsyntax/visit.rs
浏览文件 @
831b5c02
...
...
@@ -492,15 +492,10 @@ pub fn walk_param_bound<'a, V: Visitor<'a>>(visitor: &mut V, bound: &'a ParamBou
pub
fn
walk_generic_param
<
'a
,
V
:
Visitor
<
'a
>>
(
visitor
:
&
mut
V
,
param
:
&
'a
GenericParam
)
{
visitor
.visit_ident
(
param
.ident
);
walk_list!
(
visitor
,
visit_param_bound
,
&
param
.bounds
);
match
param
.kind
{
GenericParamKind
::
Lifetime
{
ref
bounds
,
ref
lifetime
}
=>
{
walk_list!
(
visitor
,
visit_lifetime
,
bounds
);
}
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
);
}
GenericParamKind
::
Lifetime
=>
{}
GenericParamKind
::
Type
{
ref
default
}
=>
walk_list!
(
visitor
,
visit_ty
,
default
),
}
walk_list!
(
visitor
,
visit_attribute
,
param
.attrs
.iter
());
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录