Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
816b0ac8
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,发现更多精彩内容 >>
提交
816b0ac8
编写于
12月 29, 2011
作者:
M
Marijn Haverbeke
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Box ty_param_bounds_and_ty
It contains a vector, which shouldn't be copied all the time.
上级
2ed1005b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
22 addition
and
22 deletion
+22
-22
src/comp/metadata/decoder.rs
src/comp/metadata/decoder.rs
+1
-1
src/comp/middle/trans.rs
src/comp/middle/trans.rs
+1
-1
src/comp/middle/ty.rs
src/comp/middle/ty.rs
+1
-1
src/comp/middle/typeck.rs
src/comp/middle/typeck.rs
+19
-19
未找到文件。
src/comp/metadata/decoder.rs
浏览文件 @
816b0ac8
...
...
@@ -213,7 +213,7 @@ fn get_type(data: @[u8], def: ast::def_id, tcx: ty::ctxt,
let
tp_bounds
=
if
family_has_type_params
(
item_family
(
item
))
{
item_ty_param_bounds
(
item
,
this_cnum
,
tcx
,
extres
)
}
else
{
[]
};
ret
{
bounds
:
tp_bounds
,
ty
:
t
};
ret
@
{
bounds
:
tp_bounds
,
ty
:
t
};
}
fn
get_type_param_count
(
data
:
@
[
u8
],
id
:
ast
::
node_id
)
->
uint
{
...
...
src/comp/middle/trans.rs
浏览文件 @
816b0ac8
...
...
@@ -2731,7 +2731,7 @@ fn trans_var(cx: @block_ctxt, sp: span, def: ast::def, id: ast::node_id)
ret
lval_no_env
(
cx
,
ccx
.consts
.get
(
did
.node
),
owned
);
}
else
{
let
tp
=
ty
::
node_id_to_monotype
(
ccx
.tcx
,
id
);
let
val
=
trans_external_path
(
cx
,
did
,
{
bounds
:
[],
ty
:
tp
});
let
val
=
trans_external_path
(
cx
,
did
,
@
{
bounds
:
[],
ty
:
tp
});
ret
lval_no_env
(
cx
,
load_if_immediate
(
cx
,
val
,
tp
),
owned_imm
);
}
}
...
...
src/comp/middle/ty.rs
浏览文件 @
816b0ac8
...
...
@@ -322,7 +322,7 @@ fn param_bounds_to_kind(bounds: @[param_bound]) -> kind {
kind
}
type
ty_param_bounds_and_ty
=
{
bounds
:
[
@
[
param_bound
]],
ty
:
t
};
type
ty_param_bounds_and_ty
=
@
{
bounds
:
[
@
[
param_bound
]],
ty
:
t
};
type
type_cache
=
hashmap
<
ast
::
def_id
,
ty_param_bounds_and_ty
>
;
...
...
src/comp/middle/typeck.rs
浏览文件 @
816b0ac8
...
...
@@ -76,22 +76,22 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) ->
ast
::
def_arg
(
id
,
_
)
{
assert
(
fcx
.locals
.contains_key
(
id
.node
));
let
typ
=
ty
::
mk_var
(
fcx
.ccx.tcx
,
lookup_local
(
fcx
,
sp
,
id
.node
));
ret
{
bounds
:
[],
ty
:
typ
};
ret
@
{
bounds
:
[],
ty
:
typ
};
}
ast
::
def_local
(
id
,
_
)
{
assert
(
fcx
.locals
.contains_key
(
id
.node
));
let
typ
=
ty
::
mk_var
(
fcx
.ccx.tcx
,
lookup_local
(
fcx
,
sp
,
id
.node
));
ret
{
bounds
:
[],
ty
:
typ
};
ret
@
{
bounds
:
[],
ty
:
typ
};
}
ast
::
def_obj_field
(
id
,
_
)
{
assert
(
fcx
.locals
.contains_key
(
id
.node
));
let
typ
=
ty
::
mk_var
(
fcx
.ccx.tcx
,
lookup_local
(
fcx
,
sp
,
id
.node
));
ret
{
bounds
:
[],
ty
:
typ
};
ret
@
{
bounds
:
[],
ty
:
typ
};
}
ast
::
def_self
(
id
)
{
alt
get_self_info
(
fcx
.ccx
)
{
some
(
self_obj
(
_
,
obj_t
))
|
some
(
self_impl
(
obj_t
))
{
ret
{
bounds
:
[],
ty
:
obj_t
};
ret
@
{
bounds
:
[],
ty
:
obj_t
};
}
}
}
...
...
@@ -102,12 +102,12 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) ->
ast
::
def_binding
(
id
)
{
assert
(
fcx
.locals
.contains_key
(
id
.node
));
let
typ
=
ty
::
mk_var
(
fcx
.ccx.tcx
,
lookup_local
(
fcx
,
sp
,
id
.node
));
ret
{
bounds
:
[],
ty
:
typ
};
ret
@
{
bounds
:
[],
ty
:
typ
};
}
ast
::
def_mod
(
_
)
{
// Hopefully part of a path.
// TODO: return a type that's more poisonous, perhaps?
ret
{
bounds
:
[],
ty
:
ty
::
mk_nil
(
fcx
.ccx.tcx
)};
ret
@
{
bounds
:
[],
ty
:
ty
::
mk_nil
(
fcx
.ccx.tcx
)};
}
ast
::
def_ty
(
_
)
{
fcx
.ccx.tcx.sess
.span_fatal
(
sp
,
"expected value but found type"
);
...
...
@@ -382,7 +382,7 @@ fn ty_of_item(tcx: ty::ctxt, mode: mode, it: @ast::item)
alt
it
.node
{
ast
::
item_const
(
t
,
_
)
{
let
typ
=
ast_ty_to_ty
(
tcx
,
mode
,
t
);
let
tpt
=
{
bounds
:
[],
ty
:
typ
};
let
tpt
=
@
{
bounds
:
[],
ty
:
typ
};
tcx
.tcache
.insert
(
local_def
(
it
.id
),
tpt
);
ret
tpt
;
}
...
...
@@ -401,7 +401,7 @@ fn ty_of_item(tcx: ty::ctxt, mode: mode, it: @ast::item)
}
// Tell ast_ty_to_ty() that we want to perform a recursive
// call to resolve any named types.
let
tpt
=
{
bounds
:
ty_param_bounds
(
tcx
,
mode
,
tps
),
let
tpt
=
@
{
bounds
:
ty_param_bounds
(
tcx
,
mode
,
tps
),
ty
:
ty
::
mk_named
(
tcx
,
ast_ty_to_ty
(
tcx
,
mode
,
t
),
@
it
.ident
)};
tcx
.tcache
.insert
(
local_def
(
it
.id
),
tpt
);
...
...
@@ -413,7 +413,7 @@ fn ty_of_item(tcx: ty::ctxt, mode: mode, it: @ast::item)
let
t
=
ty
::
mk_named
(
tcx
,
ty
::
mk_res
(
tcx
,
local_def
(
it
.id
),
t_arg
.ty
,
params
),
@
it
.ident
);
let
t_res
=
{
bounds
:
bounds
,
ty
:
t
};
let
t_res
=
@
{
bounds
:
bounds
,
ty
:
t
};
tcx
.tcache
.insert
(
local_def
(
it
.id
),
t_res
);
ret
t_res
;
}
...
...
@@ -422,7 +422,7 @@ fn ty_of_item(tcx: ty::ctxt, mode: mode, it: @ast::item)
let
{
bounds
,
params
}
=
mk_ty_params
(
tcx
,
tps
);
let
t
=
ty
::
mk_named
(
tcx
,
ty
::
mk_tag
(
tcx
,
local_def
(
it
.id
),
params
),
@
it
.ident
);
let
tpt
=
{
bounds
:
bounds
,
ty
:
t
};
let
tpt
=
@
{
bounds
:
bounds
,
ty
:
t
};
tcx
.tcache
.insert
(
local_def
(
it
.id
),
tpt
);
ret
tpt
;
}
...
...
@@ -431,7 +431,7 @@ fn ty_of_item(tcx: ty::ctxt, mode: mode, it: @ast::item)
let
t
=
ty
::
mk_named
(
tcx
,
ty
::
mk_iface
(
tcx
,
local_def
(
it
.id
),
params
),
@
it
.ident
);
let
tpt
=
{
bounds
:
bounds
,
ty
:
t
};
let
tpt
=
@
{
bounds
:
bounds
,
ty
:
t
};
tcx
.tcache
.insert
(
local_def
(
it
.id
),
tpt
);
ty
::
store_iface_methods
(
tcx
,
it
.id
,
@
vec
::
map
(
ms
,
{|
m
|
ty_of_ty_method
(
tcx
,
m_collect
,
m
)
...
...
@@ -455,7 +455,7 @@ fn ty_of_native_item(tcx: ty::ctxt, mode: mode, it: @ast::native_item)
none
.
{
}
}
let
t
=
ty
::
mk_native
(
tcx
,
ast_util
::
local_def
(
it
.id
));
let
tpt
=
{
bounds
:
[],
ty
:
t
};
let
tpt
=
@
{
bounds
:
[],
ty
:
t
};
tcx
.tcache
.insert
(
local_def
(
it
.id
),
tpt
);
ret
tpt
;
}
...
...
@@ -480,7 +480,7 @@ fn ty_of_fn_decl(tcx: ty::ctxt, mode: mode, decl: ast::fn_decl) -> ty::fn_ty {
fn
ty_of_fn
(
tcx
:
ty
::
ctxt
,
mode
:
mode
,
decl
:
ast
::
fn_decl
,
ty_params
:
[
ast
::
ty_param
],
def_id
:
ast
::
def_id
)
->
ty
::
ty_param_bounds_and_ty
{
let
tpt
=
{
bounds
:
ty_param_bounds
(
tcx
,
mode
,
ty_params
),
let
tpt
=
@
{
bounds
:
ty_param_bounds
(
tcx
,
mode
,
ty_params
),
ty
:
ty
::
mk_fn
(
tcx
,
ty_of_fn_decl
(
tcx
,
mode
,
decl
))};
tcx
.tcache
.insert
(
def_id
,
tpt
);
ret
tpt
;
...
...
@@ -493,7 +493,7 @@ fn ty_of_native_fn_decl(tcx: ty::ctxt, mode: mode, decl: ast::fn_decl,
let
output_ty
=
ast_ty_to_ty
(
tcx
,
mode
,
decl
.output
);
let
t_fn
=
ty
::
mk_native_fn
(
tcx
,
input_tys
,
output_ty
);
let
tpt
=
{
bounds
:
bounds
,
ty
:
t_fn
};
let
tpt
=
@
{
bounds
:
bounds
,
ty
:
t_fn
};
tcx
.tcache
.insert
(
def_id
,
tpt
);
ret
tpt
;
}
...
...
@@ -537,7 +537,7 @@ fn ty_of_obj(tcx: ty::ctxt, mode: mode, id: ast::ident, ob: ast::_obj,
let
methods
=
vec
::
map
(
ob
.methods
,
{|
m
|
ty_of_method
(
tcx
,
mode
,
m
)});
let
t_obj
=
ty
::
mk_named
(
tcx
,
ty
::
mk_obj
(
tcx
,
ty
::
sort_methods
(
methods
)),
@
id
);
ret
{
bounds
:
bounds
,
ty
:
t_obj
};
ret
@
{
bounds
:
bounds
,
ty
:
t_obj
};
}
fn
ty_of_obj_ctor
(
tcx
:
ty
::
ctxt
,
mode
:
mode
,
id
:
ast
::
ident
,
ob
:
ast
::
_
obj
,
ctor_id
:
ast
::
node_id
,
ty_params
:
[
ast
::
ty_param
])
...
...
@@ -551,7 +551,7 @@ fn ty_of_obj_ctor(tcx: ty::ctxt, mode: mode, id: ast::ident, ob: ast::_obj,
let
t_fn
=
ty
::
mk_fn
(
tcx
,
{
proto
:
ast
::
proto_shared
(
ast
::
sugar_normal
),
inputs
:
t_inputs
,
output
:
t_obj
.ty
,
ret_style
:
ast
::
return_val
,
constraints
:
[]});
let
tpt
=
{
bounds
:
ty_param_bounds
(
tcx
,
mode
,
ty_params
),
ty
:
t_fn
};
let
tpt
=
@
{
bounds
:
ty_param_bounds
(
tcx
,
mode
,
ty_params
),
ty
:
t_fn
};
tcx
.tcache
.insert
(
local_def
(
ctor_id
),
tpt
);
ret
tpt
;
}
...
...
@@ -672,7 +672,7 @@ fn get_tag_variant_types(cx: @ctxt, tag_ty: ty::t,
inputs
:
args
,
output
:
tag_ty
,
ret_style
:
ast
::
return_val
,
constraints
:
[]})
};
let
tpt
=
{
bounds
:
ty_param_bounds
(
cx
.tcx
,
m_collect
,
ty_params
),
let
tpt
=
@
{
bounds
:
ty_param_bounds
(
cx
.tcx
,
m_collect
,
ty_params
),
ty
:
result_ty
};
cx
.tcx.tcache
.insert
(
local_def
(
variant
.node.id
),
tpt
);
write
::
ty_only
(
cx
.tcx
,
variant
.node.id
,
result_ty
);
...
...
@@ -693,7 +693,7 @@ fn convert(cx: @ctxt, it: @ast::item) {
let
bounds
=
ty_param_bounds
(
cx
.tcx
,
m_collect
,
m
.tps
);
let
ty
=
ty
::
mk_fn
(
cx
.tcx
,
ty_of_fn_decl
(
cx
.tcx
,
m_collect
,
m
.decl
));
cx
.tcx.tcache
.insert
(
local_def
(
m
.id
),
{
bounds
:
bounds
,
cx
.tcx.tcache
.insert
(
local_def
(
m
.id
),
@
{
bounds
:
bounds
,
ty
:
ty
});
write
::
ty_only
(
cx
.tcx
,
m
.id
,
ty
);
}
...
...
@@ -751,7 +751,7 @@ fn convert(cx: @ctxt, it: @ast::item) {
write
::
ty_only
(
cx
.tcx
,
it
.id
,
t_res
);
write
::
ty_only
(
cx
.tcx
,
ctor_id
,
t_ctor
);
cx
.tcx.tcache
.insert
(
local_def
(
ctor_id
),
{
bounds
:
bounds
,
@
{
bounds
:
bounds
,
ty
:
t_ctor
});
write
::
ty_only
(
cx
.tcx
,
dtor_id
,
t_dtor
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录