Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
42f95d05
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,发现更多精彩内容 >>
提交
42f95d05
编写于
3月 04, 2013
作者:
L
Luqman Aden
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow constant expressions in [Type * n].
上级
e78f2e2a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
32 addition
and
24 deletion
+32
-24
src/librustc/middle/typeck/astconv.rs
src/librustc/middle/typeck/astconv.rs
+24
-3
src/libsyntax/ast.rs
src/libsyntax/ast.rs
+1
-1
src/libsyntax/parse/parser.rs
src/libsyntax/parse/parser.rs
+4
-17
src/libsyntax/print/pprust.rs
src/libsyntax/print/pprust.rs
+3
-3
未找到文件。
src/librustc/middle/typeck/astconv.rs
浏览文件 @
42f95d05
...
@@ -54,6 +54,7 @@
...
@@ -54,6 +54,7 @@
use
core
::
prelude
::
*
;
use
core
::
prelude
::
*
;
use
middle
::
const_eval
;
use
middle
::
ty
::{
arg
,
field
,
substs
};
use
middle
::
ty
::{
arg
,
field
,
substs
};
use
middle
::
ty
::{
ty_param_substs_and_ty
};
use
middle
::
ty
::{
ty_param_substs_and_ty
};
use
middle
::
ty
;
use
middle
::
ty
;
...
@@ -412,9 +413,29 @@ fn check_path_args(tcx: ty::ctxt,
...
@@ -412,9 +413,29 @@ fn check_path_args(tcx: ty::ctxt,
}
}
}
}
}
}
ast
::
ty_fixed_length_vec
(
a_mt
,
u
)
=>
{
ast
::
ty_fixed_length_vec
(
a_mt
,
e
)
=>
{
ty
::
mk_evec
(
tcx
,
ast_mt_to_mt
(
self
,
rscope
,
a_mt
),
match
const_eval
::
eval_const_expr_partial
(
tcx
,
e
)
{
ty
::
vstore_fixed
(
u
))
Ok
(
ref
r
)
=>
{
match
*
r
{
const_eval
::
const_int
(
i
)
=>
ty
::
mk_evec
(
tcx
,
ast_mt_to_mt
(
self
,
rscope
,
a_mt
),
ty
::
vstore_fixed
(
i
as
uint
)),
const_eval
::
const_uint
(
i
)
=>
ty
::
mk_evec
(
tcx
,
ast_mt_to_mt
(
self
,
rscope
,
a_mt
),
ty
::
vstore_fixed
(
i
as
uint
)),
_
=>
{
tcx
.sess
.span_fatal
(
ast_ty
.span
,
~
"expected constant expr for vector length"
);
}
}
}
Err
(
ref
r
)
=>
{
tcx
.sess
.span_fatal
(
ast_ty
.span
,
fmt!
(
"expected constant expr for vector length: %s"
,
*
r
));
}
}
}
}
ast
::
ty_infer
=>
{
ast
::
ty_infer
=>
{
// ty_infer should only appear as the type of arguments or return
// ty_infer should only appear as the type of arguments or return
...
...
src/libsyntax/ast.rs
浏览文件 @
42f95d05
...
@@ -916,7 +916,7 @@ pub enum ty_ {
...
@@ -916,7 +916,7 @@ pub enum ty_ {
ty_box
(
mt
),
ty_box
(
mt
),
ty_uniq
(
mt
),
ty_uniq
(
mt
),
ty_vec
(
mt
),
ty_vec
(
mt
),
ty_fixed_length_vec
(
mt
,
uint
),
ty_fixed_length_vec
(
mt
,
@
expr
),
ty_ptr
(
mt
),
ty_ptr
(
mt
),
ty_rptr
(
Option
<@
Lifetime
>
,
mt
),
ty_rptr
(
Option
<@
Lifetime
>
,
mt
),
ty_closure
(
@
TyClosure
),
ty_closure
(
@
TyClosure
),
...
...
src/libsyntax/parse/parser.rs
浏览文件 @
42f95d05
...
@@ -642,7 +642,8 @@ fn parse_ty(&self, colons_before_params: bool) -> @Ty {
...
@@ -642,7 +642,8 @@ fn parse_ty(&self, colons_before_params: bool) -> @Ty {
self
.obsolete
(
*
self
.last_span
,
ObsoleteMutVector
);
self
.obsolete
(
*
self
.last_span
,
ObsoleteMutVector
);
}
}
// Parse the `* 3` in `[ int * 3 ]`
// Parse the `* e` in `[ int * e ]`
// where `e` is a const expression
let
t
=
match
self
.maybe_parse_fixed_vstore_with_star
()
{
let
t
=
match
self
.maybe_parse_fixed_vstore_with_star
()
{
None
=>
ty_vec
(
mt
),
None
=>
ty_vec
(
mt
),
Some
(
suffix
)
=>
ty_fixed_length_vec
(
mt
,
suffix
)
Some
(
suffix
)
=>
ty_fixed_length_vec
(
mt
,
suffix
)
...
@@ -814,23 +815,9 @@ fn parse_fn_block_arg(&self) -> arg_or_capture_item {
...
@@ -814,23 +815,9 @@ fn parse_fn_block_arg(&self) -> arg_or_capture_item {
})
})
}
}
fn
maybe_parse_fixed_vstore_with_star
(
&
self
)
->
Option
<
uint
>
{
fn
maybe_parse_fixed_vstore_with_star
(
&
self
)
->
Option
<
@
ast
::
expr
>
{
if
self
.eat
(
&
token
::
BINOP
(
token
::
STAR
))
{
if
self
.eat
(
&
token
::
BINOP
(
token
::
STAR
))
{
match
*
self
.token
{
Some
(
self
.parse_expr
())
token
::
LIT_INT_UNSUFFIXED
(
i
)
if
i
>=
0i64
=>
{
self
.bump
();
Some
(
i
as
uint
)
}
_
=>
{
self
.fatal
(
fmt!
(
"expected integral vector length
\
but found `%s`"
,
token_to_str
(
self
.reader
,
&
copy
*
self
.token
)
)
);
}
}
}
else
{
}
else
{
None
None
}
}
...
...
src/libsyntax/print/pprust.rs
浏览文件 @
42f95d05
...
@@ -425,7 +425,7 @@ pub fn print_type_ex(s: @ps, &&ty: @ast::Ty, print_colons: bool) {
...
@@ -425,7 +425,7 @@ pub fn print_type_ex(s: @ps, &&ty: @ast::Ty, print_colons: bool) {
}
}
print_type
(
s
,
mt
.ty
);
print_type
(
s
,
mt
.ty
);
word
(
s
.s
,
~
" * "
);
word
(
s
.s
,
~
" * "
);
word
(
s
.s
,
fmt!
(
"%
u
"
,
v
));
word
(
s
.s
,
fmt!
(
"%
?
"
,
v
));
word
(
s
.s
,
~
"]"
);
word
(
s
.s
,
~
"]"
);
}
}
ast
::
ty_mac
(
_
)
=>
{
ast
::
ty_mac
(
_
)
=>
{
...
@@ -1015,7 +1015,7 @@ pub fn print_mac(s: @ps, m: ast::mac) {
...
@@ -1015,7 +1015,7 @@ pub fn print_mac(s: @ps, m: ast::mac) {
pub
fn
print_vstore
(
s
:
@
ps
,
t
:
ast
::
vstore
)
{
pub
fn
print_vstore
(
s
:
@
ps
,
t
:
ast
::
vstore
)
{
match
t
{
match
t
{
ast
::
vstore_fixed
(
Some
(
i
))
=>
word
(
s
.s
,
fmt!
(
"%
u
"
,
i
)),
ast
::
vstore_fixed
(
Some
(
i
))
=>
word
(
s
.s
,
fmt!
(
"%
?
"
,
i
)),
ast
::
vstore_fixed
(
None
)
=>
word
(
s
.s
,
~
"_"
),
ast
::
vstore_fixed
(
None
)
=>
word
(
s
.s
,
~
"_"
),
ast
::
vstore_uniq
=>
word
(
s
.s
,
~
"~"
),
ast
::
vstore_uniq
=>
word
(
s
.s
,
~
"~"
),
ast
::
vstore_box
=>
word
(
s
.s
,
~
"@"
),
ast
::
vstore_box
=>
word
(
s
.s
,
~
"@"
),
...
@@ -1028,7 +1028,7 @@ pub fn print_vstore(s: @ps, t: ast::vstore) {
...
@@ -1028,7 +1028,7 @@ pub fn print_vstore(s: @ps, t: ast::vstore) {
pub
fn
print_expr_vstore
(
s
:
@
ps
,
t
:
ast
::
expr_vstore
)
{
pub
fn
print_expr_vstore
(
s
:
@
ps
,
t
:
ast
::
expr_vstore
)
{
match
t
{
match
t
{
ast
::
expr_vstore_fixed
(
Some
(
i
))
=>
word
(
s
.s
,
fmt!
(
"%
u
"
,
i
)),
ast
::
expr_vstore_fixed
(
Some
(
i
))
=>
word
(
s
.s
,
fmt!
(
"%
?
"
,
i
)),
ast
::
expr_vstore_fixed
(
None
)
=>
word
(
s
.s
,
~
"_"
),
ast
::
expr_vstore_fixed
(
None
)
=>
word
(
s
.s
,
~
"_"
),
ast
::
expr_vstore_uniq
=>
word
(
s
.s
,
~
"~"
),
ast
::
expr_vstore_uniq
=>
word
(
s
.s
,
~
"~"
),
ast
::
expr_vstore_box
=>
word
(
s
.s
,
~
"@"
),
ast
::
expr_vstore_box
=>
word
(
s
.s
,
~
"@"
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录