Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
730381d9
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,发现更多精彩内容 >>
提交
730381d9
编写于
6月 14, 2012
作者:
T
Tim Chevalier
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Annotate and fix FIXMEs in typeck
上级
87af3f3c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
40 addition
and
41 deletion
+40
-41
src/rustc/middle/typeck.rs
src/rustc/middle/typeck.rs
+0
-2
src/rustc/middle/typeck/check.rs
src/rustc/middle/typeck/check.rs
+40
-39
未找到文件。
src/rustc/middle/typeck.rs
浏览文件 @
730381d9
...
...
@@ -120,8 +120,6 @@ fn foo<T: quux, baz, bar>(a: T) -- a's vtable would have a
vtable_map
:
vtable_map
,
tcx
:
ty
::
ctxt
};
type
class_map
=
hashmap
<
ast
::
node_id
,
ty
::
t
>
;
// Functions that write types into the node type table
fn
write_ty_to_tcx
(
tcx
:
ty
::
ctxt
,
node_id
:
ast
::
node_id
,
ty
:
ty
::
t
)
{
#
debug
[
"write_ty_to_tcx(%d, %s)"
,
node_id
,
ty_to_str
(
tcx
,
ty
)];
...
...
src/rustc/middle/typeck/check.rs
浏览文件 @
730381d9
...
...
@@ -99,6 +99,23 @@
ccx
:
@
crate_ctxt
};
// Used by check_const and check_enum_variants
fn
blank_fn_ctxt
(
ccx
:
@
crate_ctxt
,
rty
:
ty
::
t
)
->
@
fn_ctxt
{
// It's kind of a kludge to manufacture a fake function context
// and statement context, but we might as well do write the code only once
@
{
self_ty
:
none
,
ret_ty
:
rty
,
indirect_ret_ty
:
none
,
purity
:
ast
::
pure_fn
,
infcx
:
infer
::
new_infer_ctxt
(
ccx
.tcx
),
locals
:
int_hash
(),
mut
blocks
:
[],
in_scope_regions
:
@
nil
,
node_types
:
smallintmap
::
mk
(),
node_type_substs
:
map
::
int_hash
(),
ccx
:
ccx
}
}
// a list of mapping from in-scope-region-names ("isr") to the
// corresponding ty::region
type
isr_alist
=
@
list
<
(
ty
::
bound_region
,
ty
::
region
)
>
;
...
...
@@ -705,7 +722,7 @@ fn impl_self_ty(fcx: @fn_ctxt, did: ast::def_id) -> ty_param_substs_and_ty {
}
// Only for fields! Returns <none> for methods>
//
FIXME:
privacy flags
//
Indifferent to
privacy flags
fn
lookup_field_ty
(
tcx
:
ty
::
ctxt
,
class_id
:
ast
::
def_id
,
items
:[
ty
::
field_ty
],
fieldname
:
ast
::
ident
,
substs
:
ty
::
substs
)
->
option
<
ty
::
t
>
{
...
...
@@ -1390,7 +1407,7 @@ fn check_expr_fn(fcx: @fn_ctxt,
alt
structure_of
(
fcx
,
expr
.span
,
fty
)
{
// FIXME:
// probably need to munge the constrs to drop constraints
// for any bound args
// for any bound args
(contingent on #2588 not getting accepted)
ty
::
ty_fn
(
f
)
{
proto
=
f
.proto
;
arg_tys
=
f
.inputs
;
...
...
@@ -1460,7 +1477,11 @@ fn check_expr_fn(fcx: @fn_ctxt,
if
type_is_c_like_enum
(
fcx
,
expr
.span
,
t_e
)
&&
t_1_is_scalar
{
/* this case is allowed */
}
else
if
!
(
type_is_scalar
(
fcx
,
expr
.span
,
t_e
)
&&
t_1_is_scalar
)
{
// FIXME there are more forms of cast to support, eventually.
/*
If more type combinations should be supported than are
supported here, then file an enhancement issue and record the
issue number in this comment.
*/
tcx
.sess
.span_err
(
expr
.span
,
"non-scalar cast: "
+
ty_to_str
(
tcx
,
t_e
)
+
" as "
+
...
...
@@ -1516,14 +1537,13 @@ fn get_node(f: spanned<field>) -> field { f.node }
}
some
(
bexpr
)
{
let
bexpr_t
=
fcx
.expr_ty
(
bexpr
);
let
mut
base_fields
;
// FIXME remove mut after snapshot
alt
structure_of
(
fcx
,
expr
.span
,
bexpr_t
)
{
ty
::
ty_rec
(
flds
)
{
base_fields
=
flds
;
}
let
base_fields
=
alt
structure_of
(
fcx
,
expr
.span
,
bexpr_t
)
{
ty
::
ty_rec
(
flds
)
{
flds
}
_
{
tcx
.sess
.span_fatal
(
expr
.span
,
"record update has non-record base"
);
}
}
}
;
fcx
.write_ty
(
id
,
bexpr_t
);
for
fields_t
.each
{|
f
|
let
mut
found
=
false
;
...
...
@@ -1586,7 +1606,6 @@ fn get_node(f: spanned<field>) -> field { f.node }
alt
lookup_field_ty
(
tcx
,
base_id
,
cls_items
,
field
,
substs
)
{
some
(
field_ty
)
{
// (2) look up what field's type is, and return it
// FIXME: actually instantiate any type params
fcx
.write_ty
(
id
,
field_ty
);
handled
=
true
;
}
...
...
@@ -1843,21 +1862,8 @@ fn check_block(fcx0: @fn_ctxt, blk: ast::blk) -> bool {
}
fn
check_const
(
ccx
:
@
crate_ctxt
,
_
sp
:
span
,
e
:
@
ast
::
expr
,
id
:
ast
::
node_id
)
{
// FIXME: this is kinda a kludge; we manufacture a fake function context
// and statement context for checking the initializer expression.
let
rty
=
ty
::
node_id_to_type
(
ccx
.tcx
,
id
);
let
fcx
:
@
fn_ctxt
=
@
{
self_ty
:
none
,
ret_ty
:
rty
,
indirect_ret_ty
:
none
,
purity
:
ast
::
pure_fn
,
infcx
:
infer
::
new_infer_ctxt
(
ccx
.tcx
),
locals
:
int_hash
(),
mut
blocks
:
[],
in_scope_regions
:
@
nil
,
node_types
:
smallintmap
::
mk
(),
node_type_substs
:
map
::
int_hash
(),
ccx
:
ccx
};
let
fcx
=
blank_fn_ctxt
(
ccx
,
rty
);
check_expr
(
fcx
,
e
,
none
);
let
cty
=
fcx
.expr_ty
(
e
);
let
declty
=
fcx
.ccx.tcx.tcache
.get
(
local_def
(
id
))
.ty
;
...
...
@@ -1882,21 +1888,8 @@ fn check_enum_variants(ccx: @crate_ctxt,
sp
:
span
,
vs
:
[
ast
::
variant
],
id
:
ast
::
node_id
)
{
// FIXME: this is kinda a kludge; we manufacture a fake function context
// and statement context for checking the initializer expression.
let
rty
=
ty
::
node_id_to_type
(
ccx
.tcx
,
id
);
let
fcx
:
@
fn_ctxt
=
@
{
self_ty
:
none
,
ret_ty
:
rty
,
indirect_ret_ty
:
none
,
purity
:
ast
::
pure_fn
,
infcx
:
infer
::
new_infer_ctxt
(
ccx
.tcx
),
locals
:
int_hash
(),
mut
blocks
:
[],
in_scope_regions
:
@
nil
,
node_types
:
smallintmap
::
mk
(),
node_type_substs
:
map
::
int_hash
(),
ccx
:
ccx
};
let
fcx
=
blank_fn_ctxt
(
ccx
,
rty
);
let
mut
disr_vals
:
[
int
]
=
[];
let
mut
disr_val
=
0
;
for
vs
.each
{|
v
|
...
...
@@ -2140,9 +2133,17 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) ->
ast
::
def_upvar
(
_
,
inner
,
_
)
{
ret
ty_param_bounds_and_ty_for_def
(
fcx
,
sp
,
*
inner
);
}
_
{
// FIXME: handle other names.
fcx
.ccx.tcx.sess
.unimpl
(
"definition variant"
);
ast
::
def_ty_param
(
did
,
n
)
{
ret
no_params
(
ty
::
mk_param
(
fcx
.ccx.tcx
,
n
,
did
));
}
ast
::
def_mod
(
*
)
|
ast
::
def_native_mod
(
*
)
{
fcx
.ccx.tcx.sess
.span_fatal
(
sp
,
"expected value but found module"
);
}
ast
::
def_use
(
*
)
{
fcx
.ccx.tcx.sess
.span_fatal
(
sp
,
"expected value but found use"
);
}
ast
::
def_region
(
*
)
{
fcx
.ccx.tcx.sess
.span_fatal
(
sp
,
"expected value but found region"
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录