Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
44352df5
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
44352df5
编写于
1月 10, 2012
作者:
K
Kevin Atkinson
提交者:
Marijn Haverbeke
1月 12, 2012
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleanups to previous commits for issue #1393.
上级
175196bb
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
11 addition
and
9 deletion
+11
-9
src/comp/middle/ty.rs
src/comp/middle/ty.rs
+2
-2
src/comp/middle/typeck.rs
src/comp/middle/typeck.rs
+3
-3
src/comp/syntax/ast_util.rs
src/comp/syntax/ast_util.rs
+2
-0
src/comp/syntax/fold.rs
src/comp/syntax/fold.rs
+1
-1
src/comp/syntax/parse/parser.rs
src/comp/syntax/parse/parser.rs
+2
-2
src/test/compile-fail/tag-variant-disr-non-nullary.rs
src/test/compile-fail/tag-variant-disr-non-nullary.rs
+1
-1
未找到文件。
src/comp/middle/ty.rs
浏览文件 @
44352df5
...
...
@@ -174,7 +174,7 @@
export
type_is_str
;
export
type_is_unique
;
export
type_is_tag
;
export
type_is_
enum_like
;
export
type_is_
c_like_enum
;
export
type_structurally_contains_uniques
;
export
type_autoderef
;
export
type_param
;
...
...
@@ -1274,7 +1274,7 @@ fn type_is_tag(cx: ctxt, ty: t) -> bool {
// Whether a type is enum like, that is a tag type with only nullary
// constructors
fn
type_is_
enum_like
(
cx
:
ctxt
,
ty
:
t
)
->
bool
{
fn
type_is_
c_like_enum
(
cx
:
ctxt
,
ty
:
t
)
->
bool
{
alt
struct
(
cx
,
ty
)
{
ty_tag
(
did
,
tps
)
{
let
variants
=
tag_variants
(
cx
,
did
);
...
...
src/comp/middle/typeck.rs
浏览文件 @
44352df5
...
...
@@ -211,9 +211,9 @@ fn type_is_scalar(fcx: @fn_ctxt, sp: span, typ: ty::t) -> bool {
ret
ty
::
type_is_scalar
(
fcx
.ccx.tcx
,
typ_s
);
}
fn
type_is_
enum_like
(
fcx
:
@
fn_ctxt
,
sp
:
span
,
typ
:
ty
::
t
)
->
bool
{
fn
type_is_
c_like_enum
(
fcx
:
@
fn_ctxt
,
sp
:
span
,
typ
:
ty
::
t
)
->
bool
{
let
typ_s
=
structurally_resolved_type
(
fcx
,
sp
,
typ
);
ret
ty
::
type_is_
enum_like
(
fcx
.ccx.tcx
,
typ_s
);
ret
ty
::
type_is_
c_like_enum
(
fcx
.ccx.tcx
,
typ_s
);
}
// Parses the programmer's textual representation of a type into our internal
...
...
@@ -2216,7 +2216,7 @@ fn lower_bound_proto(proto: ast::proto) -> ast::proto {
ty
::
ty_iface
(
_
,
_
)
{}
_
{
let
t_1_is_scalar
=
type_is_scalar
(
fcx
,
expr
.span
,
t_1
);
if
type_is_
enum_like
(
fcx
,
expr
.span
,
t_e
)
&&
t_1_is_scalar
{
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.
...
...
src/comp/syntax/ast_util.rs
浏览文件 @
44352df5
...
...
@@ -245,6 +245,8 @@ fn ternary_to_if(e: @expr) -> @expr {
const_str
(
str
);
}
// FIXME (#1417): any function that uses this function should likely be moved
// into the middle end
fn
eval_const_expr
(
e
:
@
expr
)
->
const_val
{
fn
fromb
(
b
:
bool
)
->
const_val
{
const_int
(
b
as
i64
)
}
alt
e
.node
{
...
...
src/comp/syntax/fold.rs
浏览文件 @
44352df5
...
...
@@ -473,9 +473,9 @@ fn fold_variant_arg_(va: variant_arg, fld: ast_fold) -> variant_arg {
let
(
de
,
dv
)
=
alt
v
.disr_expr
{
some
(
e
)
{
let
de
=
fld
.fold_expr
(
e
);
// FIXME (#1417): see parser.rs
let
dv
=
alt
syntax
::
ast_util
::
eval_const_expr
(
e
)
{
ast_util
::
const_int
(
val
)
{
// FIXME (#1417): check that value is in range
val
as
int
}
};
...
...
src/comp/syntax/parse/parser.rs
浏览文件 @
44352df5
...
...
@@ -2117,7 +2117,7 @@ fn parse_item_tag(p: parser, attrs: [ast::attribute]) -> @ast::item {
// probably be doing." (See issue #1417)
alt
syntax
::
ast_util
::
eval_const_expr
(
e
)
{
syntax
::
ast_util
::
const_int
(
val
)
{
// FIXME
(#1417)
: check that value is in range
// FIXME: check that value is in range
disr_val
=
val
as
int
;
}
}
...
...
@@ -2148,7 +2148,7 @@ fn parse_item_tag(p: parser, attrs: [ast::attribute]) -> @ast::item {
}
let
hi
=
p
.get_hi_pos
();
if
(
have_disr
&&
!
all_nullary
)
{
p
.fatal
(
"discriminator values can only be used with
enum-like tag
"
);
p
.fatal
(
"discriminator values can only be used with
a c-like enum
"
);
}
p
.bump
();
ret
mk_item
(
p
,
lo
,
hi
,
id
,
ast
::
item_tag
(
variants
,
ty_params
),
attrs
);
...
...
src/test/compile-fail/tag-variant-disr-non-nullary.rs
浏览文件 @
44352df5
//error-pattern: discriminator values can only be used with
enum-like tag
//error-pattern: discriminator values can only be used with
a c-like enum
// black and white have the same discriminator value ...
tag
color
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录