Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
6822ec3e
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,发现更多精彩内容 >>
提交
6822ec3e
编写于
7月 14, 2012
作者:
M
Michael Sullivan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Treat bare vector and string literals as fixed length vecs. Closes #2922.
上级
7b2f4755
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
26 addition
and
100 deletion
+26
-100
src/rustc/middle/check_const.rs
src/rustc/middle/check_const.rs
+1
-2
src/rustc/middle/lint.rs
src/rustc/middle/lint.rs
+2
-74
src/rustc/middle/trans/alt.rs
src/rustc/middle/trans/alt.rs
+0
-1
src/rustc/middle/trans/base.rs
src/rustc/middle/trans/base.rs
+4
-2
src/rustc/middle/typeck/check.rs
src/rustc/middle/typeck/check.rs
+2
-2
src/test/compile-fail/alt-range-fail.rs
src/test/compile-fail/alt-range-fail.rs
+2
-2
src/test/compile-fail/binop-bitxor-str.rs
src/test/compile-fail/binop-bitxor-str.rs
+1
-1
src/test/compile-fail/issue-2063.rs
src/test/compile-fail/issue-2063.rs
+1
-1
src/test/compile-fail/minus-string.rs
src/test/compile-fail/minus-string.rs
+1
-1
src/test/compile-fail/missing-do.rs
src/test/compile-fail/missing-do.rs
+1
-1
src/test/compile-fail/mutable-huh-variance-vec1.rs
src/test/compile-fail/mutable-huh-variance-vec1.rs
+1
-1
src/test/compile-fail/mutable-huh-variance-vec2.rs
src/test/compile-fail/mutable-huh-variance-vec2.rs
+1
-1
src/test/compile-fail/mutable-huh-variance-vec4.rs
src/test/compile-fail/mutable-huh-variance-vec4.rs
+3
-3
src/test/compile-fail/non-exhaustive-match-nested.rs
src/test/compile-fail/non-exhaustive-match-nested.rs
+2
-2
src/test/compile-fail/unsendable-class.rs
src/test/compile-fail/unsendable-class.rs
+2
-2
src/test/run-pass/macro-by-example-2.rs
src/test/run-pass/macro-by-example-2.rs
+2
-4
未找到文件。
src/rustc/middle/check_const.rs
浏览文件 @
6822ec3e
...
...
@@ -38,14 +38,13 @@ fn check_item(sess: session, ast_map: ast_map::map, def_map: resolve::def_map,
fn
check_pat
(
p
:
@
pat
,
&&
_
is_const
:
bool
,
v
:
visit
::
vt
<
bool
>
)
{
fn
is_str
(
e
:
@
expr
)
->
bool
{
alt
e
.node
{
expr_lit
(
@
{
node
:
lit_str
(
_
),
_
})
|
expr_vstore
(
@
{
node
:
expr_lit
(
@
{
node
:
lit_str
(
_
),
_
}),
_
},
vstore_uniq
)
{
true
}
_
{
false
}
}
}
alt
p
.node
{
// Let through plain string literals here
// Let through plain
~-
string literals here
pat_lit
(
a
)
{
if
!
is_str
(
a
)
{
v
.visit_expr
(
a
,
true
,
v
);
}
}
pat_range
(
a
,
b
)
{
if
!
is_str
(
a
)
{
v
.visit_expr
(
a
,
true
,
v
);
}
...
...
src/rustc/middle/lint.rs
浏览文件 @
6822ec3e
...
...
@@ -43,12 +43,10 @@ enum lint {
unused_imports
,
while_true
,
path_statement
,
old_vec
s
,
implicit_copie
s
,
unrecognized_warning
,
non_implicitly_copyable_typarams
,
vecs_not_implicitly_copyable
,
implicit_copies
,
old_strs
,
}
// This is pretty unfortunate. We really want some sort of "deriving Enum"
...
...
@@ -59,12 +57,10 @@ fn int_to_lint(i: int) -> lint {
1
{
unused_imports
}
2
{
while_true
}
3
{
path_statement
}
4
{
old_vec
s
}
4
{
implicit_copie
s
}
5
{
unrecognized_warning
}
6
{
non_implicitly_copyable_typarams
}
7
{
vecs_not_implicitly_copyable
}
8
{
implicit_copies
}
9
{
old_strs
}
}
}
...
...
@@ -104,16 +100,6 @@ fn get_lint_dict() -> lint_dict {
desc
:
~
"path statements with no effect"
,
default
:
warn
}),
(
~
"old_vecs"
,
@
{
lint
:
old_vecs
,
desc
:
~
"old (deprecated) vectors"
,
default
:
error
}),
(
~
"old_strs"
,
@
{
lint
:
old_strs
,
desc
:
~
"old (deprecated) strings"
,
default
:
error
}),
(
~
"unrecognized_warning"
,
@
{
lint
:
unrecognized_warning
,
desc
:
~
"unrecognized warning attribute"
,
...
...
@@ -321,7 +307,6 @@ fn check_item(i: @ast::item, cx: ty::ctxt) {
check_item_ctypes
(
cx
,
i
);
check_item_while_true
(
cx
,
i
);
check_item_path_statement
(
cx
,
i
);
check_item_old_vecs
(
cx
,
i
);
}
// Take a visitor, and modify it so that it will not proceed past subitems.
...
...
@@ -422,63 +407,6 @@ fn check_item_path_statement(cx: ty::ctxt, it: @ast::item) {
visit
::
visit_item
(
it
,
(),
visit
);
}
fn
check_item_old_vecs
(
cx
:
ty
::
ctxt
,
it
:
@
ast
::
item
)
{
let
uses_vstore
=
int_hash
();
let
visit
=
item_stopping_visitor
(
visit
::
mk_simple_visitor
(
@
{
visit_expr
:
fn
@
(
e
:
@
ast
::
expr
)
{
alt
e
.node
{
ast
::
expr_vec
(
_
,
_
)
if
!
uses_vstore
.contains_key
(
e
.id
)
{
cx
.sess
.span_lint
(
old_vecs
,
e
.id
,
it
.id
,
e
.span
,
~
"deprecated vec expr"
);
}
ast
::
expr_lit
(
@
{
node
:
ast
::
lit_str
(
_
),
span
:
_
})
if
!
uses_vstore
.contains_key
(
e
.id
)
{
cx
.sess
.span_lint
(
old_strs
,
e
.id
,
it
.id
,
e
.span
,
~
"deprecated str expr"
);
}
ast
::
expr_vstore
(
@
inner
,
_
)
{
uses_vstore
.insert
(
inner
.id
,
true
);
}
_
{
}
}
},
visit_ty
:
fn
@
(
t
:
@
ast
::
ty
)
{
alt
t
.node
{
ast
::
ty_vec
(
_
)
if
!
uses_vstore
.contains_key
(
t
.id
)
{
cx
.sess
.span_lint
(
old_vecs
,
t
.id
,
it
.id
,
t
.span
,
~
"deprecated vec type"
);
}
ast
::
ty_path
(
@
{
span
:
_
,
global
:
_
,
idents
:
ids
,
rp
:
none
,
types
:
_
},
_
)
if
ids
==
~
[
@~
"str"
]
&&
(
!
uses_vstore
.contains_key
(
t
.id
))
{
cx
.sess
.span_lint
(
old_strs
,
t
.id
,
it
.id
,
t
.span
,
~
"deprecated str type"
);
}
ast
::
ty_fixed_length
(
inner
,
_
)
|
ast
::
ty_box
({
ty
:
inner
,
_
})
|
ast
::
ty_uniq
({
ty
:
inner
,
_
})
|
ast
::
ty_rptr
(
_
,
{
ty
:
inner
,
_
})
{
uses_vstore
.insert
(
inner
.id
,
true
);
}
_
{
}
}
}
with
*
visit
::
default_simple_visitor
()
}));
visit
::
visit_item
(
it
,
(),
visit
);
}
fn
check_crate
(
tcx
:
ty
::
ctxt
,
crate
:
@
ast
::
crate
)
{
let
v
=
visit
::
mk_simple_visitor
(
@
{
...
...
src/rustc/middle/trans/alt.rs
浏览文件 @
6822ec3e
...
...
@@ -47,7 +47,6 @@ fn trans_opt(bcx: block, o: opt) -> opt_result {
alt
o
{
lit
(
l
)
{
alt
l
.node
{
ast
::
expr_lit
(
@
{
node
:
ast
::
lit_str
(
s
),
_
})
|
ast
::
expr_vstore
(
@
{
node
:
ast
::
expr_lit
(
@
{
node
:
ast
::
lit_str
(
s
),
_
}),
_
},
ast
::
vstore_uniq
)
{
...
...
src/rustc/middle/trans/base.rs
浏览文件 @
6822ec3e
...
...
@@ -1447,7 +1447,8 @@ fn trans_lit(cx: block, e: @ast::expr, lit: ast::lit, dest: dest) -> block {
let
_
icx
=
cx
.insn_ctxt
(
~
"trans_lit"
);
if
dest
==
ignore
{
ret
cx
;
}
alt
lit
.node
{
ast
::
lit_str
(
s
)
{
tvec
::
trans_estr
(
cx
,
s
,
ast
::
vstore_uniq
,
dest
)
}
ast
::
lit_str
(
s
)
{
tvec
::
trans_estr
(
cx
,
s
,
ast
::
vstore_fixed
(
none
),
dest
)
}
_
{
store_in_dest
(
cx
,
trans_crate_lit
(
cx
.ccx
(),
e
,
lit
),
dest
)
}
...
...
@@ -3542,7 +3543,8 @@ fn unrooted(bcx: block, e: @ast::expr, dest: dest) -> block {
ast
::
expr_vstore
(
e
,
v
)
{
ret
tvec
::
trans_vstore
(
bcx
,
e
,
v
,
dest
);
}
ast
::
expr_lit
(
lit
)
{
ret
trans_lit
(
bcx
,
e
,
*
lit
,
dest
);
}
ast
::
expr_vec
(
args
,
_
)
{
ret
tvec
::
trans_evec
(
bcx
,
args
,
ast
::
vstore_uniq
,
e
.id
,
dest
);
ret
tvec
::
trans_evec
(
bcx
,
args
,
ast
::
vstore_fixed
(
none
),
e
.id
,
dest
);
}
ast
::
expr_binary
(
op
,
lhs
,
rhs
)
{
ret
trans_binary
(
bcx
,
op
,
lhs
,
rhs
,
dest
,
e
);
...
...
src/rustc/middle/typeck/check.rs
浏览文件 @
6822ec3e
...
...
@@ -611,7 +611,7 @@ fn check_lit(fcx: @fn_ctxt, lit: @ast::lit) -> ty::t {
let
tcx
=
fcx
.ccx.tcx
;
alt
lit
.node
{
ast
::
lit_str
(
_
)
{
ty
::
mk_estr
(
tcx
,
ty
::
vstore_uniq
)
}
ast
::
lit_str
(
s
)
{
ty
::
mk_estr
(
tcx
,
ty
::
vstore_fixed
(
s
.len
())
)
}
ast
::
lit_int
(
_
,
t
)
{
ty
::
mk_mach_int
(
tcx
,
t
)
}
ast
::
lit_uint
(
_
,
t
)
{
ty
::
mk_mach_uint
(
tcx
,
t
)
}
ast
::
lit_int_unsuffixed
(
_
)
{
...
...
@@ -1524,7 +1524,7 @@ fn check_field(fcx: @fn_ctxt, expr: @ast::expr, is_callee: bool,
let
t
:
ty
::
t
=
fcx
.infcx
.next_ty_var
();
for
args
.each
|
e
|
{
bot
|
=
check_expr_with
(
fcx
,
e
,
t
);
}
let
typ
=
ty
::
mk_evec
(
tcx
,
{
ty
:
t
,
mutbl
:
mutbl
},
ty
::
vstore_
uniq
);
ty
::
vstore_
fixed
(
args
.len
())
);
fcx
.write_ty
(
id
,
typ
);
}
ast
::
expr_tup
(
elts
)
{
...
...
src/test/compile-fail/alt-range-fail.rs
浏览文件 @
6822ec3e
...
...
@@ -9,11 +9,11 @@ fn main() {
};
alt
"wow"
{
"
wow"
to
"woow
"
{
}
"
bar"
to
"foo
"
{
}
};
alt
5u
{
'c'
to
100u
{
}
_
{
}
};
}
\ No newline at end of file
}
src/test/compile-fail/binop-bitxor-str.rs
浏览文件 @
6822ec3e
// error-pattern:^ cannot be applied to type `~str`
fn
main
()
{
let
x
=
"a"
^
"b"
;
}
fn
main
()
{
let
x
=
~
"a"
^
~
"b"
;
}
src/test/compile-fail/issue-2063.rs
浏览文件 @
6822ec3e
...
...
@@ -7,7 +7,7 @@
// the compiler to attempt autoderef and then
// try to resolve the method.
impl
methods
for
t
{
fn
to_str
()
->
~
str
{
"t"
}
fn
to_str
()
->
~
str
{
~
"t"
}
}
fn
new_t
(
x
:
t
)
{
...
...
src/test/compile-fail/minus-string.rs
浏览文件 @
6822ec3e
// error-pattern:cannot apply unary operator `-` to type `~str`
fn
main
()
{
-
"foo"
;
}
fn
main
()
{
-
~
"foo"
;
}
src/test/compile-fail/missing-do.rs
浏览文件 @
6822ec3e
...
...
@@ -3,7 +3,7 @@
fn
foo
(
f
:
fn
())
{
f
()
}
fn
main
()
{
""
||
42
;
//~ ERROR binary operation || cannot be applied to type `~str`
~
""
||
42
;
//~ ERROR binary operation || cannot be applied to type `~str`
foo
||
{};
//~ ERROR binary operation || cannot be applied to type `extern fn(fn())`
//~^ NOTE did you forget the 'do' keyword for the call?
}
src/test/compile-fail/mutable-huh-variance-vec1.rs
浏览文件 @
6822ec3e
...
...
@@ -5,7 +5,7 @@ fn main() {
let
v
:
~
[
mut
~
[
int
]]
=
~
[
mut
~
[
0
]];
fn
f
(
&&
v
:
~
[
mut
~
[
const
int
]])
{
v
[
0
]
=
[
mut
3
]
v
[
0
]
=
~
[
mut
3
]
}
f
(
v
);
//~ ERROR (values differ in mutability)
...
...
src/test/compile-fail/mutable-huh-variance-vec2.rs
浏览文件 @
6822ec3e
...
...
@@ -5,7 +5,7 @@ fn main() {
let
v
:
~
[
mut
~
[
mut
int
]]
=
~
[
mut
~
[
mut
0
]];
fn
f
(
&&
v
:
~
[
mut
~
[
const
int
]])
{
v
[
0
]
=
[
3
]
v
[
0
]
=
~
[
3
]
}
f
(
v
);
//~ ERROR (values differ in mutability)
...
...
src/test/compile-fail/mutable-huh-variance-vec4.rs
浏览文件 @
6822ec3e
...
...
@@ -8,18 +8,18 @@ fn main() {
let
x
=
~
[
mut
~
[
mut
0
]];
fn
f
(
&&
v
:
~
[
mut
~
[
int
]])
{
v
[
0
]
=
[
3
]
v
[
0
]
=
~
[
3
]
}
fn
g
(
&&
v
:
~
[
const
~
[
const
int
]])
{
}
fn
h
(
&&
v
:
~
[
mut
~
[
mut
int
]])
{
v
[
0
]
=
[
mut
3
]
v
[
0
]
=
~
[
mut
3
]
}
fn
i
(
&&
v
:
~
[
mut
~
[
const
int
]])
{
v
[
0
]
=
[
mut
3
]
v
[
0
]
=
~
[
mut
3
]
}
fn
j
(
&&
v
:
~
[
~
[
const
int
]])
{
...
...
src/test/compile-fail/non-exhaustive-match-nested.rs
浏览文件 @
6822ec3e
...
...
@@ -6,8 +6,8 @@ enum u { c, d }
fn
main
()
{
let
x
=
a
(
c
);
alt
x
{
a
(
d
)
{
fail
"hello"
;
}
b
{
fail
"goodbye"
;
}
a
(
d
)
{
fail
~
"hello"
;
}
b
{
fail
~
"goodbye"
;
}
}
}
src/test/compile-fail/unsendable-class.rs
浏览文件 @
6822ec3e
...
...
@@ -8,8 +8,8 @@
}
fn
main
()
{
let
cat
=
"kitty"
;
let
cat
=
~
"kitty"
;
let
po
=
comm
::
port
();
//~ ERROR missing `send`
let
ch
=
comm
::
chan
(
po
);
//~ ERROR missing `send`
comm
::
send
(
ch
,
foo
(
42
,
@
cat
));
//~ ERROR missing `send`
}
\ No newline at end of file
}
src/test/run-pass/macro-by-example-2.rs
浏览文件 @
6822ec3e
// xfail-test
// I can't for the life of me manage to untangle all of the brackets
// in this test. I am just suppessing the old_vec diagnostic. This
// doesn't actually care what sort of vector it uses, so if we change
// what vectors mean, it shouldn't mind...
#[warn(no_old_vecs)]
;
// in this test, so I am xfailing it...
fn
main
()
{
#
macro
[[
#
zip_or_unzip
[[
x
,
...
],
[
y
,
...
]],
[[
x
,
y
],
...
]],
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录