Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
8040fd86
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,发现更多精彩内容 >>
提交
8040fd86
编写于
6月 20, 2012
作者:
M
Michael Sullivan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Call the correct type formatting function for more typecheck diagnostics. Closes #2652.
上级
60a65825
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
14 addition
and
10 deletion
+14
-10
src/rustc/middle/typeck/check.rs
src/rustc/middle/typeck/check.rs
+10
-10
src/test/compile-fail/index_message.rs
src/test/compile-fail/index_message.rs
+4
-0
未找到文件。
src/rustc/middle/typeck/check.rs
浏览文件 @
8040fd86
...
...
@@ -1334,7 +1334,7 @@ fn check_expr_fn(fcx: @fn_ctxt,
tcx
.sess
.span_fatal
(
expr
.span
,
#
fmt
(
"a loop function's last argument
\
should return `bool`, not `%s`"
,
ty_to_str
(
tcx
,
fty
.output
)));
fcx
.infcx
.ty_to_str
(
fty
.output
)));
}
}
(
ty
::
mk_fn
(
tcx
,
{
output
:
ty
::
mk_nil
(
tcx
)
with
fty
}),
fty
.proto
)
...
...
@@ -1471,12 +1471,12 @@ fn check_expr_fn(fcx: @fn_ctxt,
_
{
if
ty
::
type_is_nil
(
t_e
)
{
tcx
.sess
.span_err
(
expr
.span
,
"cast from nil: "
+
ty_to_str
(
tcx
,
t_e
)
+
" as "
+
ty_to_str
(
tcx
,
t_1
));
fcx
.infcx
.ty_to_str
(
t_e
)
+
" as "
+
fcx
.infcx
.ty_to_str
(
t_1
));
}
else
if
ty
::
type_is_nil
(
t_1
)
{
tcx
.sess
.span_err
(
expr
.span
,
"cast to nil: "
+
ty_to_str
(
tcx
,
t_e
)
+
" as "
+
ty_to_str
(
tcx
,
t_1
));
fcx
.infcx
.ty_to_str
(
t_e
)
+
" as "
+
fcx
.infcx
.ty_to_str
(
t_1
));
}
let
t_1_is_scalar
=
type_is_scalar
(
fcx
,
expr
.span
,
t_1
);
...
...
@@ -1490,8 +1490,8 @@ fn check_expr_fn(fcx: @fn_ctxt,
*/
tcx
.sess
.span_err
(
expr
.span
,
"non-scalar cast: "
+
ty_to_str
(
tcx
,
t_e
)
+
" as "
+
ty_to_str
(
tcx
,
t_1
));
fcx
.infcx
.ty_to_str
(
t_e
)
+
" as "
+
fcx
.infcx
.ty_to_str
(
t_1
));
}
}
}
...
...
@@ -1639,7 +1639,7 @@ fn get_node(f: spanned<field>) -> field { f.node }
let
t_err
=
fcx
.infcx
.resolve_type_vars_if_possible
(
expr_t
);
let
msg
=
#
fmt
[
"attempted access of field %s on type %s, but
\
no public field or method with that name was found"
,
*
field
,
ty_to_str
(
tcx
,
t_err
)];
*
field
,
fcx
.infcx
.ty_to_str
(
t_err
)];
tcx
.sess
.span_err
(
expr
.span
,
msg
);
// NB: Adding a bogus type to allow typechecking to continue
fcx
.write_ty
(
id
,
fcx
.infcx
.next_ty_var
());
...
...
@@ -1667,7 +1667,7 @@ fn get_node(f: spanned<field>) -> field { f.node }
_
{
tcx
.sess
.span_fatal
(
expr
.span
,
"cannot index a value of type `"
+
ty_to_str
(
tcx
,
base_t
)
+
"`"
);
fcx
.infcx
.ty_to_str
(
base_t
)
+
"`"
);
}
}
}
...
...
@@ -1708,7 +1708,7 @@ fn get_node(f: spanned<field>) -> field { f.node }
none
{
let
t_err
=
fcx
.infcx
.resolve_type_vars_if_possible
(
p_ty
);
let
msg
=
#
fmt
[
"no `alloc()` method found for type `%s`"
,
ty_to_str
(
tcx
,
t_err
)];
fcx
.infcx
.ty_to_str
(
t_err
)];
tcx
.sess
.span_err
(
expr
.span
,
msg
);
}
}
...
...
src/test/compile-fail/index_message.rs
0 → 100644
浏览文件 @
8040fd86
fn
main
()
{
let
z
=
();
log
(
error
,
z
[
0
]);
//! ERROR cannot index a value of type `()`
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录