Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
abfa8164
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,发现更多精彩内容 >>
提交
abfa8164
编写于
6月 21, 2012
作者:
L
Lindsey Kuper
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change the level of forcing in structurally_resolved_type().
A cleaner way to handle suffix inference for unary minus exprs.
上级
31786467
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
17 deletion
+10
-17
src/rustc/middle/typeck/check.rs
src/rustc/middle/typeck/check.rs
+3
-10
src/rustc/middle/typeck/infer.rs
src/rustc/middle/typeck/infer.rs
+7
-7
未找到文件。
src/rustc/middle/typeck/check.rs
浏览文件 @
abfa8164
...
...
@@ -74,7 +74,7 @@
import
rscope
::{
in_binding_rscope
,
region_scope
,
type_rscope
};
import
syntax
::
ast
::
ty_i
;
import
typeck
::
infer
::{
unify_methods
};
// infcx.set()
import
typeck
::
infer
::{
force_level
,
force_none
,
force_
non_region
_vars_only
,
import
typeck
::
infer
::{
force_level
,
force_none
,
force_
ty
_vars_only
,
force_all
};
type
fn_ctxt
=
...
...
@@ -1174,14 +1174,7 @@ fn check_expr_fn(fcx: @fn_ctxt,
}
}
ast
::
neg
{
// If the operand's type is an integral type variable, we
// don't want to resolve it yet, because the rest of the
// typing context might not have had the opportunity to
// constrain it yet.
if
!
(
ty
::
type_is_var_integral
(
oprnd_t
))
{
oprnd_t
=
structurally_resolved_type
(
fcx
,
oprnd
.span
,
oprnd_t
);
}
oprnd_t
=
structurally_resolved_type
(
fcx
,
oprnd
.span
,
oprnd_t
);
if
!
(
ty
::
type_is_integral
(
oprnd_t
)
||
ty
::
type_is_fp
(
oprnd_t
))
{
oprnd_t
=
check_user_unop
(
fcx
,
"-"
,
"unary-"
,
expr
,
...
...
@@ -2116,7 +2109,7 @@ fn instantiate_path(fcx: @fn_ctxt,
// resolution is possible, then an error is reported.
fn
structurally_resolved_type
(
fcx
:
@
fn_ctxt
,
sp
:
span
,
tp
:
ty
::
t
)
->
ty
::
t
{
alt
infer
::
resolve_shallow
(
fcx
.infcx
,
tp
,
force_
non_region
_vars_only
)
{
force_
ty
_vars_only
)
{
result
::
ok
(
t_s
)
if
!
ty
::
type_is_var
(
t_s
)
{
ret
t_s
;
}
_
{
fcx
.ccx.tcx.sess
.span_fatal
...
...
src/rustc/middle/typeck/infer.rs
浏览文件 @
abfa8164
...
...
@@ -197,7 +197,7 @@ fn bar() {
export
assignment
;
export
root
,
to_str
;
export
int_ty_set_all
;
export
force_level
,
force_none
,
force_
non_region
_vars_only
,
force_all
;
export
force_level
,
force_none
,
force_
ty
_vars_only
,
force_all
;
// Bitvector to represent sets of integral types
enum
int_ty_set
=
uint
;
...
...
@@ -1093,9 +1093,9 @@ enum force_level {
// Any unconstrained variables are OK.
force_none
,
// Unconstrained region vars a
re OK; unconstrained ty vars and
//
integral
ty vars result in an error.
force_
non_region
_vars_only
,
// Unconstrained region vars a
nd integral ty vars are OK;
//
unconstrained general-purpose
ty vars result in an error.
force_
ty
_vars_only
,
// Any unconstrained variables result in an error.
force_all
,
...
...
@@ -1237,7 +1237,7 @@ fn resolve_ty_var(vid: tv_vid) -> ty::t {
{
ub
:
_
,
lb
:
some
(
t
)
}
{
self
.resolve1
(
t
)
}
{
ub
:
none
,
lb
:
none
}
{
alt
self
.force_vars
{
force_
non_region
_vars_only
|
force_all
{
force_
ty
_vars_only
|
force_all
{
self
.err
=
some
(
unresolved_ty
(
vid
));
}
force_none
{
/* ok */
}
...
...
@@ -1260,7 +1260,7 @@ fn resolve_ty_var_integral(vid: tvi_vid) -> ty::t {
some
(
t
)
{
t
}
none
{
alt
self
.force_vars
{
force_
non_region_vars_only
|
force_
all
{
force_all
{
// As a last resort, default to int.
let
ty
=
ty
::
mk_int
(
self
.infcx.tcx
);
self
.infcx
.set
(
...
...
@@ -1270,7 +1270,7 @@ fn resolve_ty_var_integral(vid: tvi_vid) -> ty::t {
nde
.rank
));
ty
}
force_none
{
force_none
|
force_ty_vars_only
{
ty
::
mk_var_integral
(
self
.infcx.tcx
,
vid
)
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录