Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
94c345b6
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,发现更多精彩内容 >>
提交
94c345b6
编写于
1月 04, 2015
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Convert astconv and friends to use object types, not generics. No need to compile
all that stuff twice. Also, code reads so much nicer.
上级
1f732ef5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
103 addition
and
119 deletion
+103
-119
src/librustc_typeck/astconv.rs
src/librustc_typeck/astconv.rs
+103
-119
未找到文件。
src/librustc_typeck/astconv.rs
浏览文件 @
94c345b6
...
@@ -70,7 +70,9 @@
...
@@ -70,7 +70,9 @@
pub
trait
AstConv
<
'tcx
>
{
pub
trait
AstConv
<
'tcx
>
{
fn
tcx
<
'a
>
(
&
'a
self
)
->
&
'a
ty
::
ctxt
<
'tcx
>
;
fn
tcx
<
'a
>
(
&
'a
self
)
->
&
'a
ty
::
ctxt
<
'tcx
>
;
fn
get_item_type_scheme
(
&
self
,
id
:
ast
::
DefId
)
->
ty
::
TypeScheme
<
'tcx
>
;
fn
get_item_type_scheme
(
&
self
,
id
:
ast
::
DefId
)
->
ty
::
TypeScheme
<
'tcx
>
;
fn
get_trait_def
(
&
self
,
id
:
ast
::
DefId
)
->
Rc
<
ty
::
TraitDef
<
'tcx
>>
;
fn
get_trait_def
(
&
self
,
id
:
ast
::
DefId
)
->
Rc
<
ty
::
TraitDef
<
'tcx
>>
;
/// Return an (optional) substitution to convert bound type parameters that
/// Return an (optional) substitution to convert bound type parameters that
...
@@ -162,9 +164,9 @@ pub fn ast_region_to_region(tcx: &ty::ctxt, lifetime: &ast::Lifetime)
...
@@ -162,9 +164,9 @@ pub fn ast_region_to_region(tcx: &ty::ctxt, lifetime: &ast::Lifetime)
r
r
}
}
pub
fn
opt_ast_region_to_region
<
'tcx
,
AC
:
AstConv
<
'tcx
>
,
RS
:
RegionScope
>
(
pub
fn
opt_ast_region_to_region
<
'tcx
>
(
this
:
&
A
C
,
this
:
&
A
stConv
<
'tcx
>
,
rscope
:
&
R
S
,
rscope
:
&
R
egionScope
,
default_span
:
Span
,
default_span
:
Span
,
opt_lifetime
:
&
Option
<
ast
::
Lifetime
>
)
->
ty
::
Region
opt_lifetime
:
&
Option
<
ast
::
Lifetime
>
)
->
ty
::
Region
{
{
...
@@ -241,13 +243,12 @@ pub fn opt_ast_region_to_region<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
...
@@ -241,13 +243,12 @@ pub fn opt_ast_region_to_region<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
/// Given a path `path` that refers to an item `I` with the declared generics `decl_generics`,
/// Given a path `path` that refers to an item `I` with the declared generics `decl_generics`,
/// returns an appropriate set of substitutions for this particular reference to `I`.
/// returns an appropriate set of substitutions for this particular reference to `I`.
fn
ast_path_substs_for_ty
<
'tcx
,
AC
,
RS
>
(
fn
ast_path_substs_for_ty
<
'tcx
>
(
this
:
&
A
C
,
this
:
&
A
stConv
<
'tcx
>
,
rscope
:
&
R
S
,
rscope
:
&
R
egionScope
,
decl_generics
:
&
ty
::
Generics
<
'tcx
>
,
decl_generics
:
&
ty
::
Generics
<
'tcx
>
,
path
:
&
ast
::
Path
)
path
:
&
ast
::
Path
)
->
Substs
<
'tcx
>
->
Substs
<
'tcx
>
where
AC
:
AstConv
<
'tcx
>
,
RS
:
RegionScope
{
{
let
tcx
=
this
.tcx
();
let
tcx
=
this
.tcx
();
...
@@ -285,16 +286,15 @@ fn ast_path_substs_for_ty<'tcx,AC,RS>(
...
@@ -285,16 +286,15 @@ fn ast_path_substs_for_ty<'tcx,AC,RS>(
regions
)
regions
)
}
}
fn
create_substs_for_ast_path
<
'tcx
,
AC
,
RS
>
(
fn
create_substs_for_ast_path
<
'tcx
>
(
this
:
&
A
C
,
this
:
&
A
stConv
<
'tcx
>
,
rscope
:
&
R
S
,
rscope
:
&
R
egionScope
,
span
:
Span
,
span
:
Span
,
decl_generics
:
&
ty
::
Generics
<
'tcx
>
,
decl_generics
:
&
ty
::
Generics
<
'tcx
>
,
self_ty
:
Option
<
Ty
<
'tcx
>>
,
self_ty
:
Option
<
Ty
<
'tcx
>>
,
types
:
Vec
<
Ty
<
'tcx
>>
,
types
:
Vec
<
Ty
<
'tcx
>>
,
regions
:
Vec
<
ty
::
Region
>
)
regions
:
Vec
<
ty
::
Region
>
)
->
Substs
<
'tcx
>
->
Substs
<
'tcx
>
where
AC
:
AstConv
<
'tcx
>
,
RS
:
RegionScope
{
{
let
tcx
=
this
.tcx
();
let
tcx
=
this
.tcx
();
...
@@ -408,13 +408,12 @@ struct ConvertedBinding<'tcx> {
...
@@ -408,13 +408,12 @@ struct ConvertedBinding<'tcx> {
span
:
Span
,
span
:
Span
,
}
}
fn
convert_angle_bracketed_parameters
<
'tcx
,
AC
,
RS
>
(
this
:
&
AC
,
fn
convert_angle_bracketed_parameters
<
'tcx
>
(
this
:
&
AstConv
<
'tcx
>
,
rscope
:
&
RS
,
rscope
:
&
RegionScope
,
data
:
&
ast
::
AngleBracketedParameterData
)
data
:
&
ast
::
AngleBracketedParameterData
)
->
(
Vec
<
ty
::
Region
>
,
->
(
Vec
<
ty
::
Region
>
,
Vec
<
Ty
<
'tcx
>>
,
Vec
<
Ty
<
'tcx
>>
,
Vec
<
ConvertedBinding
<
'tcx
>>
)
Vec
<
ConvertedBinding
<
'tcx
>>
)
where
AC
:
AstConv
<
'tcx
>
,
RS
:
RegionScope
{
{
let
regions
:
Vec
<
_
>
=
let
regions
:
Vec
<
_
>
=
data
.lifetimes
.iter
()
data
.lifetimes
.iter
()
...
@@ -468,12 +467,11 @@ fn find_implied_output_region(input_tys: &[Ty], input_pats: Vec<String>)
...
@@ -468,12 +467,11 @@ fn find_implied_output_region(input_tys: &[Ty], input_pats: Vec<String>)
(
implied_output_region
,
lifetimes_for_params
)
(
implied_output_region
,
lifetimes_for_params
)
}
}
fn
convert_ty_with_lifetime_elision
<
'tcx
,
AC
>
(
this
:
&
AC
,
fn
convert_ty_with_lifetime_elision
<
'tcx
>
(
this
:
&
AstConv
<
'tcx
>
,
implied_output_region
:
Option
<
ty
::
Region
>
,
implied_output_region
:
Option
<
ty
::
Region
>
,
param_lifetimes
:
Vec
<
(
String
,
uint
)
>
,
param_lifetimes
:
Vec
<
(
String
,
uint
)
>
,
ty
:
&
ast
::
Ty
)
ty
:
&
ast
::
Ty
)
->
Ty
<
'tcx
>
->
Ty
<
'tcx
>
where
AC
:
AstConv
<
'tcx
>
{
{
match
implied_output_region
{
match
implied_output_region
{
Some
(
implied_output_region
)
=>
{
Some
(
implied_output_region
)
=>
{
...
@@ -490,10 +488,9 @@ fn convert_ty_with_lifetime_elision<'tcx,AC>(this: &AC,
...
@@ -490,10 +488,9 @@ fn convert_ty_with_lifetime_elision<'tcx,AC>(this: &AC,
}
}
}
}
fn
convert_parenthesized_parameters
<
'tcx
,
AC
>
(
this
:
&
AC
,
fn
convert_parenthesized_parameters
<
'tcx
>
(
this
:
&
AstConv
<
'tcx
>
,
data
:
&
ast
::
ParenthesizedParameterData
)
data
:
&
ast
::
ParenthesizedParameterData
)
->
Vec
<
Ty
<
'tcx
>>
->
Vec
<
Ty
<
'tcx
>>
where
AC
:
AstConv
<
'tcx
>
{
{
let
binding_rscope
=
BindingRscope
::
new
();
let
binding_rscope
=
BindingRscope
::
new
();
let
inputs
=
data
.inputs
.iter
()
let
inputs
=
data
.inputs
.iter
()
...
@@ -517,14 +514,13 @@ fn convert_parenthesized_parameters<'tcx,AC>(this: &AC,
...
@@ -517,14 +514,13 @@ fn convert_parenthesized_parameters<'tcx,AC>(this: &AC,
vec!
[
input_ty
,
output
]
vec!
[
input_ty
,
output
]
}
}
pub
fn
instantiate_poly_trait_ref
<
'tcx
,
AC
,
RS
>
(
pub
fn
instantiate_poly_trait_ref
<
'tcx
>
(
this
:
&
A
C
,
this
:
&
A
stConv
<
'tcx
>
,
rscope
:
&
R
S
,
rscope
:
&
R
egionScope
,
ast_trait_ref
:
&
ast
::
PolyTraitRef
,
ast_trait_ref
:
&
ast
::
PolyTraitRef
,
self_ty
:
Option
<
Ty
<
'tcx
>>
,
self_ty
:
Option
<
Ty
<
'tcx
>>
,
poly_projections
:
&
mut
Vec
<
ty
::
PolyProjectionPredicate
<
'tcx
>>
)
poly_projections
:
&
mut
Vec
<
ty
::
PolyProjectionPredicate
<
'tcx
>>
)
->
ty
::
PolyTraitRef
<
'tcx
>
->
ty
::
PolyTraitRef
<
'tcx
>
where
AC
:
AstConv
<
'tcx
>
,
RS
:
RegionScope
{
{
let
mut
projections
=
Vec
::
new
();
let
mut
projections
=
Vec
::
new
();
...
@@ -545,14 +541,13 @@ pub fn instantiate_poly_trait_ref<'tcx,AC,RS>(
...
@@ -545,14 +541,13 @@ pub fn instantiate_poly_trait_ref<'tcx,AC,RS>(
///
///
/// If the `projections` argument is `None`, then assoc type bindings like `Foo<T=X>`
/// If the `projections` argument is `None`, then assoc type bindings like `Foo<T=X>`
/// are disallowed. Otherwise, they are pushed onto the vector given.
/// are disallowed. Otherwise, they are pushed onto the vector given.
pub
fn
instantiate_trait_ref
<
'tcx
,
AC
,
RS
>
(
pub
fn
instantiate_trait_ref
<
'tcx
>
(
this
:
&
A
C
,
this
:
&
A
stConv
<
'tcx
>
,
rscope
:
&
R
S
,
rscope
:
&
R
egionScope
,
ast_trait_ref
:
&
ast
::
TraitRef
,
ast_trait_ref
:
&
ast
::
TraitRef
,
self_ty
:
Option
<
Ty
<
'tcx
>>
,
self_ty
:
Option
<
Ty
<
'tcx
>>
,
projections
:
Option
<&
mut
Vec
<
ty
::
ProjectionPredicate
<
'tcx
>>>
)
projections
:
Option
<&
mut
Vec
<
ty
::
ProjectionPredicate
<
'tcx
>>>
)
->
Rc
<
ty
::
TraitRef
<
'tcx
>>
->
Rc
<
ty
::
TraitRef
<
'tcx
>>
where
AC
:
AstConv
<
'tcx
>
,
RS
:
RegionScope
{
{
match
::
lookup_def_tcx
(
this
.tcx
(),
ast_trait_ref
.path.span
,
ast_trait_ref
.ref_id
)
{
match
::
lookup_def_tcx
(
this
.tcx
(),
ast_trait_ref
.path.span
,
ast_trait_ref
.ref_id
)
{
def
::
DefTrait
(
trait_def_id
)
=>
{
def
::
DefTrait
(
trait_def_id
)
=>
{
...
@@ -573,15 +568,14 @@ pub fn instantiate_trait_ref<'tcx,AC,RS>(
...
@@ -573,15 +568,14 @@ pub fn instantiate_trait_ref<'tcx,AC,RS>(
}
}
}
}
fn
ast_path_to_trait_ref
<
'a
,
'tcx
,
AC
,
RS
>
(
fn
ast_path_to_trait_ref
<
'a
,
'tcx
>
(
this
:
&
A
C
,
this
:
&
A
stConv
<
'tcx
>
,
rscope
:
&
R
S
,
rscope
:
&
R
egionScope
,
trait_def_id
:
ast
::
DefId
,
trait_def_id
:
ast
::
DefId
,
self_ty
:
Option
<
Ty
<
'tcx
>>
,
self_ty
:
Option
<
Ty
<
'tcx
>>
,
path
:
&
ast
::
Path
,
path
:
&
ast
::
Path
,
mut
projections
:
Option
<&
mut
Vec
<
ty
::
ProjectionPredicate
<
'tcx
>>>
)
mut
projections
:
Option
<&
mut
Vec
<
ty
::
ProjectionPredicate
<
'tcx
>>>
)
->
Rc
<
ty
::
TraitRef
<
'tcx
>>
->
Rc
<
ty
::
TraitRef
<
'tcx
>>
where
AC
:
AstConv
<
'tcx
>
,
RS
:
RegionScope
{
{
debug!
(
"ast_path_to_trait_ref {}"
,
path
);
debug!
(
"ast_path_to_trait_ref {}"
,
path
);
let
trait_def
=
this
.get_trait_def
(
trait_def_id
);
let
trait_def
=
this
.get_trait_def
(
trait_def_id
);
...
@@ -643,12 +637,11 @@ fn ast_path_to_trait_ref<'a,'tcx,AC,RS>(
...
@@ -643,12 +637,11 @@ fn ast_path_to_trait_ref<'a,'tcx,AC,RS>(
trait_ref
trait_ref
}
}
pub
fn
ast_type_binding_to_projection_predicate
<
'tcx
,
AC
>
(
pub
fn
ast_type_binding_to_projection_predicate
<
'tcx
>
(
this
:
&
A
C
,
this
:
&
A
stConv
<
'tcx
>
,
trait_ref
:
Rc
<
ty
::
TraitRef
<
'tcx
>>
,
trait_ref
:
Rc
<
ty
::
TraitRef
<
'tcx
>>
,
binding
:
&
ConvertedBinding
<
'tcx
>
)
binding
:
&
ConvertedBinding
<
'tcx
>
)
->
Result
<
ty
::
ProjectionPredicate
<
'tcx
>
,
ErrorReported
>
->
Result
<
ty
::
ProjectionPredicate
<
'tcx
>
,
ErrorReported
>
where
AC
:
AstConv
<
'tcx
>
{
{
// Given something like `U : SomeTrait<T=X>`, we want to produce a
// Given something like `U : SomeTrait<T=X>`, we want to produce a
// predicate like `<U as SomeTrait>::T = X`. This is somewhat
// predicate like `<U as SomeTrait>::T = X`. This is somewhat
...
@@ -686,9 +679,9 @@ pub fn ast_type_binding_to_projection_predicate<'tcx,AC>(
...
@@ -686,9 +679,9 @@ pub fn ast_type_binding_to_projection_predicate<'tcx,AC>(
})
})
}
}
pub
fn
ast_path_to_ty
<
'tcx
,
AC
:
AstConv
<
'tcx
>
,
RS
:
RegionScope
>
(
pub
fn
ast_path_to_ty
<
'tcx
>
(
this
:
&
A
C
,
this
:
&
A
stConv
<
'tcx
>
,
rscope
:
&
R
S
,
rscope
:
&
R
egionScope
,
did
:
ast
::
DefId
,
did
:
ast
::
DefId
,
path
:
&
ast
::
Path
)
path
:
&
ast
::
Path
)
->
TypeAndSubsts
<
'tcx
>
->
TypeAndSubsts
<
'tcx
>
...
@@ -712,13 +705,12 @@ pub fn ast_path_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
...
@@ -712,13 +705,12 @@ pub fn ast_path_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
/// and/or region variables are substituted.
/// and/or region variables are substituted.
///
///
/// This is used when checking the constructor in struct literals.
/// This is used when checking the constructor in struct literals.
pub
fn
ast_path_to_ty_relaxed
<
'tcx
,
AC
,
RS
>
(
pub
fn
ast_path_to_ty_relaxed
<
'tcx
>
(
this
:
&
A
C
,
this
:
&
A
stConv
<
'tcx
>
,
rscope
:
&
R
S
,
rscope
:
&
R
egionScope
,
did
:
ast
::
DefId
,
did
:
ast
::
DefId
,
path
:
&
ast
::
Path
)
path
:
&
ast
::
Path
)
->
TypeAndSubsts
<
'tcx
>
->
TypeAndSubsts
<
'tcx
>
where
AC
:
AstConv
<
'tcx
>
,
RS
:
RegionScope
{
{
let
tcx
=
this
.tcx
();
let
tcx
=
this
.tcx
();
let
ty
::
TypeScheme
{
let
ty
::
TypeScheme
{
...
@@ -754,9 +746,9 @@ pub fn ast_path_to_ty_relaxed<'tcx,AC,RS>(
...
@@ -754,9 +746,9 @@ pub fn ast_path_to_ty_relaxed<'tcx,AC,RS>(
/// Converts the given AST type to a built-in type. A "built-in type" is, at
/// Converts the given AST type to a built-in type. A "built-in type" is, at
/// present, either a core numeric type, a string, or `Box`.
/// present, either a core numeric type, a string, or `Box`.
pub
fn
ast_ty_to_builtin_ty
<
'tcx
,
AC
:
AstConv
<
'tcx
>
,
RS
:
RegionScope
>
(
pub
fn
ast_ty_to_builtin_ty
<
'tcx
>
(
this
:
&
A
C
,
this
:
&
A
stConv
<
'tcx
>
,
rscope
:
&
R
S
,
rscope
:
&
R
egionScope
,
ast_ty
:
&
ast
::
Ty
)
ast_ty
:
&
ast
::
Ty
)
->
Option
<
Ty
<
'tcx
>>
{
->
Option
<
Ty
<
'tcx
>>
{
match
ast_ty_to_prim_ty
(
this
.tcx
(),
ast_ty
)
{
match
ast_ty_to_prim_ty
(
this
.tcx
(),
ast_ty
)
{
...
@@ -807,12 +799,11 @@ pub fn ast_ty_to_builtin_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
...
@@ -807,12 +799,11 @@ pub fn ast_ty_to_builtin_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
type
TraitAndProjections
<
'tcx
>
=
(
ty
::
PolyTraitRef
<
'tcx
>
,
Vec
<
ty
::
PolyProjectionPredicate
<
'tcx
>>
);
type
TraitAndProjections
<
'tcx
>
=
(
ty
::
PolyTraitRef
<
'tcx
>
,
Vec
<
ty
::
PolyProjectionPredicate
<
'tcx
>>
);
fn
ast_ty_to_trait_ref
<
'tcx
,
AC
,
RS
>
(
this
:
&
AC
,
fn
ast_ty_to_trait_ref
<
'tcx
>
(
this
:
&
AstConv
<
'tcx
>
,
rscope
:
&
RS
,
rscope
:
&
RegionScope
,
ty
:
&
ast
::
Ty
,
ty
:
&
ast
::
Ty
,
bounds
:
&
[
ast
::
TyParamBound
])
bounds
:
&
[
ast
::
TyParamBound
])
->
Result
<
TraitAndProjections
<
'tcx
>
,
ErrorReported
>
->
Result
<
TraitAndProjections
<
'tcx
>
,
ErrorReported
>
where
AC
:
AstConv
<
'tcx
>
,
RS
:
RegionScope
{
{
/*!
/*!
* In a type like `Foo + Send`, we want to wait to collect the
* In a type like `Foo + Send`, we want to wait to collect the
...
@@ -878,14 +869,13 @@ fn ast_ty_to_trait_ref<'tcx,AC,RS>(this: &AC,
...
@@ -878,14 +869,13 @@ fn ast_ty_to_trait_ref<'tcx,AC,RS>(this: &AC,
}
}
}
}
fn
trait_ref_to_object_type
<
'tcx
,
AC
,
RS
>
(
this
:
&
AC
,
fn
trait_ref_to_object_type
<
'tcx
>
(
this
:
&
AstConv
<
'tcx
>
,
rscope
:
&
RS
,
rscope
:
&
RegionScope
,
span
:
Span
,
span
:
Span
,
trait_ref
:
ty
::
PolyTraitRef
<
'tcx
>
,
trait_ref
:
ty
::
PolyTraitRef
<
'tcx
>
,
projection_bounds
:
Vec
<
ty
::
PolyProjectionPredicate
<
'tcx
>>
,
projection_bounds
:
Vec
<
ty
::
PolyProjectionPredicate
<
'tcx
>>
,
bounds
:
&
[
ast
::
TyParamBound
])
bounds
:
&
[
ast
::
TyParamBound
])
->
Ty
<
'tcx
>
->
Ty
<
'tcx
>
where
AC
:
AstConv
<
'tcx
>
,
RS
:
RegionScope
{
{
let
existential_bounds
=
conv_existential_bounds
(
this
,
let
existential_bounds
=
conv_existential_bounds
(
this
,
rscope
,
rscope
,
...
@@ -963,12 +953,11 @@ fn trait_defines_associated_type_named(this: &AstConv,
...
@@ -963,12 +953,11 @@ fn trait_defines_associated_type_named(this: &AstConv,
trait_def
.associated_type_names
.contains
(
&
assoc_name
)
trait_def
.associated_type_names
.contains
(
&
assoc_name
)
}
}
fn
qpath_to_ty
<
'tcx
,
AC
,
RS
>
(
this
:
&
AC
,
fn
qpath_to_ty
<
'tcx
>
(
this
:
&
AstConv
<
'tcx
>
,
rscope
:
&
RS
,
rscope
:
&
RegionScope
,
ast_ty
:
&
ast
::
Ty
,
// the TyQPath
ast_ty
:
&
ast
::
Ty
,
// the TyQPath
qpath
:
&
ast
::
QPath
)
qpath
:
&
ast
::
QPath
)
->
Ty
<
'tcx
>
->
Ty
<
'tcx
>
where
AC
:
AstConv
<
'tcx
>
,
RS
:
RegionScope
{
{
debug!
(
"qpath_to_ty(ast_ty={})"
,
debug!
(
"qpath_to_ty(ast_ty={})"
,
ast_ty
.repr
(
this
.tcx
()));
ast_ty
.repr
(
this
.tcx
()));
...
@@ -992,8 +981,8 @@ fn qpath_to_ty<'tcx,AC,RS>(this: &AC,
...
@@ -992,8 +981,8 @@ fn qpath_to_ty<'tcx,AC,RS>(this: &AC,
// Parses the programmer's textual representation of a type into our
// Parses the programmer's textual representation of a type into our
// internal notion of a type.
// internal notion of a type.
pub
fn
ast_ty_to_ty
<
'tcx
,
AC
:
AstConv
<
'tcx
>
,
RS
:
RegionScope
>
(
pub
fn
ast_ty_to_ty
<
'tcx
>
(
this
:
&
A
C
,
rscope
:
&
RS
,
ast_ty
:
&
ast
::
Ty
)
->
Ty
<
'tcx
>
this
:
&
A
stConv
<
'tcx
>
,
rscope
:
&
RegionScope
,
ast_ty
:
&
ast
::
Ty
)
->
Ty
<
'tcx
>
{
{
debug!
(
"ast_ty_to_ty(ast_ty={})"
,
debug!
(
"ast_ty_to_ty(ast_ty={})"
,
ast_ty
.repr
(
this
.tcx
()));
ast_ty
.repr
(
this
.tcx
()));
...
@@ -1205,10 +1194,12 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
...
@@ -1205,10 +1194,12 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
return
typ
;
return
typ
;
}
}
pub
fn
ty_of_arg
<
'tcx
,
AC
:
AstConv
<
'tcx
>
,
RS
:
RegionScope
>
(
this
:
&
AC
,
rscope
:
&
RS
,
pub
fn
ty_of_arg
<
'tcx
>
(
this
:
&
AstConv
<
'tcx
>
,
a
:
&
ast
::
Arg
,
rscope
:
&
RegionScope
,
expected_ty
:
Option
<
Ty
<
'tcx
>>
)
a
:
&
ast
::
Arg
,
->
Ty
<
'tcx
>
{
expected_ty
:
Option
<
Ty
<
'tcx
>>
)
->
Ty
<
'tcx
>
{
match
a
.ty.node
{
match
a
.ty.node
{
ast
::
TyInfer
if
expected_ty
.is_some
()
=>
expected_ty
.unwrap
(),
ast
::
TyInfer
if
expected_ty
.is_some
()
=>
expected_ty
.unwrap
(),
ast
::
TyInfer
=>
this
.ty_infer
(
a
.ty.span
),
ast
::
TyInfer
=>
this
.ty_infer
(
a
.ty.span
),
...
@@ -1221,14 +1212,13 @@ struct SelfInfo<'a, 'tcx> {
...
@@ -1221,14 +1212,13 @@ struct SelfInfo<'a, 'tcx> {
explicit_self
:
&
'a
ast
::
ExplicitSelf
,
explicit_self
:
&
'a
ast
::
ExplicitSelf
,
}
}
pub
fn
ty_of_method
<
'tcx
,
AC
:
AstConv
<
'tcx
>>
(
pub
fn
ty_of_method
<
'tcx
>
(
this
:
&
AstConv
<
'tcx
>
,
this
:
&
AC
,
unsafety
:
ast
::
Unsafety
,
unsafety
:
ast
::
Unsafety
,
untransformed_self_ty
:
Ty
<
'tcx
>
,
untransformed_self_ty
:
Ty
<
'tcx
>
,
explicit_self
:
&
ast
::
ExplicitSelf
,
explicit_self
:
&
ast
::
ExplicitSelf
,
decl
:
&
ast
::
FnDecl
,
decl
:
&
ast
::
FnDecl
,
abi
:
abi
::
Abi
)
abi
:
abi
::
Abi
)
->
(
ty
::
BareFnTy
<
'tcx
>
,
ty
::
ExplicitSelfCategory
)
{
->
(
ty
::
BareFnTy
<
'tcx
>
,
ty
::
ExplicitSelfCategory
)
{
let
self_info
=
Some
(
SelfInfo
{
let
self_info
=
Some
(
SelfInfo
{
untransformed_self_ty
:
untransformed_self_ty
,
untransformed_self_ty
:
untransformed_self_ty
,
explicit_self
:
explicit_self
,
explicit_self
:
explicit_self
,
...
@@ -1242,20 +1232,18 @@ pub fn ty_of_method<'tcx, AC: AstConv<'tcx>>(
...
@@ -1242,20 +1232,18 @@ pub fn ty_of_method<'tcx, AC: AstConv<'tcx>>(
(
bare_fn_ty
,
optional_explicit_self_category
.unwrap
())
(
bare_fn_ty
,
optional_explicit_self_category
.unwrap
())
}
}
pub
fn
ty_of_bare_fn
<
'tcx
,
AC
:
AstConv
<
'tcx
>>
(
this
:
&
AC
,
unsafety
:
ast
::
Unsafety
,
abi
:
abi
::
Abi
,
pub
fn
ty_of_bare_fn
<
'tcx
>
(
this
:
&
AstConv
<
'tcx
>
,
unsafety
:
ast
::
Unsafety
,
abi
:
abi
::
Abi
,
decl
:
&
ast
::
FnDecl
)
->
ty
::
BareFnTy
<
'tcx
>
{
decl
:
&
ast
::
FnDecl
)
->
ty
::
BareFnTy
<
'tcx
>
{
let
(
bare_fn_ty
,
_
)
=
ty_of_method_or_bare_fn
(
this
,
unsafety
,
abi
,
None
,
decl
);
let
(
bare_fn_ty
,
_
)
=
ty_of_method_or_bare_fn
(
this
,
unsafety
,
abi
,
None
,
decl
);
bare_fn_ty
bare_fn_ty
}
}
fn
ty_of_method_or_bare_fn
<
'a
,
'tcx
,
AC
:
AstConv
<
'tcx
>>
(
fn
ty_of_method_or_bare_fn
<
'a
,
'tcx
>
(
this
:
&
AstConv
<
'tcx
>
,
this
:
&
AC
,
unsafety
:
ast
::
Unsafety
,
unsafety
:
ast
::
Unsafety
,
abi
:
abi
::
Abi
,
abi
:
abi
::
Abi
,
opt_self_info
:
Option
<
SelfInfo
<
'a
,
'tcx
>>
,
opt_self_info
:
Option
<
SelfInfo
<
'a
,
'tcx
>>
,
decl
:
&
ast
::
FnDecl
)
decl
:
&
ast
::
FnDecl
)
->
(
ty
::
BareFnTy
<
'tcx
>
,
Option
<
ty
::
ExplicitSelfCategory
>
)
->
(
ty
::
BareFnTy
<
'tcx
>
,
Option
<
ty
::
ExplicitSelfCategory
>
)
{
{
debug!
(
"ty_of_method_or_bare_fn"
);
debug!
(
"ty_of_method_or_bare_fn"
);
...
@@ -1357,12 +1345,10 @@ fn ty_of_method_or_bare_fn<'a, 'tcx, AC: AstConv<'tcx>>(
...
@@ -1357,12 +1345,10 @@ fn ty_of_method_or_bare_fn<'a, 'tcx, AC: AstConv<'tcx>>(
},
explicit_self_category_result
)
},
explicit_self_category_result
)
}
}
fn
determine_explicit_self_category
<
'a
,
'tcx
,
AC
:
AstConv
<
'tcx
>
,
fn
determine_explicit_self_category
<
'a
,
'tcx
>
(
this
:
&
AstConv
<
'tcx
>
,
RS
:
RegionScope
>
(
rscope
:
&
RegionScope
,
this
:
&
AC
,
self_info
:
&
SelfInfo
<
'a
,
'tcx
>
)
rscope
:
&
RS
,
->
ty
::
ExplicitSelfCategory
self_info
:
&
SelfInfo
<
'a
,
'tcx
>
)
->
ty
::
ExplicitSelfCategory
{
{
return
match
self_info
.explicit_self.node
{
return
match
self_info
.explicit_self.node
{
ast
::
SelfStatic
=>
ty
::
StaticExplicitSelfCategory
,
ast
::
SelfStatic
=>
ty
::
StaticExplicitSelfCategory
,
...
@@ -1439,8 +1425,8 @@ fn count_modifiers(ty: Ty) -> uint {
...
@@ -1439,8 +1425,8 @@ fn count_modifiers(ty: Ty) -> uint {
}
}
}
}
pub
fn
ty_of_closure
<
'tcx
,
AC
:
AstConv
<
'tcx
>
>
(
pub
fn
ty_of_closure
<
'tcx
>
(
this
:
&
A
C
,
this
:
&
A
stConv
<
'tcx
>
,
unsafety
:
ast
::
Unsafety
,
unsafety
:
ast
::
Unsafety
,
onceness
:
ast
::
Onceness
,
onceness
:
ast
::
Onceness
,
bounds
:
ty
::
ExistentialBounds
<
'tcx
>
,
bounds
:
ty
::
ExistentialBounds
<
'tcx
>
,
...
@@ -1501,9 +1487,9 @@ pub fn ty_of_closure<'tcx, AC: AstConv<'tcx>>(
...
@@ -1501,9 +1487,9 @@ pub fn ty_of_closure<'tcx, AC: AstConv<'tcx>>(
/// `ExistentialBounds` struct. The `main_trait_refs` argument specifies the `Foo` -- it is absent
/// `ExistentialBounds` struct. The `main_trait_refs` argument specifies the `Foo` -- it is absent
/// for closures. Eventually this should all be normalized, I think, so that there is no "main
/// for closures. Eventually this should all be normalized, I think, so that there is no "main
/// trait ref" and instead we just have a flat list of bounds as the existential type.
/// trait ref" and instead we just have a flat list of bounds as the existential type.
pub
fn
conv_existential_bounds
<
'tcx
,
AC
:
AstConv
<
'tcx
>
,
RS
:
RegionScope
>
(
pub
fn
conv_existential_bounds
<
'tcx
>
(
this
:
&
A
C
,
this
:
&
A
stConv
<
'tcx
>
,
rscope
:
&
R
S
,
rscope
:
&
R
egionScope
,
span
:
Span
,
span
:
Span
,
principal_trait_ref
:
Option
<
ty
::
PolyTraitRef
<
'tcx
>>
,
// None for boxed closures
principal_trait_ref
:
Option
<
ty
::
PolyTraitRef
<
'tcx
>>
,
// None for boxed closures
projection_bounds
:
Vec
<
ty
::
PolyProjectionPredicate
<
'tcx
>>
,
projection_bounds
:
Vec
<
ty
::
PolyProjectionPredicate
<
'tcx
>>
,
...
@@ -1517,13 +1503,12 @@ pub fn conv_existential_bounds<'tcx, AC: AstConv<'tcx>, RS:RegionScope>(
...
@@ -1517,13 +1503,12 @@ pub fn conv_existential_bounds<'tcx, AC: AstConv<'tcx>, RS:RegionScope>(
this
,
rscope
,
span
,
principal_trait_ref
,
projection_bounds
,
partitioned_bounds
)
this
,
rscope
,
span
,
principal_trait_ref
,
projection_bounds
,
partitioned_bounds
)
}
}
fn
conv_ty_poly_trait_ref
<
'tcx
,
AC
,
RS
>
(
fn
conv_ty_poly_trait_ref
<
'tcx
>
(
this
:
&
A
C
,
this
:
&
A
stConv
<
'tcx
>
,
rscope
:
&
R
S
,
rscope
:
&
R
egionScope
,
span
:
Span
,
span
:
Span
,
ast_bounds
:
&
[
ast
::
TyParamBound
])
ast_bounds
:
&
[
ast
::
TyParamBound
])
->
Ty
<
'tcx
>
->
Ty
<
'tcx
>
where
AC
:
AstConv
<
'tcx
>
,
RS
:
RegionScope
{
{
let
mut
partitioned_bounds
=
partition_bounds
(
this
.tcx
(),
span
,
ast_bounds
[]);
let
mut
partitioned_bounds
=
partition_bounds
(
this
.tcx
(),
span
,
ast_bounds
[]);
...
@@ -1556,15 +1541,14 @@ fn conv_ty_poly_trait_ref<'tcx, AC, RS>(
...
@@ -1556,15 +1541,14 @@ fn conv_ty_poly_trait_ref<'tcx, AC, RS>(
}
}
}
}
pub
fn
conv_existential_bounds_from_partitioned_bounds
<
'tcx
,
AC
,
RS
>
(
pub
fn
conv_existential_bounds_from_partitioned_bounds
<
'tcx
>
(
this
:
&
A
C
,
this
:
&
A
stConv
<
'tcx
>
,
rscope
:
&
R
S
,
rscope
:
&
R
egionScope
,
span
:
Span
,
span
:
Span
,
principal_trait_ref
:
Option
<
ty
::
PolyTraitRef
<
'tcx
>>
,
// None for boxed closures
principal_trait_ref
:
Option
<
ty
::
PolyTraitRef
<
'tcx
>>
,
// None for boxed closures
mut
projection_bounds
:
Vec
<
ty
::
PolyProjectionPredicate
<
'tcx
>>
,
// Empty for boxed closures
mut
projection_bounds
:
Vec
<
ty
::
PolyProjectionPredicate
<
'tcx
>>
,
// Empty for boxed closures
partitioned_bounds
:
PartitionedBounds
)
partitioned_bounds
:
PartitionedBounds
)
->
ty
::
ExistentialBounds
<
'tcx
>
->
ty
::
ExistentialBounds
<
'tcx
>
where
AC
:
AstConv
<
'tcx
>
,
RS
:
RegionScope
{
{
let
PartitionedBounds
{
builtin_bounds
,
let
PartitionedBounds
{
builtin_bounds
,
trait_bounds
,
trait_bounds
,
...
@@ -1657,9 +1641,9 @@ fn compute_opt_region_bound<'tcx>(tcx: &ty::ctxt<'tcx>,
...
@@ -1657,9 +1641,9 @@ fn compute_opt_region_bound<'tcx>(tcx: &ty::ctxt<'tcx>,
/// A version of `compute_opt_region_bound` for use where some region bound is required
/// A version of `compute_opt_region_bound` for use where some region bound is required
/// (existential types, basically). Reports an error if no region bound can be derived and we are
/// (existential types, basically). Reports an error if no region bound can be derived and we are
/// in an `rscope` that does not provide a default.
/// in an `rscope` that does not provide a default.
fn
compute_region_bound
<
'tcx
,
AC
:
AstConv
<
'tcx
>
,
RS
:
RegionScope
>
(
fn
compute_region_bound
<
'tcx
>
(
this
:
&
A
C
,
this
:
&
A
stConv
<
'tcx
>
,
rscope
:
&
R
S
,
rscope
:
&
R
egionScope
,
span
:
Span
,
span
:
Span
,
region_bounds
:
&
[
&
ast
::
Lifetime
],
region_bounds
:
&
[
&
ast
::
Lifetime
],
principal_trait_ref
:
Option
<
ty
::
PolyTraitRef
<
'tcx
>>
,
// None for closures
principal_trait_ref
:
Option
<
ty
::
PolyTraitRef
<
'tcx
>>
,
// None for closures
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录