Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
ee0be3b3
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,发现更多精彩内容 >>
提交
ee0be3b3
编写于
1月 28, 2015
作者:
B
bors
浏览文件
操作
浏览文件
下载
差异文件
Auto merge of #21698 - Manishearth:rollup, r=alexcrichton
This should work now.
上级
a45e1177
c709ed2f
变更
126
展开全部
隐藏空白更改
内联
并排
Showing
126 changed file
with
1204 addition
and
1167 deletion
+1204
-1167
src/compiletest/common.rs
src/compiletest/common.rs
+2
-5
src/doc/reference.md
src/doc/reference.md
+3
-3
src/doc/trpl/more-strings.md
src/doc/trpl/more-strings.md
+2
-2
src/doc/trpl/ownership.md
src/doc/trpl/ownership.md
+1
-0
src/etc/check-summary.py
src/etc/check-summary.py
+6
-2
src/etc/errorck.py
src/etc/errorck.py
+3
-1
src/etc/extract_grammar.py
src/etc/extract_grammar.py
+68
-68
src/etc/gdb_rust_pretty_printing.py
src/etc/gdb_rust_pretty_printing.py
+188
-176
src/etc/generate-keyword-tests.py
src/etc/generate-keyword-tests.py
+1
-1
src/etc/get-snapshot.py
src/etc/get-snapshot.py
+51
-43
src/etc/htmldocck.py
src/etc/htmldocck.py
+45
-15
src/etc/latest-unix-snaps.py
src/etc/latest-unix-snaps.py
+12
-10
src/etc/lldb_batchmode.py
src/etc/lldb_batchmode.py
+112
-106
src/etc/lldb_rust_formatters.py
src/etc/lldb_rust_formatters.py
+171
-169
src/etc/make-win-dist.py
src/etc/make-win-dist.py
+7
-2
src/etc/maketest.py
src/etc/maketest.py
+20
-18
src/etc/mirror-all-snapshots.py
src/etc/mirror-all-snapshots.py
+4
-3
src/etc/mklldeps.py
src/etc/mklldeps.py
+1
-2
src/etc/snapshot.py
src/etc/snapshot.py
+153
-132
src/etc/sugarise-doc-comments.py
src/etc/sugarise-doc-comments.py
+4
-2
src/etc/tidy.py
src/etc/tidy.py
+22
-14
src/etc/unicode.py
src/etc/unicode.py
+1
-3
src/etc/vim/syntax_checkers/rust/rustc.vim
src/etc/vim/syntax_checkers/rust/rustc.vim
+1
-1
src/libcollections/slice.rs
src/libcollections/slice.rs
+105
-4
src/libcollections/vec.rs
src/libcollections/vec.rs
+47
-2
src/libcore/nonzero.rs
src/libcore/nonzero.rs
+1
-1
src/libcore/ops.rs
src/libcore/ops.rs
+4
-4
src/librustc_llvm/diagnostic.rs
src/librustc_llvm/diagnostic.rs
+2
-2
src/librustdoc/html/static/main.css
src/librustdoc/html/static/main.css
+8
-1
src/libstd/os.rs
src/libstd/os.rs
+4
-4
src/libstd/rand/mod.rs
src/libstd/rand/mod.rs
+27
-27
src/libstd/rand/os.rs
src/libstd/rand/os.rs
+4
-4
src/libunicode/lib.rs
src/libunicode/lib.rs
+1
-0
src/libunicode/tables.rs
src/libunicode/tables.rs
+1
-4
src/libunicode/u_str.rs
src/libunicode/u_str.rs
+1
-3
src/test/auxiliary/issue-14422.rs
src/test/auxiliary/issue-14422.rs
+1
-2
src/test/auxiliary/issue13213aux.rs
src/test/auxiliary/issue13213aux.rs
+2
-3
src/test/auxiliary/method_self_arg1.rs
src/test/auxiliary/method_self_arg1.rs
+1
-2
src/test/auxiliary/method_self_arg2.rs
src/test/auxiliary/method_self_arg2.rs
+1
-2
src/test/auxiliary/xcrate_unit_struct.rs
src/test/auxiliary/xcrate_unit_struct.rs
+5
-10
src/test/bench/noise.rs
src/test/bench/noise.rs
+1
-2
src/test/bench/shootout-chameneos-redux.rs
src/test/bench/shootout-chameneos-redux.rs
+2
-4
src/test/bench/shootout-fannkuch-redux.rs
src/test/bench/shootout-fannkuch-redux.rs
+2
-4
src/test/bench/shootout-fasta-redux.rs
src/test/bench/shootout-fasta-redux.rs
+1
-2
src/test/bench/shootout-k-nucleotide.rs
src/test/bench/shootout-k-nucleotide.rs
+1
-3
src/test/bench/shootout-nbody.rs
src/test/bench/shootout-nbody.rs
+1
-2
src/test/bench/task-perf-one-million.rs
src/test/bench/task-perf-one-million.rs
+0
-70
src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs
src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs
+2
-4
src/test/compile-fail/borrowck-borrow-from-stack-variable.rs
src/test/compile-fail/borrowck-borrow-from-stack-variable.rs
+2
-4
src/test/compile-fail/borrowck-use-mut-borrow.rs
src/test/compile-fail/borrowck-use-mut-borrow.rs
+1
-2
src/test/compile-fail/dst-index.rs
src/test/compile-fail/dst-index.rs
+2
-4
src/test/compile-fail/kindck-copy.rs
src/test/compile-fail/kindck-copy.rs
+1
-2
src/test/debuginfo/generic-method-on-generic-struct.rs
src/test/debuginfo/generic-method-on-generic-struct.rs
+1
-2
src/test/debuginfo/method-on-enum.rs
src/test/debuginfo/method-on-enum.rs
+1
-2
src/test/debuginfo/method-on-generic-struct.rs
src/test/debuginfo/method-on-generic-struct.rs
+1
-2
src/test/debuginfo/method-on-struct.rs
src/test/debuginfo/method-on-struct.rs
+1
-2
src/test/debuginfo/method-on-trait.rs
src/test/debuginfo/method-on-trait.rs
+1
-2
src/test/debuginfo/method-on-tuple-struct.rs
src/test/debuginfo/method-on-tuple-struct.rs
+1
-2
src/test/debuginfo/self-in-default-method.rs
src/test/debuginfo/self-in-default-method.rs
+1
-2
src/test/debuginfo/self-in-generic-default-method.rs
src/test/debuginfo/self-in-generic-default-method.rs
+1
-2
src/test/pretty/block-disambig.rs
src/test/pretty/block-disambig.rs
+1
-2
src/test/run-make/extern-fn-with-packed-struct/test.rs
src/test/run-make/extern-fn-with-packed-struct/test.rs
+1
-3
src/test/run-pass/borrowck-univariant-enum.rs
src/test/run-pass/borrowck-univariant-enum.rs
+1
-2
src/test/run-pass/builtin-superkinds-in-metadata.rs
src/test/run-pass/builtin-superkinds-in-metadata.rs
+1
-2
src/test/run-pass/cell-does-not-clone.rs
src/test/run-pass/cell-does-not-clone.rs
+1
-2
src/test/run-pass/class-impl-very-parameterized-trait.rs
src/test/run-pass/class-impl-very-parameterized-trait.rs
+1
-3
src/test/run-pass/coherence-impl-in-fn.rs
src/test/run-pass/coherence-impl-in-fn.rs
+1
-1
src/test/run-pass/coherence-where-clause.rs
src/test/run-pass/coherence-where-clause.rs
+1
-3
src/test/run-pass/const-nullary-univariant-enum.rs
src/test/run-pass/const-nullary-univariant-enum.rs
+1
-2
src/test/run-pass/dst-struct-sole.rs
src/test/run-pass/dst-struct-sole.rs
+1
-3
src/test/run-pass/dst-struct.rs
src/test/run-pass/dst-struct.rs
+1
-3
src/test/run-pass/dst-trait.rs
src/test/run-pass/dst-trait.rs
+2
-6
src/test/run-pass/empty-tag.rs
src/test/run-pass/empty-tag.rs
+1
-3
src/test/run-pass/enum-discrim-width-stuff.rs
src/test/run-pass/enum-discrim-width-stuff.rs
+1
-2
src/test/run-pass/explicit-self-generic.rs
src/test/run-pass/explicit-self-generic.rs
+1
-2
src/test/run-pass/export-unexported-dep.rs
src/test/run-pass/export-unexported-dep.rs
+1
-2
src/test/run-pass/expr-copy.rs
src/test/run-pass/expr-copy.rs
+1
-2
src/test/run-pass/expr-if-struct.rs
src/test/run-pass/expr-if-struct.rs
+2
-5
src/test/run-pass/expr-match-struct.rs
src/test/run-pass/expr-match-struct.rs
+2
-5
src/test/run-pass/exterior.rs
src/test/run-pass/exterior.rs
+1
-2
src/test/run-pass/extern-pass-TwoU16s.rs
src/test/run-pass/extern-pass-TwoU16s.rs
+1
-3
src/test/run-pass/extern-pass-TwoU32s.rs
src/test/run-pass/extern-pass-TwoU32s.rs
+1
-3
src/test/run-pass/extern-pass-TwoU64s.rs
src/test/run-pass/extern-pass-TwoU64s.rs
+1
-3
src/test/run-pass/extern-pass-TwoU8s.rs
src/test/run-pass/extern-pass-TwoU8s.rs
+1
-3
src/test/run-pass/foreign-fn-with-byval.rs
src/test/run-pass/foreign-fn-with-byval.rs
+1
-2
src/test/run-pass/generic-fn.rs
src/test/run-pass/generic-fn.rs
+1
-2
src/test/run-pass/guards-not-exhaustive.rs
src/test/run-pass/guards-not-exhaustive.rs
+1
-2
src/test/run-pass/guards.rs
src/test/run-pass/guards.rs
+1
-2
src/test/run-pass/hrtb-opt-in-copy.rs
src/test/run-pass/hrtb-opt-in-copy.rs
+1
-2
src/test/run-pass/issue-12860.rs
src/test/run-pass/issue-12860.rs
+1
-3
src/test/run-pass/issue-19100.rs
src/test/run-pass/issue-19100.rs
+1
-2
src/test/run-pass/issue-2288.rs
src/test/run-pass/issue-2288.rs
+1
-2
src/test/run-pass/issue-2633.rs
src/test/run-pass/issue-2633.rs
+2
-4
src/test/run-pass/issue-3121.rs
src/test/run-pass/issue-3121.rs
+3
-4
src/test/run-pass/issue-3563-3.rs
src/test/run-pass/issue-3563-3.rs
+3
-6
src/test/run-pass/issue-3743.rs
src/test/run-pass/issue-3743.rs
+1
-2
src/test/run-pass/issue-3753.rs
src/test/run-pass/issue-3753.rs
+2
-4
src/test/run-pass/issue-5688.rs
src/test/run-pass/issue-5688.rs
+1
-2
src/test/run-pass/match-arm-statics.rs
src/test/run-pass/match-arm-statics.rs
+1
-2
src/test/run-pass/method-self-arg-trait.rs
src/test/run-pass/method-self-arg-trait.rs
+1
-2
src/test/run-pass/method-self-arg.rs
src/test/run-pass/method-self-arg.rs
+1
-2
src/test/run-pass/monomorphize-abi-alignment.rs
src/test/run-pass/monomorphize-abi-alignment.rs
+3
-8
src/test/run-pass/multidispatch1.rs
src/test/run-pass/multidispatch1.rs
+1
-2
src/test/run-pass/multidispatch2.rs
src/test/run-pass/multidispatch2.rs
+1
-2
src/test/run-pass/newtype.rs
src/test/run-pass/newtype.rs
+2
-4
src/test/run-pass/out-pointer-aliasing.rs
src/test/run-pass/out-pointer-aliasing.rs
+1
-2
src/test/run-pass/overloaded-autoderef-order.rs
src/test/run-pass/overloaded-autoderef-order.rs
+2
-4
src/test/run-pass/packed-struct-vec.rs
src/test/run-pass/packed-struct-vec.rs
+1
-3
src/test/run-pass/rec-tup.rs
src/test/run-pass/rec-tup.rs
+1
-2
src/test/run-pass/rec.rs
src/test/run-pass/rec.rs
+1
-5
src/test/run-pass/regions-dependent-addr-of.rs
src/test/run-pass/regions-dependent-addr-of.rs
+1
-2
src/test/run-pass/regions-early-bound-used-in-bound-method.rs
...test/run-pass/regions-early-bound-used-in-bound-method.rs
+1
-2
src/test/run-pass/regions-early-bound-used-in-type-param.rs
src/test/run-pass/regions-early-bound-used-in-type-param.rs
+1
-2
src/test/run-pass/regions-mock-tcx.rs
src/test/run-pass/regions-mock-tcx.rs
+4
-10
src/test/run-pass/self-in-mut-slot-immediate-value.rs
src/test/run-pass/self-in-mut-slot-immediate-value.rs
+1
-2
src/test/run-pass/simd-generics.rs
src/test/run-pass/simd-generics.rs
+3
-3
src/test/run-pass/small-enum-range-edge.rs
src/test/run-pass/small-enum-range-edge.rs
+2
-4
src/test/run-pass/struct-return.rs
src/test/run-pass/struct-return.rs
+2
-4
src/test/run-pass/structured-compare.rs
src/test/run-pass/structured-compare.rs
+1
-3
src/test/run-pass/tag-variant-disr-val.rs
src/test/run-pass/tag-variant-disr-val.rs
+1
-2
src/test/run-pass/trait-coercion-generic.rs
src/test/run-pass/trait-coercion-generic.rs
+1
-2
src/test/run-pass/trait-coercion.rs
src/test/run-pass/trait-coercion.rs
+1
-2
src/test/run-pass/typeclasses-eq-example-static.rs
src/test/run-pass/typeclasses-eq-example-static.rs
+1
-3
src/test/run-pass/typeclasses-eq-example.rs
src/test/run-pass/typeclasses-eq-example.rs
+1
-3
src/test/run-pass/ufcs-explicit-self.rs
src/test/run-pass/ufcs-explicit-self.rs
+2
-4
src/test/run-pass/unboxed-closures-monomorphization.rs
src/test/run-pass/unboxed-closures-monomorphization.rs
+1
-3
未找到文件。
src/compiletest/common.rs
浏览文件 @
ee0be3b3
...
...
@@ -13,7 +13,7 @@
use
std
::
str
::
FromStr
;
#[cfg(stage0)]
// NOTE: remove impl after snapshot
#[derive(Clone,
PartialEq,
Show)]
#[derive(Clone,
Copy,
PartialEq,
Show)]
pub
enum
Mode
{
CompileFail
,
RunFail
,
...
...
@@ -26,7 +26,7 @@ pub enum Mode {
}
#[cfg(not(stage0))]
// NOTE: remove cfg after snapshot
#[derive(Clone,
PartialEq,
Debug)]
#[derive(Clone,
Copy,
PartialEq,
Debug)]
pub
enum
Mode
{
CompileFail
,
RunFail
,
...
...
@@ -38,9 +38,6 @@ pub enum Mode {
Codegen
}
impl
Copy
for
Mode
{}
impl
FromStr
for
Mode
{
fn
from_str
(
s
:
&
str
)
->
Option
<
Mode
>
{
match
s
{
...
...
src/doc/reference.md
浏览文件 @
ee0be3b3
...
...
@@ -1680,8 +1680,8 @@ specific type.
Implementations are defined with the keyword
`impl`
.
```
# #[derive(Copy)]
# struct Point {x: f64, y: f64};
# impl Copy for Point {}
# type Surface = i32;
# struct BoundingBox {x: f64, y: f64, width: f64, height: f64};
# trait Shape { fn draw(&self, Surface); fn bounding_box(&self) -> BoundingBox; }
...
...
@@ -2219,7 +2219,7 @@ For any lint check `C`:
The lint checks supported by the compiler can be found via
`rustc -W help`
,
along with their default settings.
[
Compiler
plugins
](
book/plugin.html#lint-plugins
)
can provide additional lint checks.
plugins
](
book/plugin
s
.html#lint-plugins
)
can provide additional lint checks.
```
{.ignore}
mod m1 {
...
...
@@ -4163,4 +4163,4 @@ that have since been removed):
pattern syntax
[
ffi
]:
book/ffi.html
[
plugin
]:
book/plugin.html
[
plugin
]:
book/plugin
s
.html
src/doc/trpl/more-strings.md
浏览文件 @
ee0be3b3
...
...
@@ -279,5 +279,5 @@ Many more bytes than graphemes!
# Other Documentation
*
[
the `&str` API documentation
](
std/str/index.html
)
*
[
the `String` API documentation
](
std/string/index.html
)
*
[
the `&str` API documentation
](
../
std/str/index.html
)
*
[
the `String` API documentation
](
../
std/string/index.html
)
src/doc/trpl/ownership.md
浏览文件 @
ee0be3b3
...
...
@@ -533,6 +533,7 @@ fn substr<'a>(s: &'a str, until: u32) -> &'a str; // expanded
fn get_str() -> &str; // ILLEGAL, no inputs
fn frob(s: &str, t: &str) -> &str; // ILLEGAL, two inputs
fn frob<'a, 'b>(s: &'a str, t: &'b str) -> &str; // Expanded: Output lifetime is unclear
fn get_mut(&mut self) -> &mut T; // elided
fn get_mut<'a>(&'a mut self) -> &'a mut T; // expanded
...
...
src/etc/check-summary.py
浏览文件 @
ee0be3b3
...
...
@@ -15,6 +15,7 @@ import sys
if
__name__
==
'__main__'
:
summaries
=
[]
def
summarise
(
fname
):
summary
=
{}
with
open
(
fname
)
as
fd
:
...
...
@@ -27,12 +28,14 @@ if __name__ == '__main__':
# track bench runs
if
splitline
[
1
]
==
'ns/iter'
:
status
=
'bench'
if
not
summary
.
has_key
(
status
)
:
if
status
not
in
summary
:
summary
[
status
]
=
[]
summary
[
status
].
append
(
test
)
summaries
.
append
((
fname
,
summary
))
def
count
(
t
):
return
sum
(
map
(
lambda
(
f
,
s
):
len
(
s
.
get
(
t
,
[])),
summaries
))
logfiles
=
sys
.
argv
[
1
:]
for
files
in
map
(
glob
.
glob
,
logfiles
):
map
(
summarise
,
files
)
...
...
@@ -41,8 +44,9 @@ if __name__ == '__main__':
ignored
=
count
(
'ignored'
)
measured
=
count
(
'bench'
)
print
"summary of %d test runs: %d passed; %d failed; %d ignored; %d measured"
%
\
(
len
(
logfiles
),
ok
,
failed
,
ignored
,
measured
)
(
len
(
logfiles
),
ok
,
failed
,
ignored
,
measured
)
print
""
if
failed
>
0
:
print
"failed tests:"
for
f
,
s
in
summaries
:
...
...
src/etc/errorck.py
浏览文件 @
ee0be3b3
...
...
@@ -11,7 +11,9 @@
# Digs error codes out of files named 'diagnostics.rs' across
# the tree, and ensures thare are no duplicates.
import
sys
,
os
,
re
import
sys
import
os
import
re
src_dir
=
sys
.
argv
[
1
]
errcode_map
=
{}
...
...
src/etc/extract_grammar.py
浏览文件 @
ee0be3b3
...
...
@@ -14,11 +14,11 @@
import
fileinput
collections
=
{
"gram"
:
[],
"keyword"
:
[],
"reserved"
:
[],
"binop"
:
[],
"unop"
:
[]
}
collections
=
{
"gram"
:
[],
"keyword"
:
[],
"reserved"
:
[],
"binop"
:
[],
"unop"
:
[]
}
in_coll
=
False
...
...
@@ -47,66 +47,66 @@ for line in fileinput.input(openhook=fileinput.hook_encoded("utf-8")):
# Define operator symbol-names here
tokens
=
[
"non_star"
,
"non_slash"
,
"non_eol"
,
"non_single_quote"
,
"non_double_quote"
,
"ident"
]
"non_single_quote"
,
"non_double_quote"
,
"ident"
]
symnames
=
{
"."
:
"dot"
,
"+"
:
"plus"
,
"-"
:
"minus"
,
"/"
:
"slash"
,
"*"
:
"star"
,
"%"
:
"percent"
,
"~"
:
"tilde"
,
"@"
:
"at"
,
"!"
:
"not"
,
"&"
:
"and"
,
"|"
:
"or"
,
"^"
:
"xor"
,
"<<"
:
"lsl"
,
">>"
:
"lsr"
,
">>>"
:
"asr"
,
"&&"
:
"andand"
,
"||"
:
"oror"
,
"<"
:
"lt"
,
"<="
:
"le"
,
"=="
:
"eqeq"
,
">="
:
"ge"
,
">"
:
"gt"
,
"="
:
"eq"
,
"+="
:
"plusequal"
,
"-="
:
"minusequal"
,
"/="
:
"divequal"
,
"*="
:
"starequal"
,
"%="
:
"percentequal"
,
"&="
:
"andequal"
,
"|="
:
"orequal"
,
"^="
:
"xorequal"
,
">>="
:
"lsrequal"
,
">>>="
:
"asrequal"
,
"<<="
:
"lslequal"
,
"::"
:
"coloncolon"
,
"->"
:
"rightarrow"
,
"<-"
:
"leftarrow"
,
"<->"
:
"swaparrow"
,
"//"
:
"linecomment"
,
"/*"
:
"openblockcomment"
,
"*/"
:
"closeblockcomment"
,
"macro_rules"
:
"macro_rules"
,
"=>"
:
"eg"
,
".."
:
"dotdot"
,
","
:
"comma"
"."
:
"dot"
,
"+"
:
"plus"
,
"-"
:
"minus"
,
"/"
:
"slash"
,
"*"
:
"star"
,
"%"
:
"percent"
,
"~"
:
"tilde"
,
"@"
:
"at"
,
"!"
:
"not"
,
"&"
:
"and"
,
"|"
:
"or"
,
"^"
:
"xor"
,
"<<"
:
"lsl"
,
">>"
:
"lsr"
,
">>>"
:
"asr"
,
"&&"
:
"andand"
,
"||"
:
"oror"
,
"<"
:
"lt"
,
"<="
:
"le"
,
"=="
:
"eqeq"
,
">="
:
"ge"
,
">"
:
"gt"
,
"="
:
"eq"
,
"+="
:
"plusequal"
,
"-="
:
"minusequal"
,
"/="
:
"divequal"
,
"*="
:
"starequal"
,
"%="
:
"percentequal"
,
"&="
:
"andequal"
,
"|="
:
"orequal"
,
"^="
:
"xorequal"
,
">>="
:
"lsrequal"
,
">>>="
:
"asrequal"
,
"<<="
:
"lslequal"
,
"::"
:
"coloncolon"
,
"->"
:
"rightarrow"
,
"<-"
:
"leftarrow"
,
"<->"
:
"swaparrow"
,
"//"
:
"linecomment"
,
"/*"
:
"openblockcomment"
,
"*/"
:
"closeblockcomment"
,
"macro_rules"
:
"macro_rules"
,
"=>"
:
"eg"
,
".."
:
"dotdot"
,
","
:
"comma"
}
lines
=
[]
...
...
@@ -126,8 +126,8 @@ for line in collections["gram"]:
+
word
)
if
word
not
in
tokens
:
if
(
word
in
collections
[
"keyword"
]
or
word
in
collections
[
"reserved"
]):
tokens
.
append
(
word
)
word
in
collections
[
"reserved"
]):
tokens
.
append
(
word
)
else
:
raise
Exception
(
"unknown keyword/reserved word: "
+
word
)
...
...
@@ -149,8 +149,8 @@ for sym in collections["unop"] + collections["binop"] + symnames.keys():
print
(
"%start parser, token;"
)
print
(
"%%token %s ;"
%
(
"
\n\t
, "
.
join
(
tokens
)))
for
coll
in
[
"keyword"
,
"reserved"
]:
print
(
"%s: %s ; "
%
(
coll
,
"
\n\t
| "
.
join
(
collections
[
coll
])))
;
print
(
"%s: %s ; "
%
(
coll
,
"
\n\t
| "
.
join
(
collections
[
coll
])))
for
coll
in
[
"binop"
,
"unop"
]:
print
(
"%s: %s ; "
%
(
coll
,
"
\n\t
| "
.
join
([
symnames
[
x
]
for
x
in
collections
[
coll
]])))
;
print
(
"
\n
"
.
join
(
lines
))
;
for
x
in
collections
[
coll
]])))
print
(
"
\n
"
.
join
(
lines
))
src/etc/gdb_rust_pretty_printing.py
浏览文件 @
ee0be3b3
...
...
@@ -14,181 +14,189 @@ import gdb
# GDB Pretty Printing Module for Rust
#===============================================================================
def
register_printers
(
objfile
):
"Registers Rust pretty printers for the given objfile"
objfile
.
pretty_printers
.
append
(
rust_pretty_printer_lookup_function
)
"Registers Rust pretty printers for the given objfile"
objfile
.
pretty_printers
.
append
(
rust_pretty_printer_lookup_function
)
def
rust_pretty_printer_lookup_function
(
val
):
"Returns the correct Rust pretty printer for the given value if there is one"
type_code
=
val
.
type
.
code
if
type_code
==
gdb
.
TYPE_CODE_STRUCT
:
struct_kind
=
classify_struct
(
val
.
type
)
if
struct_kind
==
STRUCT_KIND_STR_SLICE
:
return
RustStringSlicePrinter
(
val
)
if
struct_kind
==
STRUCT_KIND_TUPLE
:
return
RustTuplePrinter
(
val
)
if
struct_kind
==
STRUCT_KIND_TUPLE_STRUCT
:
return
RustTupleStructPrinter
(
val
,
False
)
if
struct_kind
==
STRUCT_KIND_CSTYLE_VARIANT
:
return
RustCStyleEnumPrinter
(
val
[
get_field_at_index
(
val
,
0
)])
if
struct_kind
==
STRUCT_KIND_TUPLE_VARIANT
:
return
RustTupleStructPrinter
(
val
,
True
)
if
struct_kind
==
STRUCT_KIND_STRUCT_VARIANT
:
return
RustStructPrinter
(
val
,
True
)
return
RustStructPrinter
(
val
,
False
)
# Enum handling
if
type_code
==
gdb
.
TYPE_CODE_UNION
:
enum_members
=
list
(
val
.
type
.
fields
())
enum_member_count
=
len
(
enum_members
)
if
enum_member_count
==
0
:
return
RustStructPrinter
(
val
,
False
)
if
enum_member_count
==
1
:
first_variant_name
=
enum_members
[
0
].
name
if
first_variant_name
==
None
:
# This is a singleton enum
return
rust_pretty_printer_lookup_function
(
val
[
enum_members
[
0
]])
else
:
assert
first_variant_name
.
startswith
(
"RUST$ENCODED$ENUM$"
)
# This is a space-optimized enum.
# This means this enum has only two states, and Rust uses one of th
e
# fields somewhere in the struct to determine which of the two states
# it's in. The location of the field is encoded in the name as something
# like RUST$ENCODED$ENUM$(num$)*name_of_zero_stat
e
last_separator_index
=
first_variant_name
.
rfind
(
"$"
)
start_index
=
len
(
"RUST$ENCODED$ENUM
$"
)
disr_field_indices
=
first_variant_name
[
start_index
:
last_separator_index
].
split
(
"$"
)
disr_field_indices
=
[
int
(
index
)
for
index
in
disr_field_indices
]
sole_variant_val
=
val
[
enum_members
[
0
]]
discriminant
=
sole_variant_val
for
disr_field_index
in
disr_field_indices
:
disr_field
=
get_field_at_index
(
discriminant
,
disr_field_index
)
discriminant
=
discriminant
[
disr_field
]
# If the discriminant field is a fat pointer we have to consider the
# first word as the true discriminant
if
discriminant
.
type
.
code
==
gdb
.
TYPE_CODE_STRUCT
:
discriminant
=
discriminant
[
get_field_at_index
(
discriminant
,
0
)]
if
discriminant
==
0
:
null_variant_name
=
first_variant_name
[
last_separator_index
+
1
:]
return
IdentityPrinter
(
null_variant_name
)
return
rust_pretty_printer_lookup_function
(
sole_variant_val
)
# This is a regular enum, extract the discriminant
discriminant_name
,
discriminant_val
=
extract_discriminant_value
(
val
)
return
rust_pretty_printer_lookup_function
(
val
[
enum_members
[
discriminant_val
]])
# No pretty printer has been found
return
None
"Returns the correct Rust pretty printer for the given value if there is one"
type_code
=
val
.
type
.
code
if
type_code
==
gdb
.
TYPE_CODE_STRUCT
:
struct_kind
=
classify_struct
(
val
.
type
)
if
struct_kind
==
STRUCT_KIND_STR_SLICE
:
return
RustStringSlicePrinter
(
val
)
if
struct_kind
==
STRUCT_KIND_TUPLE
:
return
RustTuplePrinter
(
val
)
if
struct_kind
==
STRUCT_KIND_TUPLE_STRUCT
:
return
RustTupleStructPrinter
(
val
,
False
)
if
struct_kind
==
STRUCT_KIND_CSTYLE_VARIANT
:
return
RustCStyleEnumPrinter
(
val
[
get_field_at_index
(
val
,
0
)])
if
struct_kind
==
STRUCT_KIND_TUPLE_VARIANT
:
return
RustTupleStructPrinter
(
val
,
True
)
if
struct_kind
==
STRUCT_KIND_STRUCT_VARIANT
:
return
RustStructPrinter
(
val
,
True
)
return
RustStructPrinter
(
val
,
False
)
# Enum handling
if
type_code
==
gdb
.
TYPE_CODE_UNION
:
enum_members
=
list
(
val
.
type
.
fields
())
enum_member_count
=
len
(
enum_members
)
if
enum_member_count
==
0
:
return
RustStructPrinter
(
val
,
False
)
if
enum_member_count
==
1
:
first_variant_name
=
enum_members
[
0
].
name
if
first_variant_name
is
None
:
# This is a singleton enum
return
rust_pretty_printer_lookup_function
(
val
[
enum_members
[
0
]])
else
:
assert
first_variant_name
.
startswith
(
"RUST$ENCODED$ENUM$"
)
# This is a space-optimized enum.
# This means this enum has only two states, and Rust uses on
e
# of the fields somewhere in the struct to determine which of
# the two states it's in. The location of the field is encoded
# in the name as something lik
e
# RUST$ENCODED$ENUM$(num$)*name_of_zero_state
last_separator_index
=
first_variant_name
.
rfind
(
"
$"
)
start_index
=
len
(
"RUST$ENCODED$ENUM$"
)
disr_field_indices
=
first_variant_name
[
start_index
:
last_separator_index
].
split
(
"$"
)
disr_field_indices
=
[
int
(
index
)
for
index
in
disr_field_indices
]
sole_variant_val
=
val
[
enum_members
[
0
]]
discriminant
=
sole_variant_val
for
disr_field_index
in
disr_field_indices
:
disr_field
=
get_field_at_index
(
discriminant
,
disr_field_index
)
discriminant
=
discriminant
[
disr_field
]
# If the discriminant field is a fat pointer we have to consider the
# first word as the true discriminant
if
discriminant
.
type
.
code
==
gdb
.
TYPE_CODE_STRUCT
:
discriminant
=
discriminant
[
get_field_at_index
(
discriminant
,
0
)]
if
discriminant
==
0
:
null_variant_name
=
first_variant_name
[
last_separator_index
+
1
:]
return
IdentityPrinter
(
null_variant_name
)
return
rust_pretty_printer_lookup_function
(
sole_variant_val
)
# This is a regular enum, extract the discriminant
discriminant_name
,
discriminant_val
=
extract_discriminant_value
(
val
)
return
rust_pretty_printer_lookup_function
(
val
[
enum_members
[
discriminant_val
]])
# No pretty printer has been found
return
None
#=------------------------------------------------------------------------------
# Pretty Printer Classes
#=------------------------------------------------------------------------------
class
RustStructPrinter
:
def
__init__
(
self
,
val
,
hide_first_field
):
self
.
val
=
val
self
.
hide_first_field
=
hide_first_field
def
to_string
(
self
):
return
self
.
val
.
type
.
tag
def
children
(
self
):
cs
=
[]
for
field
in
self
.
val
.
type
.
fields
():
field_name
=
field
.
name
# Normally the field name is used as a key to access the field value,
# because that's also supported in older versions of GDB...
field_key
=
field_name
if
field_name
==
None
:
field_name
=
""
# ... but for fields without a name (as in tuples), we have to fall back
# to the newer method of using the field object directly as key. In
# older versions of GDB, this will just fail.
field_key
=
field
name_value_tuple
=
(
field_name
,
self
.
val
[
field_key
]
)
cs
.
append
(
name_value_tuple
)
if
self
.
hide_first_field
:
cs
=
cs
[
1
:]
return
cs
def
__init__
(
self
,
val
,
hide_first_field
):
self
.
val
=
val
self
.
hide_first_field
=
hide_first_field
def
to_string
(
self
):
return
self
.
val
.
type
.
tag
def
children
(
self
):
cs
=
[]
for
field
in
self
.
val
.
type
.
fields
():
field_name
=
field
.
name
# Normally the field name is used as a key to access the field
# value, because that's also supported in older versions of GDB...
field_key
=
field_name
if
field_name
is
None
:
field_name
=
""
# ... but for fields without a name (as in tuples), we have to
# fall back to the newer method of using the field object
# directly as key. In older versions of GDB, this will just
# fail.
field_key
=
field
name_value_tuple
=
(
field_name
,
self
.
val
[
field_key
])
cs
.
append
(
name_value_tuple
)
if
self
.
hide_first_field
:
cs
=
cs
[
1
:]
return
cs
class
RustTuplePrinter
:
def
__init__
(
self
,
val
):
self
.
val
=
val
def
__init__
(
self
,
val
):
self
.
val
=
val
def
to_string
(
self
):
return
None
def
to_string
(
self
):
return
None
def
children
(
self
):
cs
=
[]
for
field
in
self
.
val
.
type
.
fields
():
cs
.
append
((
""
,
self
.
val
[
field
]))
def
children
(
self
):
cs
=
[]
for
field
in
self
.
val
.
type
.
fields
():
cs
.
append
(
(
""
,
self
.
val
[
field
])
)
return
cs
return
cs
def
display_hint
(
self
):
return
"array"
def
display_hint
(
self
):
return
"array"
class
RustTupleStructPrinter
:
def
__init__
(
self
,
val
,
hide_first_field
):
self
.
val
=
val
self
.
hide_first_field
=
hide_first_field
def
__init__
(
self
,
val
,
hide_first_field
):
self
.
val
=
val
self
.
hide_first_field
=
hide_first_field
def
to_string
(
self
):
return
self
.
val
.
type
.
tag
def
to_string
(
self
):
return
self
.
val
.
type
.
tag
def
children
(
self
):
cs
=
[]
for
field
in
self
.
val
.
type
.
fields
():
cs
.
append
(
(
""
,
self
.
val
[
field
])
)
def
children
(
self
):
cs
=
[]
for
field
in
self
.
val
.
type
.
fields
():
cs
.
append
((
""
,
self
.
val
[
field
])
)
if
self
.
hide_first_field
:
cs
=
cs
[
1
:]
if
self
.
hide_first_field
:
cs
=
cs
[
1
:]
return
cs
return
cs
def
display_hint
(
self
):
return
"array"
def
display_hint
(
self
):
return
"array"
class
RustStringSlicePrinter
:
def
__init__
(
self
,
val
):
self
.
val
=
val
def
__init__
(
self
,
val
):
self
.
val
=
val
def
to_string
(
self
):
slice_byte_len
=
self
.
val
[
"length"
]
return
'"%s"'
%
self
.
val
[
"data_ptr"
].
string
(
encoding
=
"utf-8"
,
length
=
slice_byte_len
)
def
to_string
(
self
):
slice_byte_len
=
self
.
val
[
"length"
]
return
'"%s"'
%
self
.
val
[
"data_ptr"
].
string
(
encoding
=
"utf-8"
,
length
=
slice_byte_len
)
class
RustCStyleEnumPrinter
:
def
__init__
(
self
,
val
):
assert
val
.
type
.
code
==
gdb
.
TYPE_CODE_ENUM
self
.
val
=
val
def
__init__
(
self
,
val
):
assert
val
.
type
.
code
==
gdb
.
TYPE_CODE_ENUM
self
.
val
=
val
def
to_string
(
self
):
return
str
(
self
.
val
)
def
to_string
(
self
):
return
str
(
self
.
val
)
class
IdentityPrinter
:
def
__init__
(
self
,
string
):
self
.
string
=
string
def
__init__
(
self
,
string
):
self
.
string
=
string
def
to_string
(
self
):
return
self
.
string
def
to_string
(
self
):
return
self
.
string
STRUCT_KIND_REGULAR_STRUCT
=
0
STRUCT_KIND_TUPLE_STRUCT
=
1
...
...
@@ -198,47 +206,51 @@ STRUCT_KIND_STRUCT_VARIANT = 4
STRUCT_KIND_CSTYLE_VARIANT
=
5
STRUCT_KIND_STR_SLICE
=
6
def
classify_struct
(
type
):
if
type
.
tag
==
"&str"
:
return
STRUCT_KIND_STR_SLICE
if
type
.
tag
==
"&str"
:
return
STRUCT_KIND_STR_SLICE
fields
=
list
(
type
.
fields
())
field_count
=
len
(
fields
)
fields
=
list
(
type
.
fields
())
field_count
=
len
(
fields
)
if
field_count
==
0
:
return
STRUCT_KIND_REGULAR_STRUCT
if
field_count
==
0
:
return
STRUCT_KIND_REGULAR_STRUCT
if
fields
[
0
].
name
==
"RUST$ENUM$DISR"
:
if
field_count
==
1
:
return
STRUCT_KIND_CSTYLE_VARIANT
elif
fields
[
1
].
name
is
None
:
return
STRUCT_KIND_TUPLE_VARIANT
else
:
return
STRUCT_KIND_STRUCT_VARIANT
if
fields
[
0
].
name
==
"RUST$ENUM$DISR"
:
if
field_count
==
1
:
return
STRUCT_KIND_CSTYLE_VARIANT
elif
fields
[
1
].
name
==
None
:
return
STRUCT_KIND_TUPLE_VARIANT
else
:
return
STRUCT_KIND_STRUCT_VARIANT
if
fields
[
0
].
name
is
None
:
if
type
.
tag
.
startswith
(
"("
):
return
STRUCT_KIND_TUPLE
else
:
return
STRUCT_KIND_TUPLE_STRUCT
if
fields
[
0
].
name
==
None
:
if
type
.
tag
.
startswith
(
"("
):
return
STRUCT_KIND_TUPLE
else
:
return
STRUCT_KIND_TUPLE_STRUCT
return
STRUCT_KIND_REGULAR_STRUCT
return
STRUCT_KIND_REGULAR_STRUCT
def
extract_discriminant_value
(
enum_val
):
assert
enum_val
.
type
.
code
==
gdb
.
TYPE_CODE_UNION
for
variant_descriptor
in
enum_val
.
type
.
fields
():
variant_val
=
enum_val
[
variant_descriptor
]
for
field
in
variant_val
.
type
.
fields
():
return
(
field
.
name
,
int
(
variant_val
[
field
]))
assert
enum_val
.
type
.
code
==
gdb
.
TYPE_CODE_UNION
for
variant_descriptor
in
enum_val
.
type
.
fields
():
variant_val
=
enum_val
[
variant_descriptor
]
for
field
in
variant_val
.
type
.
fields
():
return
(
field
.
name
,
int
(
variant_val
[
field
]))
def
first_field
(
val
):
for
field
in
val
.
type
.
fields
():
return
field
for
field
in
val
.
type
.
fields
():
return
field
def
get_field_at_index
(
val
,
index
):
i
=
0
for
field
in
val
.
type
.
fields
():
if
i
==
index
:
return
field
i
+=
1
return
None
i
=
0
for
field
in
val
.
type
.
fields
():
if
i
==
index
:
return
field
i
+=
1
return
None
src/etc/generate-keyword-tests.py
浏览文件 @
ee0be3b3
...
...
@@ -56,4 +56,4 @@ for kw in sys.argv[1:]:
f
.
write
(
template
%
(
datetime
.
datetime
.
now
().
year
,
kw
,
kw
))
# mark file read-only
os
.
chmod
(
test_file
,
stat
.
S_IRUSR
|
stat
.
S_IRGRP
|
stat
.
S_IROTH
)
os
.
chmod
(
test_file
,
stat
.
S_IRUSR
|
stat
.
S_IRGRP
|
stat
.
S_IROTH
)
src/etc/get-snapshot.py
浏览文件 @
ee0be3b3
...
...
@@ -10,36 +10,40 @@
# option. This file may not be copied, modified, or distributed
# except according to those terms.
import
os
,
tarfile
,
re
,
shutil
,
sys
import
os
import
tarfile
import
shutil
import
sys
from
snapshot
import
*
def
unpack_snapshot
(
triple
,
dl_path
):
print
(
"opening snapshot "
+
dl_path
)
tar
=
tarfile
.
open
(
dl_path
)
kernel
=
get_kernel
(
triple
)
stagep
=
os
.
path
.
join
(
triple
,
"stage0"
)
# Remove files from prior unpackings, since snapshot rustc may not
# be able to disambiguate between multiple candidate libraries.
# (Leave dirs in place since extracting step still needs them.)
for
root
,
_
,
files
in
os
.
walk
(
stagep
):
for
f
in
files
:
print
(
"removing "
+
os
.
path
.
join
(
root
,
f
))
os
.
unlink
(
os
.
path
.
join
(
root
,
f
))
for
p
in
tar
.
getnames
():
name
=
p
.
replace
(
"rust-stage0/"
,
""
,
1
);
fp
=
os
.
path
.
join
(
stagep
,
name
)
print
(
"extracting "
+
p
)
tar
.
extract
(
p
,
download_unpack_base
)
tp
=
os
.
path
.
join
(
download_unpack_base
,
p
)
if
os
.
path
.
isdir
(
tp
)
and
os
.
path
.
exists
(
fp
):
continue
shutil
.
move
(
tp
,
fp
)
tar
.
close
()
shutil
.
rmtree
(
download_unpack_base
)
print
(
"opening snapshot "
+
dl_path
)
tar
=
tarfile
.
open
(
dl_path
)
kernel
=
get_kernel
(
triple
)
stagep
=
os
.
path
.
join
(
triple
,
"stage0"
)
# Remove files from prior unpackings, since snapshot rustc may not
# be able to disambiguate between multiple candidate libraries.
# (Leave dirs in place since extracting step still needs them.)
for
root
,
_
,
files
in
os
.
walk
(
stagep
):
for
f
in
files
:
print
(
"removing "
+
os
.
path
.
join
(
root
,
f
))
os
.
unlink
(
os
.
path
.
join
(
root
,
f
))
for
p
in
tar
.
getnames
():
name
=
p
.
replace
(
"rust-stage0/"
,
""
,
1
)
fp
=
os
.
path
.
join
(
stagep
,
name
)
print
(
"extracting "
+
p
)
tar
.
extract
(
p
,
download_unpack_base
)
tp
=
os
.
path
.
join
(
download_unpack_base
,
p
)
if
os
.
path
.
isdir
(
tp
)
and
os
.
path
.
exists
(
fp
):
continue
shutil
.
move
(
tp
,
fp
)
tar
.
close
()
shutil
.
rmtree
(
download_unpack_base
)
# Main
...
...
@@ -48,23 +52,27 @@ def unpack_snapshot(triple, dl_path):
# The first is the O/S triple.
# The second is an optional path to the snapshot to use.
triple
=
sys
.
argv
[
1
]
if
len
(
sys
.
argv
)
==
3
:
dl_path
=
sys
.
argv
[
2
]
else
:
snap
=
determine_curr_snapshot
(
triple
)
dl
=
os
.
path
.
join
(
download_dir_base
,
snap
)
url
=
download_url_base
+
"/"
+
snap
print
(
"determined most recent snapshot: "
+
snap
)
def
main
(
argv
):
triple
=
argv
[
1
]
if
len
(
argv
)
==
3
:
dl_path
=
argv
[
2
]
else
:
snap
=
determine_curr_snapshot
(
triple
)
dl
=
os
.
path
.
join
(
download_dir_base
,
snap
)
url
=
download_url_base
+
"/"
+
snap
print
(
"determined most recent snapshot: "
+
snap
)
if
(
not
os
.
path
.
exists
(
dl
)):
get_url_to_file
(
url
,
dl
)
if
(
not
os
.
path
.
exists
(
dl
)):
get_url_to_file
(
url
,
dl
)
if
(
snap_filename_hash_part
(
snap
)
==
hash_file
(
dl
)):
print
(
"got download with ok hash"
)
else
:
raise
Exception
(
"bad hash on download"
)
if
(
snap_filename_hash_part
(
snap
)
==
hash_file
(
dl
)):
print
(
"got download with ok hash"
)
else
:
raise
Exception
(
"bad hash on download"
)
dl_path
=
os
.
path
.
join
(
download_dir_base
,
snap
)
dl_path
=
os
.
path
.
join
(
download_dir_base
,
snap
)
unpack_snapshot
(
triple
,
dl_path
)
unpack_snapshot
(
triple
,
dl_path
)
if
__name__
==
'__main__'
:
main
(
sys
.
argv
)
src/etc/htmldocck.py
浏览文件 @
ee0be3b3
...
...
@@ -118,40 +118,54 @@ entitydefs['rarrb'] = u'\u21e5'
VOID_ELEMENTS
=
set
([
'area'
,
'base'
,
'br'
,
'col'
,
'embed'
,
'hr'
,
'img'
,
'input'
,
'keygen'
,
'link'
,
'menuitem'
,
'meta'
,
'param'
,
'source'
,
'track'
,
'wbr'
])
# simplified HTML parser.
# this is possible because we are dealing with very regular HTML from rustdoc;
# we only have to deal with i) void elements and ii) empty attributes.
class
CustomHTMLParser
(
HTMLParser
):
"""simplified HTML parser.
this is possible because we are dealing with very regular HTML from
rustdoc; we only have to deal with i) void elements and ii) empty
attributes."""
def
__init__
(
self
,
target
=
None
):
HTMLParser
.
__init__
(
self
)
self
.
__builder
=
target
or
ET
.
TreeBuilder
()
def
handle_starttag
(
self
,
tag
,
attrs
):
attrs
=
dict
((
k
,
v
or
''
)
for
k
,
v
in
attrs
)
self
.
__builder
.
start
(
tag
,
attrs
)
if
tag
in
VOID_ELEMENTS
:
self
.
__builder
.
end
(
tag
)
if
tag
in
VOID_ELEMENTS
:
self
.
__builder
.
end
(
tag
)
def
handle_endtag
(
self
,
tag
):
self
.
__builder
.
end
(
tag
)
def
handle_startendtag
(
self
,
tag
,
attrs
):
attrs
=
dict
((
k
,
v
or
''
)
for
k
,
v
in
attrs
)
self
.
__builder
.
start
(
tag
,
attrs
)
self
.
__builder
.
end
(
tag
)
def
handle_data
(
self
,
data
):
self
.
__builder
.
data
(
data
)
def
handle_entityref
(
self
,
name
):
self
.
__builder
.
data
(
entitydefs
[
name
])
def
handle_charref
(
self
,
name
):
code
=
int
(
name
[
1
:],
16
)
if
name
.
startswith
((
'x'
,
'X'
))
else
int
(
name
,
10
)
self
.
__builder
.
data
(
unichr
(
code
).
encode
(
'utf-8'
))
def
close
(
self
):
HTMLParser
.
close
(
self
)
return
self
.
__builder
.
close
()
Command
=
namedtuple
(
'Command'
,
'negated cmd args lineno'
)
# returns a generator out of the file object, which
# - removes `\\` then `\n` then a shared prefix with the previous line then optional whitespace;
# - keeps a line number (starting from 0) of the first line being concatenated.
def
concat_multi_lines
(
f
):
"""returns a generator out of the file object, which
- removes `
\\
` then `
\n
` then a shared prefix with the previous line then
optional whitespace;
- keeps a line number (starting from 0) of the first line being
concatenated."""
lastline
=
None
# set to the last line when the last line has a backslash
firstlineno
=
None
catenated
=
''
...
...
@@ -162,7 +176,8 @@ def concat_multi_lines(f):
if
lastline
is
not
None
:
maxprefix
=
0
for
i
in
xrange
(
min
(
len
(
line
),
len
(
lastline
))):
if
line
[
i
]
!=
lastline
[
i
]:
break
if
line
[
i
]
!=
lastline
[
i
]:
break
maxprefix
+=
1
line
=
line
[
maxprefix
:].
lstrip
()
...
...
@@ -184,11 +199,14 @@ LINE_PATTERN = re.compile(r'''
(?P<cmd>[A-Za-z]+(?:-[A-Za-z]+)*)
(?P<args>.*)$
'''
,
re
.
X
)
def
get_commands
(
template
):
with
open
(
template
,
'rUb'
)
as
f
:
for
lineno
,
line
in
concat_multi_lines
(
f
):
m
=
LINE_PATTERN
.
search
(
line
)
if
not
m
:
continue
if
not
m
:
continue
negated
=
(
m
.
group
(
'negated'
)
==
'!'
)
cmd
=
m
.
group
(
'cmd'
)
...
...
@@ -198,17 +216,22 @@ def get_commands(template):
args
=
shlex
.
split
(
args
)
yield
Command
(
negated
=
negated
,
cmd
=
cmd
,
args
=
args
,
lineno
=
lineno
+
1
)
def
_flatten
(
node
,
acc
):
if
node
.
text
:
acc
.
append
(
node
.
text
)
if
node
.
text
:
acc
.
append
(
node
.
text
)
for
e
in
node
:
_flatten
(
e
,
acc
)
if
e
.
tail
:
acc
.
append
(
e
.
tail
)
if
e
.
tail
:
acc
.
append
(
e
.
tail
)
def
flatten
(
node
):
acc
=
[]
_flatten
(
node
,
acc
)
return
''
.
join
(
acc
)
def
normalize_xpath
(
path
):
if
path
.
startswith
(
'//'
):
return
'.'
+
path
# avoid warnings
...
...
@@ -218,6 +241,7 @@ def normalize_xpath(path):
raise
RuntimeError
(
'Non-absolute XPath is not supported due to
\
the implementation issue.'
)
class
CachedFiles
(
object
):
def
__init__
(
self
,
root
):
self
.
root
=
root
...
...
@@ -267,6 +291,7 @@ class CachedFiles(object):
self
.
trees
[
path
]
=
tree
return
self
.
trees
[
path
]
def
check_string
(
data
,
pat
,
regexp
):
if
not
pat
:
return
True
# special case a presence testing
...
...
@@ -277,6 +302,7 @@ def check_string(data, pat, regexp):
pat
=
' '
.
join
(
pat
.
split
())
return
pat
in
data
def
check_tree_attr
(
tree
,
path
,
attr
,
pat
,
regexp
):
path
=
normalize_xpath
(
path
)
ret
=
False
...
...
@@ -287,9 +313,11 @@ def check_tree_attr(tree, path, attr, pat, regexp):
continue
else
:
ret
=
check_string
(
value
,
pat
,
regexp
)
if
ret
:
break
if
ret
:
break
return
ret
def
check_tree_text
(
tree
,
path
,
pat
,
regexp
):
path
=
normalize_xpath
(
path
)
ret
=
False
...
...
@@ -300,9 +328,11 @@ def check_tree_text(tree, path, pat, regexp):
continue
else
:
ret
=
check_string
(
value
,
pat
,
regexp
)
if
ret
:
break
if
ret
:
break
return
ret
def
check
(
target
,
commands
):
cache
=
CachedFiles
(
target
)
for
c
in
commands
:
...
...
@@ -323,7 +353,8 @@ def check(target, commands):
ret
=
check_tree_attr
(
cache
.
get_tree
(
c
.
args
[
0
]),
pat
,
attr
,
c
.
args
[
2
],
regexp
)
else
:
# normalized text
pat
=
c
.
args
[
1
]
if
pat
.
endswith
(
'/text()'
):
pat
=
pat
[:
-
7
]
if
pat
.
endswith
(
'/text()'
):
pat
=
pat
[:
-
7
]
ret
=
check_tree_text
(
cache
.
get_tree
(
c
.
args
[
0
]),
pat
,
c
.
args
[
2
],
regexp
)
else
:
raise
RuntimeError
(
'Invalid number of @{} arguments
\
...
...
@@ -348,4 +379,3 @@ if __name__ == '__main__':
raise
SystemExit
(
1
)
else
:
check
(
sys
.
argv
[
1
],
get_commands
(
sys
.
argv
[
2
]))
src/etc/latest-unix-snaps.py
浏览文件 @
ee0be3b3
...
...
@@ -10,7 +10,8 @@
# option. This file may not be copied, modified, or distributed
# except according to those terms.
import
os
,
tarfile
,
hashlib
,
re
,
shutil
,
sys
import
os
import
re
from
snapshot
import
*
f
=
open
(
snapshotfile
)
...
...
@@ -26,7 +27,8 @@ newestSet = {}
for
line
in
f
.
readlines
():
i
+=
1
parsed
=
parse_line
(
i
,
line
)
if
(
not
parsed
):
continue
if
not
parsed
:
continue
if
parsed
[
"type"
]
==
"snapshot"
:
if
(
len
(
newestSet
)
==
0
or
parsed
[
"date"
]
>
newestSet
[
"date"
]):
...
...
@@ -37,16 +39,16 @@ for line in f.readlines():
else
:
addingMode
=
False
elif
addingMode
==
True
and
parsed
[
"type"
]
==
"file"
:
elif
addingMode
is
True
and
parsed
[
"type"
]
==
"file"
:
tux
=
re
.
compile
(
"linux"
,
re
.
IGNORECASE
)
if
(
tux
.
match
(
parsed
[
"platform"
])
!=
None
):
ff
=
{}
ff
[
"platform"
]
=
parsed
[
"platform"
]
ff
[
"hash"
]
=
parsed
[
"hash"
]
newestSet
[
"files"
]
+=
[
ff
]
if
(
tux
.
match
(
parsed
[
"platform"
])
is
not
None
):
ff
=
{}
ff
[
"platform"
]
=
parsed
[
"platform"
]
ff
[
"hash"
]
=
parsed
[
"hash"
]
newestSet
[
"files"
]
+=
[
ff
]
def
download_new_file
(
date
,
rev
,
platform
,
hsh
):
def
download_new_file
(
date
,
rev
,
platform
,
hsh
):
snap
=
full_snapshot_name
(
date
,
rev
,
platform
,
hsh
)
dl
=
os
.
path
.
join
(
download_dir_base
,
snap
)
url
=
download_url_base
+
"/"
+
snap
...
...
@@ -59,5 +61,5 @@ def download_new_file (date, rev, platform, hsh):
raise
Exception
(
"bad hash on download"
)
for
ff
in
newestSet
[
"files"
]:
download_new_file
(
newestSet
[
"date"
],
newestSet
[
"rev"
],
download_new_file
(
newestSet
[
"date"
],
newestSet
[
"rev"
],
ff
[
"platform"
],
ff
[
"hash"
])
src/etc/lldb_batchmode.py
浏览文件 @
ee0be3b3
...
...
@@ -30,36 +30,35 @@ import sys
import
threading
import
thread
import
re
import
atexit
import
time
# Set this to True for additional output
DEBUG_OUTPUT
=
False
def
print_debug
(
s
):
"Print something if DEBUG_OUTPUT is True"
global
DEBUG_OUTPUT
if
DEBUG_OUTPUT
:
print
(
"DEBUG: "
+
str
(
s
))
"Print something if DEBUG_OUTPUT is True"
global
DEBUG_OUTPUT
if
DEBUG_OUTPUT
:
print
(
"DEBUG: "
+
str
(
s
))
def
normalize_whitespace
(
s
):
"Replace newlines, tabs, multiple spaces, etc with exactly one space"
return
re
.
sub
(
"\s+"
,
" "
,
s
)
"Replace newlines, tabs, multiple spaces, etc with exactly one space"
return
re
.
sub
(
"\s+"
,
" "
,
s
)
# This callback is registered with every breakpoint and makes sure that the frame containing the
# breakpoint location is selected
def
breakpoint_callback
(
frame
,
bp_loc
,
dict
):
"Called whenever a breakpoint is hit"
print
(
"Hit breakpoint "
+
str
(
bp_loc
))
"""This callback is registered with every breakpoint and makes sure that the
frame containing the breakpoint location is selected"""
print
(
"Hit breakpoint "
+
str
(
bp_loc
))
# Select the frame and the thread containing it
frame
.
thread
.
process
.
SetSelectedThread
(
frame
.
thread
)
frame
.
thread
.
SetSelectedFrame
(
frame
.
idx
)
# Select the frame and the thread containing it
frame
.
thread
.
process
.
SetSelectedThread
(
frame
.
thread
)
frame
.
thread
.
SetSelectedFrame
(
frame
.
idx
)
# Returning True means that we actually want to stop at this breakpoint
return
True
# Returning True means that we actually want to stop at this breakpoint
return
True
# This is a list of breakpoints that are not registered with the breakpoint callback. The list is
...
...
@@ -70,91 +69,99 @@ new_breakpoints = []
# used to avoid hooking callbacks into breakpoints more than once
registered_breakpoints
=
set
()
def
execute_command
(
command_interpreter
,
command
):
"Executes a single CLI command"
global
new_breakpoints
global
registered_breakpoints
res
=
lldb
.
SBCommandReturnObject
()
print
(
command
)
command_interpreter
.
HandleCommand
(
command
,
res
)
if
res
.
Succeeded
():
if
res
.
HasResult
():
print
(
normalize_whitespace
(
res
.
GetOutput
()),
end
=
'
\n
'
)
# If the command introduced any breakpoints, make sure to register them with the breakpoint
# callback
while
len
(
new_breakpoints
)
>
0
:
res
.
Clear
()
breakpoint_id
=
new_breakpoints
.
pop
()
if
breakpoint_id
in
registered_breakpoints
:
print_debug
(
"breakpoint with id %s is already registered. Ignoring."
%
str
(
breakpoint_id
))
else
:
print_debug
(
"registering breakpoint callback, id = "
+
str
(
breakpoint_id
))
callback_command
=
"breakpoint command add -F breakpoint_callback "
+
str
(
breakpoint_id
)
command_interpreter
.
HandleCommand
(
callback_command
,
res
)
if
res
.
Succeeded
():
print_debug
(
"successfully registered breakpoint callback, id = "
+
str
(
breakpoint_id
))
registered_breakpoints
.
add
(
breakpoint_id
)
else
:
print
(
"Error while trying to register breakpoint callback, id = "
+
str
(
breakpoint_id
))
else
:
print
(
res
.
GetError
())
"Executes a single CLI command"
global
new_breakpoints
global
registered_breakpoints
res
=
lldb
.
SBCommandReturnObject
()
print
(
command
)
command_interpreter
.
HandleCommand
(
command
,
res
)
if
res
.
Succeeded
():
if
res
.
HasResult
():
print
(
normalize_whitespace
(
res
.
GetOutput
()),
end
=
'
\n
'
)
# If the command introduced any breakpoints, make sure to register
# them with the breakpoint
# callback
while
len
(
new_breakpoints
)
>
0
:
res
.
Clear
()
breakpoint_id
=
new_breakpoints
.
pop
()
if
breakpoint_id
in
registered_breakpoints
:
print_debug
(
"breakpoint with id %s is already registered. Ignoring."
%
str
(
breakpoint_id
))
else
:
print_debug
(
"registering breakpoint callback, id = "
+
str
(
breakpoint_id
))
callback_command
=
(
"breakpoint command add -F breakpoint_callback "
+
str
(
breakpoint_id
))
command_interpreter
.
HandleCommand
(
callback_command
,
res
)
if
res
.
Succeeded
():
print_debug
(
"successfully registered breakpoint callback, id = "
+
str
(
breakpoint_id
))
registered_breakpoints
.
add
(
breakpoint_id
)
else
:
print
(
"Error while trying to register breakpoint callback, id = "
+
str
(
breakpoint_id
))
else
:
print
(
res
.
GetError
())
def
start_breakpoint_listener
(
target
):
"Listens for breakpoints being added and adds new ones to the callback registration list"
listener
=
lldb
.
SBListener
(
"breakpoint listener"
)
def
listen
():
event
=
lldb
.
SBEvent
()
try
:
while
True
:
if
listener
.
WaitForEvent
(
120
,
event
):
if
lldb
.
SBBreakpoint
.
EventIsBreakpointEvent
(
event
)
and
\
lldb
.
SBBreakpoint
.
GetBreakpointEventTypeFromEvent
(
event
)
==
\
lldb
.
eBreakpointEventTypeAdded
:
global
new_breakpoints
breakpoint
=
lldb
.
SBBreakpoint
.
GetBreakpointFromEvent
(
event
)
print_debug
(
"breakpoint added, id = "
+
str
(
breakpoint
.
id
))
new_breakpoints
.
append
(
breakpoint
.
id
)
except
:
print_debug
(
"breakpoint listener shutting down"
)
# Start the listener and let it run as a daemon
listener_thread
=
threading
.
Thread
(
target
=
listen
)
listener_thread
.
daemon
=
True
listener_thread
.
start
()
# Register the listener with the target
target
.
GetBroadcaster
().
AddListener
(
listener
,
lldb
.
SBTarget
.
eBroadcastBitBreakpointChanged
)
"""Listens for breakpoints being added and adds new ones to the callback
registration list"""
listener
=
lldb
.
SBListener
(
"breakpoint listener"
)
def
listen
():
event
=
lldb
.
SBEvent
()
try
:
while
True
:
if
listener
.
WaitForEvent
(
120
,
event
):
if
lldb
.
SBBreakpoint
.
EventIsBreakpointEvent
(
event
)
and
\
lldb
.
SBBreakpoint
.
GetBreakpointEventTypeFromEvent
(
event
)
==
\
lldb
.
eBreakpointEventTypeAdded
:
global
new_breakpoints
breakpoint
=
lldb
.
SBBreakpoint
.
GetBreakpointFromEvent
(
event
)
print_debug
(
"breakpoint added, id = "
+
str
(
breakpoint
.
id
))
new_breakpoints
.
append
(
breakpoint
.
id
)
except
:
print_debug
(
"breakpoint listener shutting down"
)
# Start the listener and let it run as a daemon
listener_thread
=
threading
.
Thread
(
target
=
listen
)
listener_thread
.
daemon
=
True
listener_thread
.
start
()
# Register the listener with the target
target
.
GetBroadcaster
().
AddListener
(
listener
,
lldb
.
SBTarget
.
eBroadcastBitBreakpointChanged
)
def
start_watchdog
():
"Starts a watchdog thread that will terminate the process after a certain period of time"
watchdog_start_time
=
time
.
clock
()
watchdog_max_time
=
watchdog_start_time
+
30
def
watchdog
():
while
time
.
clock
()
<
watchdog_max_time
:
time
.
sleep
(
1
)
print
(
"TIMEOUT: lldb_batchmode.py has been running for too long. Aborting!"
)
thread
.
interrupt_main
()
# Start the listener and let it run as a daemon
watchdog_thread
=
threading
.
Thread
(
target
=
watchdog
)
watchdog_thread
.
daemon
=
True
watchdog_thread
.
start
()
"""Starts a watchdog thread that will terminate the process after a certain
period of time"""
watchdog_start_time
=
time
.
clock
()
watchdog_max_time
=
watchdog_start_time
+
30
def
watchdog
():
while
time
.
clock
()
<
watchdog_max_time
:
time
.
sleep
(
1
)
print
(
"TIMEOUT: lldb_batchmode.py has been running for too long. Aborting!"
)
thread
.
interrupt_main
()
# Start the listener and let it run as a daemon
watchdog_thread
=
threading
.
Thread
(
target
=
watchdog
)
watchdog_thread
.
daemon
=
True
watchdog_thread
.
start
()
####################################################################################################
# ~main
####################################################################################################
if
len
(
sys
.
argv
)
!=
3
:
print
(
"usage: python lldb_batchmode.py target-path script-path"
)
sys
.
exit
(
1
)
print
(
"usage: python lldb_batchmode.py target-path script-path"
)
sys
.
exit
(
1
)
target_path
=
sys
.
argv
[
1
]
script_path
=
sys
.
argv
[
2
]
...
...
@@ -181,9 +188,9 @@ target_error = lldb.SBError()
target
=
debugger
.
CreateTarget
(
target_path
,
None
,
None
,
True
,
target_error
)
if
not
target
:
print
(
"Could not create debugging target '"
+
target_path
+
"': "
+
str
(
target_error
)
+
". Aborting."
,
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
print
(
"Could not create debugging target '"
+
target_path
+
"': "
+
str
(
target_error
)
+
". Aborting."
,
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
# Register the breakpoint callback for every breakpoint
...
...
@@ -192,22 +199,21 @@ start_breakpoint_listener(target)
command_interpreter
=
debugger
.
GetCommandInterpreter
()
try
:
script_file
=
open
(
script_path
,
'r'
)
script_file
=
open
(
script_path
,
'r'
)
for
line
in
script_file
:
command
=
line
.
strip
()
if
command
==
"run"
or
command
==
"r"
or
re
.
match
(
"^process\s+launch.*"
,
command
):
# Before starting to run the program, let the thread sleep a bit, so all
# breakpoint added events can be processed
time
.
sleep
(
0.5
)
if
command
!=
''
:
execute_command
(
command_interpreter
,
command
)
for
line
in
script_file
:
command
=
line
.
strip
()
if
command
==
"run"
or
command
==
"r"
or
re
.
match
(
"^process\s+launch.*"
,
command
):
# Before starting to run the program, let the thread sleep a bit, so all
# breakpoint added events can be processed
time
.
sleep
(
0.5
)
if
command
!=
''
:
execute_command
(
command_interpreter
,
command
)
except
IOError
as
e
:
print
(
"Could not read debugging script '%s'."
%
script_path
,
file
=
sys
.
stderr
)
print
(
e
,
file
=
sys
.
stderr
)
print
(
"Aborting."
,
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
print
(
"Could not read debugging script '%s'."
%
script_path
,
file
=
sys
.
stderr
)
print
(
e
,
file
=
sys
.
stderr
)
print
(
"Aborting."
,
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
finally
:
script_file
.
close
()
script_file
.
close
()
src/etc/lldb_rust_formatters.py
浏览文件 @
ee0be3b3
...
...
@@ -10,23 +10,24 @@
import
lldb
def
print_val
(
val
,
internal_dict
):
'''Prints the given value with Rust syntax'''
type_class
=
val
.
GetType
().
GetTypeClass
()
'''Prints the given value with Rust syntax'''
type_class
=
val
.
GetType
().
GetTypeClass
()
if
type_class
==
lldb
.
eTypeClassStruct
:
return
print_struct_val
(
val
,
internal_dict
)
if
type_class
==
lldb
.
eTypeClassStruct
:
return
print_struct_val
(
val
,
internal_dict
)
if
type_class
==
lldb
.
eTypeClassUnion
:
return
print_enum_val
(
val
,
internal_dict
)
if
type_class
==
lldb
.
eTypeClassUnion
:
return
print_enum_val
(
val
,
internal_dict
)
if
type_class
==
lldb
.
eTypeClassPointer
:
return
print_pointer_val
(
val
,
internal_dict
)
if
type_class
==
lldb
.
eTypeClassPointer
:
return
print_pointer_val
(
val
,
internal_dict
)
if
type_class
==
lldb
.
eTypeClassArray
:
return
print_fixed_size_vec_val
(
val
,
internal_dict
)
if
type_class
==
lldb
.
eTypeClassArray
:
return
print_fixed_size_vec_val
(
val
,
internal_dict
)
return
val
.
GetValue
()
return
val
.
GetValue
()
#=--------------------------------------------------------------------------------------------------
...
...
@@ -34,162 +35,164 @@ def print_val(val, internal_dict):
#=--------------------------------------------------------------------------------------------------
def
print_struct_val
(
val
,
internal_dict
):
'''Prints a struct, tuple, or tuple struct value with Rust syntax'''
assert
val
.
GetType
().
GetTypeClass
()
==
lldb
.
eTypeClassStruct
'''Prints a struct, tuple, or tuple struct value with Rust syntax'''
assert
val
.
GetType
().
GetTypeClass
()
==
lldb
.
eTypeClassStruct
if
is_vec_slice
(
val
):
return
print_vec_slice_val
(
val
,
internal_dict
)
else
:
return
print_struct_val_starting_from
(
0
,
val
,
internal_dict
)
if
is_vec_slice
(
val
):
return
print_vec_slice_val
(
val
,
internal_dict
)
else
:
return
print_struct_val_starting_from
(
0
,
val
,
internal_dict
)
def
print_vec_slice_val
(
val
,
internal_dict
):
length
=
val
.
GetChildAtIndex
(
1
).
GetValueAsUnsigned
()
length
=
val
.
GetChildAtIndex
(
1
).
GetValueAsUnsigned
()
data_ptr_val
=
val
.
GetChildAtIndex
(
0
)
data_ptr_type
=
data_ptr_val
.
GetType
()
assert
data_ptr_type
.
IsPointerType
()
data_ptr_val
=
val
.
GetChildAtIndex
(
0
)
data_ptr_type
=
data_ptr_val
.
GetType
()
assert
data_ptr_type
.
IsPointerType
()
element_type
=
data_ptr_type
.
GetPointeeType
()
element_type_size
=
element_type
.
GetByteSize
()
element_type
=
data_ptr_type
.
GetPointeeType
()
element_type_size
=
element_type
.
GetByteSize
()
start_address
=
data_ptr_val
.
GetValueAsUnsigned
()
start_address
=
data_ptr_val
.
GetValueAsUnsigned
()
def
render_element
(
i
):
address
=
start_address
+
i
*
element_type_size
element_val
=
val
.
CreateValueFromAddress
(
val
.
GetName
()
+
(
"[%s]"
%
i
),
address
,
element_type
)
return
print_val
(
element_val
,
internal_dict
)
def
render_element
(
i
):
address
=
start_address
+
i
*
element_type_size
element_val
=
val
.
CreateValueFromAddress
(
val
.
GetName
()
+
(
"[%s]"
%
i
),
address
,
element_type
)
return
print_val
(
element_val
,
internal_dict
)
return
"&[%s]"
%
(
', '
.
join
([
render_element
(
i
)
for
i
in
range
(
length
)]))
return
"&[%s]"
%
(
', '
.
join
([
render_element
(
i
)
for
i
in
range
(
length
)]))
def
print_struct_val_starting_from
(
field_start_index
,
val
,
internal_dict
):
'''
Prints a struct, tuple, or tuple struct value with Rust syntax.
Ignores any fields before field_start_index.
'''
assert
val
.
GetType
().
GetTypeClass
()
==
lldb
.
eTypeClassStruct
t
=
val
.
GetType
()
type_name
=
extract_type_name
(
t
.
GetName
())
num_children
=
val
.
num_children
if
(
num_children
-
field_start_index
)
==
0
:
# The only field of this struct is the enum discriminant
return
type_name
has_field_names
=
type_has_field_names
(
t
)
if
has_field_names
:
template
=
"%(type_name)s {
\n
%(body)s
\n
}"
separator
=
",
\n
"
else
:
template
=
"%(type_name)s(%(body)s)"
separator
=
", "
if
type_name
.
startswith
(
"("
):
# this is a tuple, so don't print the type name
type_name
=
""
def
render_child
(
child_index
):
this
=
""
if
has_field_names
:
field_name
=
t
.
GetFieldAtIndex
(
child_index
).
GetName
()
this
+=
field_name
+
": "
field_val
=
val
.
GetChildAtIndex
(
child_index
)
return
this
+
print_val
(
field_val
,
internal_dict
)
def
print_struct_val_starting_from
(
field_start_index
,
val
,
internal_dict
):
'''
Prints a struct, tuple, or tuple struct value with Rust syntax.
Ignores any fields before field_start_index.
'''
assert
val
.
GetType
().
GetTypeClass
()
==
lldb
.
eTypeClassStruct
body
=
separator
.
join
([
render_child
(
idx
)
for
idx
in
range
(
field_start_index
,
num_children
)])
t
=
val
.
GetType
()
type_name
=
extract_type_name
(
t
.
GetName
())
num_children
=
val
.
num_children
return
template
%
{
"type_name"
:
type_name
,
"body"
:
body
}
if
(
num_children
-
field_start_index
)
==
0
:
# The only field of this struct is the enum discriminant
return
type_name
has_field_names
=
type_has_field_names
(
t
)
def
print_enum_val
(
val
,
internal_dict
):
'''Prints an enum value with Rust syntax'''
assert
val
.
GetType
().
GetTypeClass
()
==
lldb
.
eTypeClassUnion
if
val
.
num_children
==
1
:
# This is either an enum with just one variant, or it is an Option-like enum
# where the discriminant is encoded in a non-nullable pointer field. We find
# out which one it is by looking at the member name of the sole union
# variant. If it starts with "RUST$ENCODED$ENUM$" then we have an
# Option-like enum.
first_variant_name
=
val
.
GetChildAtIndex
(
0
).
GetName
()
if
first_variant_name
and
first_variant_name
.
startswith
(
"RUST$ENCODED$ENUM$"
):
# This is an Option-like enum. The position of the discriminator field is
# encoded in the name which has the format:
# RUST$ENCODED$ENUM$<index of discriminator field>$<name of null variant>
last_separator_index
=
first_variant_name
.
rfind
(
"$"
)
if
last_separator_index
==
-
1
:
return
"<invalid enum encoding: %s>"
%
first_variant_name
start_index
=
len
(
"RUST$ENCODED$ENUM$"
)
# Extract indices of the discriminator field
try
:
disr_field_indices
=
first_variant_name
[
start_index
:
last_separator_index
].
split
(
"$"
)
disr_field_indices
=
[
int
(
index
)
for
index
in
disr_field_indices
]
except
:
return
"<invalid enum encoding: %s>"
%
first_variant_name
# Read the discriminant
disr_val
=
val
.
GetChildAtIndex
(
0
)
for
index
in
disr_field_indices
:
disr_val
=
disr_val
.
GetChildAtIndex
(
index
)
# If the discriminant field is a fat pointer we have to consider the
# first word as the true discriminant
if
disr_val
.
GetType
().
GetTypeClass
()
==
lldb
.
eTypeClassStruct
:
disr_val
=
disr_val
.
GetChildAtIndex
(
0
)
if
disr_val
.
GetValueAsUnsigned
()
==
0
:
# Null case: Print the name of the null-variant
null_variant_name
=
first_variant_name
[
last_separator_index
+
1
:]
return
null_variant_name
else
:
# Non-null case: Interpret the data as a value of the non-null variant type
return
print_struct_val_starting_from
(
0
,
val
.
GetChildAtIndex
(
0
),
internal_dict
)
if
has_field_names
:
template
=
"%(type_name)s {
\n
%(body)s
\n
}"
separator
=
",
\n
"
else
:
# This is just a regular uni-variant enum without discriminator field
return
print_struct_val_starting_from
(
0
,
val
.
GetChildAtIndex
(
0
),
internal_dict
)
template
=
"%(type_name)s(%(body)s)"
separator
=
", "
if
type_name
.
startswith
(
"("
):
# this is a tuple, so don't print the type name
type_name
=
""
# If we are here, this is a regular enum with more than one variant
disr_val
=
val
.
GetChildAtIndex
(
0
).
GetChildMemberWithName
(
"RUST$ENUM$DISR"
)
disr_type
=
disr_val
.
GetType
()
def
render_child
(
child_index
):
this
=
""
if
has_field_names
:
field_name
=
t
.
GetFieldAtIndex
(
child_index
).
GetName
()
this
+=
field_name
+
": "
if
disr_type
.
GetTypeClass
()
!=
lldb
.
eTypeClassEnumeration
:
return
"<Invalid enum value encountered: Discriminator is not an enum>"
field_val
=
val
.
GetChildAtIndex
(
child_index
)
return
this
+
print_val
(
field_val
,
internal_dict
)
variant_index
=
disr_val
.
GetValueAsUnsigned
()
return
print_struct_val_starting_from
(
1
,
val
.
GetChildAtIndex
(
variant_index
),
internal_dict
)
body
=
separator
.
join
([
render_child
(
idx
)
for
idx
in
range
(
field_start_index
,
num_children
)])
return
template
%
{
"type_name"
:
type_name
,
"body"
:
body
}
def
print_enum_val
(
val
,
internal_dict
):
'''Prints an enum value with Rust syntax'''
assert
val
.
GetType
().
GetTypeClass
()
==
lldb
.
eTypeClassUnion
if
val
.
num_children
==
1
:
# This is either an enum with just one variant, or it is an Option-like
# enum where the discriminant is encoded in a non-nullable pointer
# field. We find out which one it is by looking at the member name of
# the sole union variant. If it starts with "RUST$ENCODED$ENUM$" then
# we have an Option-like enum.
first_variant_name
=
val
.
GetChildAtIndex
(
0
).
GetName
()
if
first_variant_name
and
first_variant_name
.
startswith
(
"RUST$ENCODED$ENUM$"
):
# This is an Option-like enum. The position of the discriminator field is
# encoded in the name which has the format:
# RUST$ENCODED$ENUM$<index of discriminator field>$<name of null variant>
last_separator_index
=
first_variant_name
.
rfind
(
"$"
)
if
last_separator_index
==
-
1
:
return
"<invalid enum encoding: %s>"
%
first_variant_name
start_index
=
len
(
"RUST$ENCODED$ENUM$"
)
# Extract indices of the discriminator field
try
:
disr_field_indices
=
first_variant_name
[
start_index
:
last_separator_index
].
split
(
"$"
)
disr_field_indices
=
[
int
(
index
)
for
index
in
disr_field_indices
]
except
:
return
"<invalid enum encoding: %s>"
%
first_variant_name
# Read the discriminant
disr_val
=
val
.
GetChildAtIndex
(
0
)
for
index
in
disr_field_indices
:
disr_val
=
disr_val
.
GetChildAtIndex
(
index
)
# If the discriminant field is a fat pointer we have to consider the
# first word as the true discriminant
if
disr_val
.
GetType
().
GetTypeClass
()
==
lldb
.
eTypeClassStruct
:
disr_val
=
disr_val
.
GetChildAtIndex
(
0
)
if
disr_val
.
GetValueAsUnsigned
()
==
0
:
# Null case: Print the name of the null-variant
null_variant_name
=
first_variant_name
[
last_separator_index
+
1
:]
return
null_variant_name
else
:
# Non-null case: Interpret the data as a value of the non-null variant type
return
print_struct_val_starting_from
(
0
,
val
.
GetChildAtIndex
(
0
),
internal_dict
)
else
:
# This is just a regular uni-variant enum without discriminator field
return
print_struct_val_starting_from
(
0
,
val
.
GetChildAtIndex
(
0
),
internal_dict
)
# If we are here, this is a regular enum with more than one variant
disr_val
=
val
.
GetChildAtIndex
(
0
).
GetChildMemberWithName
(
"RUST$ENUM$DISR"
)
disr_type
=
disr_val
.
GetType
()
if
disr_type
.
GetTypeClass
()
!=
lldb
.
eTypeClassEnumeration
:
return
"<Invalid enum value encountered: Discriminator is not an enum>"
variant_index
=
disr_val
.
GetValueAsUnsigned
()
return
print_struct_val_starting_from
(
1
,
val
.
GetChildAtIndex
(
variant_index
),
internal_dict
)
def
print_pointer_val
(
val
,
internal_dict
):
'''Prints a pointer value with Rust syntax'''
assert
val
.
GetType
().
IsPointerType
()
sigil
=
"&"
type_name
=
extract_type_name
(
val
.
GetType
().
GetName
())
if
type_name
and
type_name
[
0
:
1
]
in
[
"&"
,
"~"
,
"*"
]:
sigil
=
type_name
[
0
:
1
]
'''Prints a pointer value with Rust syntax'''
assert
val
.
GetType
().
IsPointerType
()
sigil
=
"&"
type_name
=
extract_type_name
(
val
.
GetType
().
GetName
())
if
type_name
and
type_name
[
0
:
1
]
in
[
"&"
,
"~"
,
"*"
]:
sigil
=
type_name
[
0
:
1
]
return
sigil
+
hex
(
val
.
GetValueAsUnsigned
())
#print_val(val.Dereference(), internal_dict)
return
sigil
+
hex
(
val
.
GetValueAsUnsigned
())
#print_val(val.Dereference(), internal_dict)
def
print_fixed_size_vec_val
(
val
,
internal_dict
):
assert
val
.
GetType
().
GetTypeClass
()
==
lldb
.
eTypeClassArray
assert
val
.
GetType
().
GetTypeClass
()
==
lldb
.
eTypeClassArray
output
=
"["
output
=
"["
for
i
in
range
(
val
.
num_children
):
output
+=
print_val
(
val
.
GetChildAtIndex
(
i
),
internal_dict
)
if
i
!=
val
.
num_children
-
1
:
output
+=
", "
for
i
in
range
(
val
.
num_children
):
output
+=
print_val
(
val
.
GetChildAtIndex
(
i
),
internal_dict
)
if
i
!=
val
.
num_children
-
1
:
output
+=
", "
output
+=
"]"
return
output
output
+=
"]"
return
output
#=--------------------------------------------------------------------------------------------------
...
...
@@ -198,46 +201,45 @@ def print_fixed_size_vec_val(val, internal_dict):
unqualified_type_markers
=
frozenset
([
"("
,
"["
,
"&"
,
"*"
])
def
extract_type_name
(
qualified_type_name
):
'''Extracts the type name from a fully qualified path'''
if
qualified_type_name
[
0
]
in
unqualified_type_markers
:
return
qualified_type_name
'''Extracts the type name from a fully qualified path'''
if
qualified_type_name
[
0
]
in
unqualified_type_markers
:
return
qualified_type_name
end_of_search
=
qualified_type_name
.
find
(
"<"
)
if
end_of_search
<
0
:
end_of_search
=
len
(
qualified_type_name
)
end_of_search
=
qualified_type_name
.
find
(
"<"
)
if
end_of_search
<
0
:
end_of_search
=
len
(
qualified_type_name
)
index
=
qualified_type_name
.
rfind
(
"::"
,
0
,
end_of_search
)
if
index
<
0
:
return
qualified_type_name
else
:
return
qualified_type_name
[
index
+
2
:]
index
=
qualified_type_name
.
rfind
(
"::"
,
0
,
end_of_search
)
if
index
<
0
:
return
qualified_type_name
else
:
return
qualified_type_name
[
index
+
2
:]
def
type_has_field_names
(
ty
):
'''Returns true of this is a type with field names (struct, struct-like enum variant)'''
# This may also be an enum variant where the first field doesn't have a name but the rest has
if
ty
.
GetNumberOfFields
()
>
1
:
return
ty
.
GetFieldAtIndex
(
1
).
GetName
()
!=
None
else
:
return
ty
.
GetFieldAtIndex
(
0
).
GetName
()
!=
None
'''Returns true of this is a type with field names (struct, struct-like enum variant)'''
# This may also be an enum variant where the first field doesn't have a name but the rest has
if
ty
.
GetNumberOfFields
()
>
1
:
return
ty
.
GetFieldAtIndex
(
1
).
GetName
()
is
not
None
else
:
return
ty
.
GetFieldAtIndex
(
0
).
GetName
()
is
not
None
def
is_vec_slice
(
val
):
ty
=
val
.
GetType
()
if
ty
.
GetTypeClass
()
!=
lldb
.
eTypeClassStruct
:
return
False
if
ty
.
GetNumberOfFields
()
!=
2
:
return
False
ty
=
val
.
GetType
()
if
ty
.
GetTypeClass
()
!=
lldb
.
eTypeClassStruct
:
return
False
if
ty
.
GetFieldAtIndex
(
0
).
GetName
()
!=
"data_ptr"
:
return
False
if
ty
.
GetNumberOfFields
()
!=
2
:
return
False
if
ty
.
GetFieldAtIndex
(
1
).
GetName
()
!=
"length
"
:
return
False
if
ty
.
GetFieldAtIndex
(
0
).
GetName
()
!=
"data_ptr
"
:
return
False
type_name
=
extract_type_name
(
ty
.
GetName
()).
replace
(
"&'static"
,
"&"
).
replace
(
" "
,
""
)
return
type_name
.
startswith
(
"&["
)
and
type_name
.
endswith
(
"]"
)
if
ty
.
GetFieldAtIndex
(
1
).
GetName
()
!=
"length"
:
return
False
# vi: sw=2:ts=2
type_name
=
extract_type_name
(
ty
.
GetName
()).
replace
(
"&'static"
,
"&"
).
replace
(
" "
,
""
)
return
type_name
.
startswith
(
"&["
)
and
type_name
.
endswith
(
"]"
)
src/etc/make-win-dist.py
浏览文件 @
ee0be3b3
...
...
@@ -14,7 +14,11 @@
# argv[3] = target triple
# The first two correspond to the two installable components defined in the setup script.
import
sys
,
os
,
shutil
,
subprocess
import
sys
import
os
import
shutil
import
subprocess
def
find_files
(
files
,
path
):
found
=
[]
...
...
@@ -28,6 +32,7 @@ def find_files(files, path):
raise
Exception
(
"Could not find '%s' in %s"
%
(
fname
,
path
))
return
found
def
make_win_dist
(
rust_root
,
gcc_root
,
target_triple
):
# Ask gcc where it keeps its stuff
gcc_out
=
subprocess
.
check_output
([
"gcc.exe"
,
"-print-search-dirs"
])
...
...
@@ -114,5 +119,5 @@ def make_win_dist(rust_root, gcc_root, target_triple):
for
src
in
target_libs
:
shutil
.
copy
(
src
,
target_lib_dir
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
make_win_dist
(
sys
.
argv
[
1
],
sys
.
argv
[
2
],
sys
.
argv
[
3
])
src/etc/maketest.py
浏览文件 @
ee0be3b3
...
...
@@ -12,13 +12,14 @@ import subprocess
import
os
import
sys
# msys1/msys2 automatically converts `/abs/path1:/abs/path2` into
# `c:\real\abs\path1;c:\real\abs\path2` (semicolons) if shell thinks
# the value is list of paths.
# (if there is only one path, it becomes `c:/real/abs/path`.)
# this causes great confusion and error: shell and Makefile doesn't like
# windows paths so it is really error-prone. revert it for peace.
def
normalize_path
(
v
):
"""msys1/msys2 automatically converts `/abs/path1:/abs/path2` into
`c:
\r
eal
\a
bs\path1;c:
\r
eal
\a
bs\path2` (semicolons) if shell thinks
the value is list of paths.
(if there is only one path, it becomes `c:/real/abs/path`.)
this causes great confusion and error: shell and Makefile doesn't like
windows paths so it is really error-prone. revert it for peace."""
v
=
v
.
replace
(
'
\\
'
,
'/'
)
# c:/path -> /c/path
if
':/'
in
v
:
...
...
@@ -31,6 +32,7 @@ def putenv(name, value):
value
=
normalize_path
(
value
)
os
.
putenv
(
name
,
value
)
def
convert_path_spec
(
name
,
value
):
if
os
.
name
==
'nt'
and
name
!=
'PATH'
:
value
=
":"
.
join
(
normalize_path
(
v
)
for
v
in
value
.
split
(
";"
))
...
...
@@ -42,14 +44,14 @@ putenv('TMPDIR', os.path.abspath(sys.argv[4]))
putenv
(
'CC'
,
sys
.
argv
[
5
])
putenv
(
'RUSTDOC'
,
os
.
path
.
abspath
(
sys
.
argv
[
6
]))
filt
=
sys
.
argv
[
7
]
putenv
(
'LD_LIB_PATH_ENVVAR'
,
sys
.
argv
[
8
])
;
putenv
(
'HOST_RPATH_DIR'
,
os
.
path
.
abspath
(
sys
.
argv
[
9
]))
;
putenv
(
'TARGET_RPATH_DIR'
,
os
.
path
.
abspath
(
sys
.
argv
[
10
]))
;
putenv
(
'LD_LIB_PATH_ENVVAR'
,
sys
.
argv
[
8
])
putenv
(
'HOST_RPATH_DIR'
,
os
.
path
.
abspath
(
sys
.
argv
[
9
]))
putenv
(
'TARGET_RPATH_DIR'
,
os
.
path
.
abspath
(
sys
.
argv
[
10
]))
putenv
(
'RUST_BUILD_STAGE'
,
sys
.
argv
[
11
])
putenv
(
'S'
,
os
.
path
.
abspath
(
sys
.
argv
[
12
]))
putenv
(
'PYTHON'
,
sys
.
executable
)
if
not
fil
t
in
sys
.
argv
[
1
]:
if
filt
no
t
in
sys
.
argv
[
1
]:
sys
.
exit
(
0
)
print
(
'maketest: '
+
os
.
path
.
basename
(
os
.
path
.
dirname
(
sys
.
argv
[
1
])))
...
...
@@ -63,19 +65,19 @@ if path[-1] == '/':
path
=
path
[:
-
1
]
proc
=
subprocess
.
Popen
([
make
,
'-C'
,
path
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
out
,
err
=
proc
.
communicate
()
i
=
proc
.
wait
()
if
i
!=
0
:
print
'----- '
+
sys
.
argv
[
1
]
+
"""
--------------------
print
"""
\
----- %s
--------------------
------ stdout ---------------------------------------------
"""
+
out
+
"""
%s
------ stderr ---------------------------------------------
"""
+
err
+
"""
%s
------ ---------------------------------------------
"""
sys
.
exit
(
i
)
"""
%
(
sys
.
argv
[
1
],
out
,
err
)
sys
.
exit
(
i
)
src/etc/mirror-all-snapshots.py
浏览文件 @
ee0be3b3
...
...
@@ -10,7 +10,7 @@
# option. This file may not be copied, modified, or distributed
# except according to those terms.
import
os
,
tarfile
,
hashlib
,
re
,
shutil
import
os
from
snapshot
import
*
f
=
open
(
snapshotfile
)
...
...
@@ -23,13 +23,14 @@ i = 0
for
line
in
f
.
readlines
():
i
+=
1
parsed
=
parse_line
(
i
,
line
)
if
(
not
parsed
):
continue
if
not
parsed
:
continue
if
parsed
[
"type"
]
==
"snapshot"
:
date
=
parsed
[
"date"
]
rev
=
parsed
[
"rev"
]
elif
rev
!=
None
and
parsed
[
"type"
]
==
"file"
:
elif
rev
is
not
None
and
parsed
[
"type"
]
==
"file"
:
platform
=
parsed
[
"platform"
]
hsh
=
parsed
[
"hash"
]
snap
=
full_snapshot_name
(
date
,
rev
,
platform
,
hsh
)
...
...
src/etc/mklldeps.py
浏览文件 @
ee0be3b3
...
...
@@ -11,8 +11,6 @@
import
os
import
sys
import
subprocess
import
itertools
from
os
import
path
f
=
open
(
sys
.
argv
[
1
],
'wb'
)
...
...
@@ -35,6 +33,7 @@ f.write("""// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// take a look at src/etc/mklldeps.py if you're interested
"""
)
def
run
(
args
):
proc
=
subprocess
.
Popen
(
args
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
out
,
err
=
proc
.
communicate
()
...
...
src/etc/snapshot.py
浏览文件 @
ee0be3b3
...
...
@@ -8,24 +8,32 @@
# option. This file may not be copied, modified, or distributed
# except according to those terms.
import
re
,
os
,
sys
,
glob
,
tarfile
,
shutil
,
subprocess
,
tempfile
,
distutils
.
spawn
import
re
import
os
import
sys
import
glob
import
tarfile
import
shutil
import
subprocess
import
distutils.spawn
try
:
import
hashlib
sha_func
=
hashlib
.
sha1
import
hashlib
sha_func
=
hashlib
.
sha1
except
ImportError
:
import
sha
sha_func
=
sha
.
new
import
sha
sha_func
=
sha
.
new
def
scrub
(
b
):
if
sys
.
version_info
>=
(
3
,)
and
type
(
b
)
==
bytes
:
return
b
.
decode
(
'ascii'
)
else
:
return
b
if
sys
.
version_info
>=
(
3
,)
and
type
(
b
)
==
bytes
:
return
b
.
decode
(
'ascii'
)
else
:
return
b
src_dir
=
scrub
(
os
.
getenv
(
"CFG_SRC_DIR"
))
if
not
src_dir
:
raise
Exception
(
"missing env var CFG_SRC_DIR"
)
raise
Exception
(
"missing env var CFG_SRC_DIR"
)
snapshotfile
=
os
.
path
.
join
(
src_dir
,
"src"
,
"snapshots.txt"
)
download_url_base
=
"https://static.rust-lang.org/stage0-snapshots"
...
...
@@ -33,54 +41,57 @@ download_dir_base = "dl"
download_unpack_base
=
os
.
path
.
join
(
download_dir_base
,
"unpack"
)
snapshot_files
=
{
"linux"
:
[
"bin/rustc"
],
"macos"
:
[
"bin/rustc"
],
"winnt"
:
[
"bin/rustc.exe"
],
"freebsd"
:
[
"bin/rustc"
],
"dragonfly"
:
[
"bin/rustc"
],
}
winnt_runtime_deps_32
=
[
"libgcc_s_dw2-1.dll"
,
"libstdc++-6.dll"
]
winnt_runtime_deps_64
=
[
"libgcc_s_seh-1.dll"
,
"libstdc++-6.dll"
]
"linux"
:
[
"bin/rustc"
],
"macos"
:
[
"bin/rustc"
],
"winnt"
:
[
"bin/rustc.exe"
],
"freebsd"
:
[
"bin/rustc"
],
"dragonfly"
:
[
"bin/rustc"
],
}
winnt_runtime_deps_32
=
[
"libgcc_s_dw2-1.dll"
,
"libstdc++-6.dll"
]
winnt_runtime_deps_64
=
[
"libgcc_s_seh-1.dll"
,
"libstdc++-6.dll"
]
def
parse_line
(
n
,
line
):
global
snapshotfile
global
snapshotfile
if
re
.
match
(
r
"\s*$"
,
line
):
return
None
if
re
.
match
(
r
"\s*$"
,
line
):
return
None
if
re
.
match
(
r
"^T\s*$"
,
line
):
return
None
if
re
.
match
(
r
"^T\s*$"
,
line
):
return
None
match
=
re
.
match
(
r
"\s+([\w_-]+) ([a-fA-F\d]{40})\s*$"
,
line
)
if
match
:
return
{
"type"
:
"file"
,
"platform"
:
match
.
group
(
1
),
"hash"
:
match
.
group
(
2
).
lower
()
}
match
=
re
.
match
(
r
"\s+([\w_-]+) ([a-fA-F\d]{40})\s*$"
,
line
)
if
match
:
return
{
"type"
:
"file"
,
"platform"
:
match
.
group
(
1
),
"hash"
:
match
.
group
(
2
).
lower
()
}
match
=
re
.
match
(
r
"([ST]) (\d{4}-\d{2}-\d{2}) ([a-fA-F\d]+)\s*$"
,
line
);
if
(
not
match
)
:
raise
Exception
(
"%s:%d:E syntax error: "
%
(
snapshotfile
,
n
))
return
{
"type"
:
"snapshot"
,
"date"
:
match
.
group
(
2
),
"rev"
:
match
.
group
(
3
)}
match
=
re
.
match
(
r
"([ST]) (\d{4}-\d{2}-\d{2}) ([a-fA-F\d]+)\s*$"
,
line
)
if
not
match
:
raise
Exception
(
"%s:%d:E syntax error: "
%
(
snapshotfile
,
n
))
return
{
"type"
:
"snapshot"
,
"date"
:
match
.
group
(
2
),
"rev"
:
match
.
group
(
3
)}
def
partial_snapshot_name
(
date
,
rev
,
platform
):
return
(
"rust-stage0-%s-%s-%s.tar.bz2"
%
(
date
,
rev
,
platform
))
return
(
"rust-stage0-%s-%s-%s.tar.bz2"
%
(
date
,
rev
,
platform
))
def
full_snapshot_name
(
date
,
rev
,
platform
,
hsh
):
return
(
"rust-stage0-%s-%s-%s-%s.tar.bz2"
%
(
date
,
rev
,
platform
,
hsh
))
return
(
"rust-stage0-%s-%s-%s-%s.tar.bz2"
%
(
date
,
rev
,
platform
,
hsh
))
def
get_kernel
(
triple
):
t
=
triple
.
split
(
'-'
)
if
len
(
t
)
==
2
:
os_name
=
t
[
1
]
os_name
=
t
[
1
]
else
:
os_name
=
t
[
2
]
os_name
=
t
[
2
]
if
os_name
==
"windows"
:
return
"winnt"
if
os_name
==
"darwin"
:
...
...
@@ -91,19 +102,20 @@ def get_kernel(triple):
return
"dragonfly"
return
"linux"
def
get_cpu
(
triple
):
arch
=
triple
.
split
(
'-'
)[
0
]
if
arch
==
"i686"
:
return
"i386"
return
"i386"
return
arch
def
get_platform
(
triple
):
return
"%s-%s"
%
(
get_kernel
(
triple
),
get_cpu
(
triple
))
return
"%s-%s"
%
(
get_kernel
(
triple
),
get_cpu
(
triple
))
def
cmd_out
(
cmdline
):
p
=
subprocess
.
Popen
(
cmdline
,
stdout
=
subprocess
.
PIPE
)
p
=
subprocess
.
Popen
(
cmdline
,
stdout
=
subprocess
.
PIPE
)
return
scrub
(
p
.
communicate
()[
0
].
strip
())
...
...
@@ -124,7 +136,8 @@ def local_rev_short_sha():
def
local_rev_committer_date
():
return
local_rev_info
(
"ci"
)
def
get_url_to_file
(
u
,
f
):
def
get_url_to_file
(
u
,
f
):
# no security issue, just to stop partial download leaving a stale file
tmpf
=
f
+
'.tmp'
...
...
@@ -137,40 +150,44 @@ def get_url_to_file(u,f):
if
returncode
!=
0
:
try
:
os
.
unlink
(
tmpf
)
except
OSError
as
e
:
except
OSError
:
pass
raise
Exception
(
"failed to fetch url"
)
os
.
rename
(
tmpf
,
f
)
def
snap_filename_hash_part
(
snap
):
match
=
re
.
match
(
r
".*([a-fA-F\d]{40}).tar.bz2$"
,
snap
)
if
not
match
:
raise
Exception
(
"unable to find hash in filename: "
+
snap
)
return
match
.
group
(
1
)
match
=
re
.
match
(
r
".*([a-fA-F\d]{40}).tar.bz2$"
,
snap
)
if
not
match
:
raise
Exception
(
"unable to find hash in filename: "
+
snap
)
return
match
.
group
(
1
)
def
hash_file
(
x
):
h
=
sha_func
()
h
.
update
(
open
(
x
,
"rb"
).
read
())
return
scrub
(
h
.
hexdigest
())
# Returns a list of paths of Rust's system runtime dependencies
def
get_winnt_runtime_deps
(
platform
):
"""Returns a list of paths of Rust's system runtime dependencies"""
if
platform
==
"winnt-x86_64"
:
deps
=
winnt_runtime_deps_64
deps
=
winnt_runtime_deps_64
else
:
deps
=
winnt_runtime_deps_32
deps
=
winnt_runtime_deps_32
runtime_deps
=
[]
path_dirs
=
os
.
environ
[
"PATH"
].
split
(
os
.
pathsep
)
for
name
in
deps
:
for
dir
in
path_dirs
:
filepath
=
os
.
path
.
join
(
dir
,
name
)
if
os
.
path
.
isfile
(
filepath
):
runtime_deps
.
append
(
filepath
)
break
else
:
raise
Exception
(
"Could not find runtime dependency: %s"
%
name
)
for
dir
in
path_dirs
:
filepath
=
os
.
path
.
join
(
dir
,
name
)
if
os
.
path
.
isfile
(
filepath
):
runtime_deps
.
append
(
filepath
)
break
else
:
raise
Exception
(
"Could not find runtime dependency: %s"
%
name
)
return
runtime_deps
def
make_snapshot
(
stage
,
triple
):
kernel
=
get_kernel
(
triple
)
platform
=
get_platform
(
triple
)
...
...
@@ -180,31 +197,31 @@ def make_snapshot(stage, triple):
file0
=
partial_snapshot_name
(
date
,
rev
,
platform
)
def
in_tar_name
(
fn
):
cs
=
re
.
split
(
r
"[\\/]"
,
fn
)
if
len
(
cs
)
>=
2
:
return
os
.
sep
.
join
(
cs
[
-
2
:])
cs
=
re
.
split
(
r
"[\\/]"
,
fn
)
if
len
(
cs
)
>=
2
:
return
os
.
sep
.
join
(
cs
[
-
2
:])
tar
=
tarfile
.
open
(
file0
,
"w:bz2"
)
for
name
in
snapshot_files
[
kernel
]:
dir
=
stage
if
stage
==
"stage1"
and
re
.
match
(
r
"^lib/(lib)?std.*"
,
name
):
dir
=
"stage0"
fn_glob
=
os
.
path
.
join
(
triple
,
dir
,
name
)
matches
=
glob
.
glob
(
fn_glob
)
if
not
matches
:
raise
Exception
(
"Not found file with name like "
+
fn_glob
)
if
len
(
matches
)
==
1
:
tar
.
add
(
matches
[
0
],
"rust-stage0/"
+
in_tar_name
(
matches
[
0
]))
else
:
raise
Exception
(
"Found stale files:
\n
%s
\n
"
"Please make a clean build."
%
"
\n
"
.
join
(
matches
))
if
kernel
==
"winnt"
:
for
path
in
get_winnt_runtime_deps
(
platform
):
tar
.
add
(
path
,
"rust-stage0/bin/"
+
os
.
path
.
basename
(
path
))
tar
.
add
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"third-party"
),
"rust-stage0/bin/third-party"
)
dir
=
stage
if
stage
==
"stage1"
and
re
.
match
(
r
"^lib/(lib)?std.*"
,
name
):
dir
=
"stage0"
fn_glob
=
os
.
path
.
join
(
triple
,
dir
,
name
)
matches
=
glob
.
glob
(
fn_glob
)
if
not
matches
:
raise
Exception
(
"Not found file with name like "
+
fn_glob
)
if
len
(
matches
)
==
1
:
tar
.
add
(
matches
[
0
],
"rust-stage0/"
+
in_tar_name
(
matches
[
0
]))
else
:
raise
Exception
(
"Found stale files:
\n
%s
\n
"
"Please make a clean build."
%
"
\n
"
.
join
(
matches
))
if
kernel
==
"winnt"
:
for
path
in
get_winnt_runtime_deps
(
platform
):
tar
.
add
(
path
,
"rust-stage0/bin/"
+
os
.
path
.
basename
(
path
))
tar
.
add
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"third-party"
),
"rust-stage0/bin/third-party"
)
tar
.
close
()
...
...
@@ -215,60 +232,64 @@ def make_snapshot(stage, triple):
return
file1
def
curr_snapshot_rev
():
i
=
0
found_snap
=
False
date
=
None
rev
=
None
i
=
0
found_snap
=
False
date
=
None
rev
=
None
f
=
open
(
snapshotfile
)
for
line
in
f
.
readlines
():
i
+=
1
parsed
=
parse_line
(
i
,
line
)
if
not
parsed
:
continue
f
=
open
(
snapshotfile
)
for
line
in
f
.
readlines
():
i
+=
1
parsed
=
parse_line
(
i
,
line
)
if
(
not
parsed
):
continue
if
parsed
[
"type"
]
==
"snapshot"
:
date
=
parsed
[
"date"
]
rev
=
parsed
[
"rev"
]
found_snap
=
True
break
if
parsed
[
"type"
]
==
"snapshot"
:
date
=
parsed
[
"date"
]
rev
=
parsed
[
"rev"
]
found_snap
=
True
break
if
not
found_snap
:
raise
Exception
(
"no snapshot entries in file"
)
if
not
found_snap
:
raise
Exception
(
"no snapshot entries in file"
)
return
(
date
,
rev
)
return
(
date
,
rev
)
def
determine_curr_snapshot
(
triple
):
i
=
0
platform
=
get_platform
(
triple
)
found_file
=
False
found_snap
=
False
hsh
=
None
date
=
None
rev
=
None
f
=
open
(
snapshotfile
)
for
line
in
f
.
readlines
():
i
+=
1
parsed
=
parse_line
(
i
,
line
)
if
(
not
parsed
):
continue
if
found_snap
and
parsed
[
"type"
]
==
"file"
:
if
parsed
[
"platform"
]
==
platform
:
hsh
=
parsed
[
"hash"
]
found_file
=
True
break
;
elif
parsed
[
"type"
]
==
"snapshot"
:
date
=
parsed
[
"date"
]
rev
=
parsed
[
"rev"
]
found_snap
=
True
if
not
found_snap
:
raise
Exception
(
"no snapshot entries in file"
)
if
not
found_file
:
raise
Exception
(
"no snapshot file found for platform %s, rev %s"
%
(
platform
,
rev
))
return
full_snapshot_name
(
date
,
rev
,
platform
,
hsh
)
i
=
0
platform
=
get_platform
(
triple
)
found_file
=
False
found_snap
=
False
hsh
=
None
date
=
None
rev
=
None
f
=
open
(
snapshotfile
)
for
line
in
f
.
readlines
():
i
+=
1
parsed
=
parse_line
(
i
,
line
)
if
not
parsed
:
continue
if
found_snap
and
parsed
[
"type"
]
==
"file"
:
if
parsed
[
"platform"
]
==
platform
:
hsh
=
parsed
[
"hash"
]
found_file
=
True
break
elif
parsed
[
"type"
]
==
"snapshot"
:
date
=
parsed
[
"date"
]
rev
=
parsed
[
"rev"
]
found_snap
=
True
if
not
found_snap
:
raise
Exception
(
"no snapshot entries in file"
)
if
not
found_file
:
raise
Exception
(
"no snapshot file found for platform %s, rev %s"
%
(
platform
,
rev
))
return
full_snapshot_name
(
date
,
rev
,
platform
,
hsh
)
src/etc/sugarise-doc-comments.py
浏览文件 @
ee0be3b3
...
...
@@ -17,7 +17,10 @@
# it sugarises all .rs/.rc files underneath the working directory
#
import
sys
,
os
,
fnmatch
,
re
import
sys
import
os
import
fnmatch
import
re
DOC_PATTERN
=
'^(?P<indent>[
\\
t ]*)#
\\
[(
\\
s*)doc(
\\
s*)='
+
\
...
...
@@ -85,7 +88,6 @@ def sugarise_file(path):
if
s
!=
ns
:
open
(
path
,
'w'
).
write
(
ns
)
for
(
dirpath
,
dirnames
,
filenames
)
in
os
.
walk
(
'.'
):
for
name
in
fnmatch
.
filter
(
filenames
,
'*.r[sc]'
):
sugarise_file
(
os
.
path
.
join
(
dirpath
,
name
))
src/etc/tidy.py
浏览文件 @
ee0be3b3
...
...
@@ -8,37 +8,45 @@
# option. This file may not be copied, modified, or distributed
# except according to those terms.
import
sys
,
fileinput
,
subprocess
,
re
,
os
import
sys
import
fileinput
import
subprocess
import
re
import
os
from
licenseck
import
*
import
snapshot
err
=
0
cols
=
100
cr_flag
=
"ignore-tidy-cr"
tab_flag
=
"ignore-tidy-tab"
linelength_flag
=
"ignore-tidy-linelength"
err
=
0
cols
=
100
cr_flag
=
"ignore-tidy-cr"
tab_flag
=
"ignore-tidy-tab"
linelength_flag
=
"ignore-tidy-linelength"
# Be careful to support Python 2.4, 2.6, and 3.x here!
config_proc
=
subprocess
.
Popen
([
"git"
,
"config"
,
"core.autocrlf"
],
stdout
=
subprocess
.
PIPE
)
result
=
config_proc
.
communicate
()[
0
]
config_proc
=
subprocess
.
Popen
([
"git"
,
"config"
,
"core.autocrlf"
],
stdout
=
subprocess
.
PIPE
)
result
=
config_proc
.
communicate
()[
0
]
true
=
"true"
.
encode
(
'utf8'
)
autocrlf
=
result
.
strip
()
==
true
if
result
is
not
None
else
False
true
=
"true"
.
encode
(
'utf8'
)
autocrlf
=
result
.
strip
()
==
true
if
result
is
not
None
else
False
def
report_error_name_no
(
name
,
no
,
s
):
global
err
print
(
"%s:%d: %s"
%
(
name
,
no
,
s
))
err
=
1
err
=
1
def
report_err
(
s
):
report_error_name_no
(
fileinput
.
filename
(),
fileinput
.
filelineno
(),
s
)
def
report_warn
(
s
):
print
(
"%s:%d: %s"
%
(
fileinput
.
filename
(),
fileinput
.
filelineno
(),
s
))
def
do_license_check
(
name
,
contents
):
if
not
check_license
(
name
,
contents
):
report_error_name_no
(
name
,
1
,
"incorrect license"
)
...
...
@@ -81,13 +89,13 @@ try:
date
,
rev
=
snapshot
.
curr_snapshot_rev
()
if
not
hsh
.
startswith
(
rev
):
report_err
(
"snapshot out of date ("
+
date
+
"): "
+
line
)
+
"): "
+
line
)
else
:
if
"SNAP"
in
line
:
report_warn
(
"unmatched SNAP line: "
+
line
)
if
check_tab
and
(
'
\t
'
in
line
and
"Makefile"
not
in
fileinput
.
filename
()):
"Makefile"
not
in
fileinput
.
filename
()):
report_err
(
"tab character"
)
if
check_cr
and
not
autocrlf
and
'
\r
'
in
line
:
report_err
(
"CR character"
)
...
...
src/etc/unicode.py
浏览文件 @
ee0be3b3
...
...
@@ -392,15 +392,13 @@ def emit_grapheme_module(f, grapheme_table, grapheme_cats):
use core::slice;
#[allow(non_camel_case_types)]
#[derive(Clone)]
#[derive(Clone
, Copy
)]
pub enum GraphemeCat {
"""
)
for
cat
in
grapheme_cats
+
[
"Any"
]:
f
.
write
(
" GC_"
+
cat
+
",
\n
"
)
f
.
write
(
""" }
impl Copy for GraphemeCat {}
fn bsearch_range_value_table(c: char, r: &'static [(char, char, GraphemeCat)]) -> GraphemeCat {
use core::cmp::Ordering::{Equal, Less, Greater};
match r.binary_search(|&(lo, hi, _)| {
...
...
src/etc/vim/syntax_checkers/rust/rustc.vim
浏览文件 @
ee0be3b3
...
...
@@ -14,7 +14,7 @@ let s:save_cpo = &cpo
set
cpo
&
vim
function
!
SyntaxCheckers_rust_rustc_GetLocList
()
dict
let
makeprg
=
self
.
makeprgBuild
({
'args'
:
'-
-
parse-only'
})
let
makeprg
=
self
.
makeprgBuild
({
'args'
:
'-
Z
parse-only'
})
let
errorformat
=
\
'%E%f:%l:%c: %\d%#:%\d%# %.%\{-}error:%.%\{-} %m,'
.
...
...
src/libcollections/slice.rs
浏览文件 @
ee0be3b3
// Copyright 2012-201
4
The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-201
5
The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
...
...
@@ -179,7 +179,7 @@ pub trait SliceExt {
/// Deprecated: use `&s[start..]` notation instead.
#[unstable(feature
=
"collections"
,
reason
=
"will be replaced by slice syntax"
)]
#[deprecated(since
=
"1.0.0"
,
reason
=
"use &s[start..] i
sn
tead"
)]
#[deprecated(since
=
"1.0.0"
,
reason
=
"use &s[start..] i
ns
tead"
)]
fn
slice_from
(
&
self
,
start
:
uint
)
->
&
[
Self
::
Item
];
/// Deprecated: use `&s[..end]` notation instead.
...
...
@@ -195,15 +195,36 @@ pub trait SliceExt {
/// indices from `[mid, len)` (excluding the index `len` itself).
///
/// Panics if `mid > len`.
///
/// # Examples
///
/// ```
/// let v = [10, 40, 30, 20, 50];
/// let (v1, v2) = v.split_at(2);
/// assert_eq!([10, 40], v1);
/// assert_eq!([30, 20, 50], v2);
/// ```
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
fn
split_at
(
&
self
,
mid
:
uint
)
->
(
&
[
Self
::
Item
],
&
[
Self
::
Item
]);
/// Returns an iterator over the slice
/// Returns an iterator over the slice
.
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
fn
iter
(
&
self
)
->
Iter
<
Self
::
Item
>
;
/// Returns an iterator over subslices separated by elements that match
/// `pred`. The matched element is not contained in the subslices.
///
/// # Examples
///
/// Print the slice split by numbers divisible by 3 (i.e. `[10, 40]`,
/// `[20]`, `[50]`):
///
/// ```
/// let v = [10, 40, 30, 20, 60, 50];
/// for group in v.split(|num| *num % 3 == 0) {
/// println!("{:?}", group);
/// }
/// ```
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
fn
split
<
F
>
(
&
self
,
pred
:
F
)
->
Split
<
Self
::
Item
,
F
>
where
F
:
FnMut
(
&
Self
::
Item
)
->
bool
;
...
...
@@ -211,6 +232,18 @@ fn split<F>(&self, pred: F) -> Split<Self::Item, F>
/// Returns an iterator over subslices separated by elements that match
/// `pred`, limited to splitting at most `n` times. The matched element is
/// not contained in the subslices.
///
/// # Examples
///
/// Print the slice split once by numbers divisible by 3 (i.e. `[10, 40]`,
/// `[20, 60, 50]`):
///
/// ```
/// let v = [10, 40, 30, 20, 60, 50];
/// for group in v.splitn(1, |num| *num % 3 == 0) {
/// println!("{:?}", group);
/// }
/// ```
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
fn
splitn
<
F
>
(
&
self
,
n
:
uint
,
pred
:
F
)
->
SplitN
<
Self
::
Item
,
F
>
where
F
:
FnMut
(
&
Self
::
Item
)
->
bool
;
...
...
@@ -219,6 +252,18 @@ fn splitn<F>(&self, n: uint, pred: F) -> SplitN<Self::Item, F>
/// `pred` limited to splitting at most `n` times. This starts at the end of
/// the slice and works backwards. The matched element is not contained in
/// the subslices.
///
/// # Examples
///
/// Print the slice split once, starting from the end, by numbers divisible
/// by 3 (i.e. `[50]`, `[10, 40, 30, 20]`):
///
/// ```
/// let v = [10, 40, 30, 20, 60, 50];
/// for group in v.rsplitn(1, |num| *num % 3 == 0) {
/// println!("{:?}", group);
/// }
/// ```
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
fn
rsplitn
<
F
>
(
&
self
,
n
:
uint
,
pred
:
F
)
->
RSplitN
<
Self
::
Item
,
F
>
where
F
:
FnMut
(
&
Self
::
Item
)
->
bool
;
...
...
@@ -270,10 +315,28 @@ fn rsplitn<F>(&self, n: uint, pred: F) -> RSplitN<Self::Item, F>
/// Returns the element of a slice at the given index, or `None` if the
/// index is out of bounds.
///
/// # Examples
///
/// ```
/// let v = [10, 40, 30];
/// assert_eq!(Some(&40), v.get(1));
/// assert_eq!(None, v.get(3));
/// ```
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
fn
get
(
&
self
,
index
:
uint
)
->
Option
<&
Self
::
Item
>
;
/// Returns the first element of a slice, or `None` if it is empty.
///
/// # Examples
///
/// ```
/// let v = [10, 40, 30];
/// assert_eq!(Some(&10), v.first());
///
/// let w: &[i32] = &[];
/// assert_eq!(None, w.first());
/// ```
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
fn
first
(
&
self
)
->
Option
<&
Self
::
Item
>
;
...
...
@@ -286,6 +349,16 @@ fn rsplitn<F>(&self, n: uint, pred: F) -> RSplitN<Self::Item, F>
fn
init
(
&
self
)
->
&
[
Self
::
Item
];
/// Returns the last element of a slice, or `None` if it is empty.
///
/// # Examples
///
/// ```
/// let v = [10, 40, 30];
/// assert_eq!(Some(&30), v.last());
///
/// let w: &[i32] = &[];
/// assert_eq!(None, w.last());
/// ```
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
fn
last
(
&
self
)
->
Option
<&
Self
::
Item
>
;
...
...
@@ -676,15 +749,43 @@ fn binary_search_elem(&self, x: &Self::Item) -> Result<uint, uint> where Self::I
#[unstable(feature
=
"collections"
)]
fn
rposition_elem
(
&
self
,
t
:
&
Self
::
Item
)
->
Option
<
uint
>
where
Self
::
Item
:
PartialEq
;
/// Return true if the slice contains an element with the given value.
/// Returns true if the slice contains an element with the given value.
///
/// # Examples
///
/// ```
/// let v = [10, 40, 30];
/// assert!(v.contains(&30));
/// assert!(!v.contains(&50));
/// ```
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
fn
contains
(
&
self
,
x
:
&
Self
::
Item
)
->
bool
where
Self
::
Item
:
PartialEq
;
/// Returns true if `needle` is a prefix of the slice.
///
/// # Examples
///
/// ```
/// let v = [10, 40, 30];
/// assert!(v.starts_with(&[10]));
/// assert!(v.starts_with(&[10, 40]));
/// assert!(!v.starts_with(&[50]));
/// assert!(!v.starts_with(&[10, 50]));
/// ```
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
fn
starts_with
(
&
self
,
needle
:
&
[
Self
::
Item
])
->
bool
where
Self
::
Item
:
PartialEq
;
/// Returns true if `needle` is a suffix of the slice.
///
/// # Examples
///
/// ```
/// let v = [10, 40, 30];
/// assert!(v.ends_with(&[30]));
/// assert!(v.ends_with(&[40, 30]));
/// assert!(!v.ends_with(&[50]));
/// assert!(!v.ends_with(&[50, 30]));
/// ```
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
fn
ends_with
(
&
self
,
needle
:
&
[
Self
::
Item
])
->
bool
where
Self
::
Item
:
PartialEq
;
...
...
src/libcollections/vec.rs
浏览文件 @
ee0be3b3
...
...
@@ -993,6 +993,43 @@ pub fn map_in_place<U, F>(self, mut f: F) -> Vec<U> where F: FnMut(T) -> U {
result
}
}
/// Splits the collection into two at the given index.
///
/// Returns a newly allocated `Self`. `self` contains elements `[0, at)`,
/// and the returned `Self` contains elements `[at, len)`.
///
/// Note that the capacity of `self` does not change.
///
/// # Examples
/// ```rust
/// let mut vec = vec![1,2,3];
/// let vec2 = vec.split_off(1);
/// assert_eq!(vec, vec![1]);
/// assert_eq!(vec2, vec![2, 3]);
/// ```
#[inline]
#[unstable(feature
=
"collections"
,
reason
=
"new API, waiting for dust to settle"
)]
pub
fn
split_off
(
&
mut
self
,
at
:
usize
)
->
Self
{
assert
!
(
at
<
self
.len
(),
"`at` out of bounds"
);
let
other_len
=
self
.len
-
at
;
let
mut
other
=
Vec
::
with_capacity
(
other_len
);
// Unsafely `set_len` and copy items to `other`.
unsafe
{
self
.set_len
(
at
);
other
.set_len
(
other_len
);
ptr
::
copy_nonoverlapping_memory
(
other
.as_mut_ptr
(),
self
.as_ptr
()
.offset
(
at
as
isize
),
other
.len
());
}
other
}
}
impl
<
T
:
Clone
>
Vec
<
T
>
{
...
...
@@ -1966,7 +2003,7 @@ fn test_extend() {
fn
test_slice_from_mut
()
{
let
mut
values
=
vec!
[
1u8
,
2
,
3
,
4
,
5
];
{
let
slice
=
values
.slice_from_mut
(
2
)
;
let
slice
=
&
mut
values
[
2
..
]
;
assert
!
(
slice
==
[
3
,
4
,
5
]);
for
p
in
slice
.iter_mut
()
{
*
p
+=
2
;
...
...
@@ -1980,7 +2017,7 @@ fn test_slice_from_mut() {
fn
test_slice_to_mut
()
{
let
mut
values
=
vec!
[
1u8
,
2
,
3
,
4
,
5
];
{
let
slice
=
values
.slice_to_mut
(
2
)
;
let
slice
=
&
mut
values
[
..
2
]
;
assert
!
(
slice
==
[
1
,
2
]);
for
p
in
slice
.iter_mut
()
{
*
p
+=
1
;
...
...
@@ -2354,6 +2391,14 @@ fn test_append() {
assert_eq!
(
vec2
,
vec!
[]);
}
#[test]
fn
test_split_off
()
{
let
mut
vec
=
vec!
[
1
,
2
,
3
,
4
,
5
,
6
];
let
vec2
=
vec
.split_off
(
4
);
assert_eq!
(
vec
,
vec!
[
1
,
2
,
3
,
4
]);
assert_eq!
(
vec2
,
vec!
[
5
,
6
]);
}
#[bench]
fn
bench_new
(
b
:
&
mut
Bencher
)
{
b
.iter
(||
{
...
...
src/libcore/nonzero.rs
浏览文件 @
ee0be3b3
...
...
@@ -31,7 +31,7 @@ unsafe impl Zeroable for u64 {}
/// A wrapper type for raw pointers and integers that will never be
/// NULL or 0 that might allow certain optimizations.
#[lang=
"non_zero"
]
#[derive(Copy,
Clone,
Eq,
PartialEq,
Ord,
PartialOrd,
Show)]
#[derive(Copy,
Clone,
Eq,
PartialEq,
Ord,
PartialOrd,
Show
,
Hash
)]
#[unstable(feature
=
"core"
)]
pub
struct
NonZero
<
T
:
Zeroable
>
(
T
);
...
...
src/libcore/ops.rs
浏览文件 @
ee0be3b3
...
...
@@ -449,10 +449,9 @@ fn rem(self, other: $t) -> $t {
/// ```
/// use std::ops::Neg;
///
/// #[derive(Copy)]
/// struct Foo;
///
/// impl Copy for Foo {}
///
/// impl Neg for Foo {
/// type Output = Foo;
///
...
...
@@ -526,10 +525,9 @@ fn neg(self) -> $t { -(self as $t_signed) as $t }
/// ```
/// use std::ops::Not;
///
/// #[derive(Copy)]
/// struct Foo;
///
/// impl Copy for Foo {}
///
/// impl Not for Foo {
/// type Output = Foo;
///
...
...
@@ -899,6 +897,7 @@ fn shr(self, other: $f) -> $t {
/// }
/// ```
#[lang=
"index"
]
#[rustc_on_unimplemented
=
"the type `{Self}` cannot be indexed by `{Index}`"
]
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
trait
Index
<
Index
:
?
Sized
>
{
type
Output
:
?
Sized
;
...
...
@@ -937,6 +936,7 @@ pub trait Index<Index: ?Sized> {
/// }
/// ```
#[lang=
"index_mut"
]
#[rustc_on_unimplemented
=
"the type `{Self}` cannot be mutably indexed by `{Index}`"
]
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
trait
IndexMut
<
Index
:
?
Sized
>
{
type
Output
:
?
Sized
;
...
...
src/librustc_llvm/diagnostic.rs
浏览文件 @
ee0be3b3
...
...
@@ -37,6 +37,8 @@ pub fn describe(self) -> &'static str {
}
}
#[allow(raw_pointer_derive)]
#[derive(Copy)]
pub
struct
OptimizationDiagnostic
{
pub
kind
:
OptimizationDiagnosticKind
,
pub
pass_name
:
*
const
c_char
,
...
...
@@ -45,8 +47,6 @@ pub struct OptimizationDiagnostic {
pub
message
:
TwineRef
,
}
impl
Copy
for
OptimizationDiagnostic
{}
impl
OptimizationDiagnostic
{
unsafe
fn
unpack
(
kind
:
OptimizationDiagnosticKind
,
di
:
DiagnosticInfoRef
)
->
OptimizationDiagnostic
{
...
...
src/librustdoc/html/static/main.css
浏览文件 @
ee0be3b3
...
...
@@ -64,7 +64,6 @@
body
{
color
:
#333
;
min-width
:
500px
;
font
:
16px
/
1.4
"Source Serif Pro"
,
"Helvetica Neue"
,
Helvetica
,
Arial
,
sans-serif
;
margin
:
0
;
position
:
relative
;
...
...
@@ -592,6 +591,14 @@ pre.rust { position: relative; }
margin-left
:
0px
;
}
.content
.in-band
{
width
:
100%
;
}
.content
.out-of-band
{
display
:
none
;
}
.toggle-wrapper
>
.collapse-toggle
{
left
:
0px
;
}
...
...
src/libstd/os.rs
浏览文件 @
ee0be3b3
...
...
@@ -815,6 +815,8 @@ pub struct MemoryMap {
}
/// Type of memory map
#[allow(raw_pointer_derive)]
#[derive(Copy)]
pub
enum
MemoryMapKind
{
/// Virtual memory map. Usually used to change the permissions of a given
/// chunk of memory. Corresponds to `VirtualAlloc` on Windows.
...
...
@@ -825,9 +827,9 @@ pub enum MemoryMapKind {
MapVirtual
}
impl
Copy
for
MemoryMapKind
{}
/// Options the memory map is created with
#[allow(raw_pointer_derive)]
#[derive(Copy)]
pub
enum
MapOption
{
/// The memory should be readable
MapReadable
,
...
...
@@ -854,8 +856,6 @@ pub enum MapOption {
MapNonStandardFlags
(
c_int
),
}
impl
Copy
for
MapOption
{}
/// Possible errors when creating a map.
#[derive(Copy,
Show)]
pub
enum
MapError
{
...
...
src/libstd/rand/mod.rs
浏览文件 @
ee0be3b3
...
...
@@ -99,10 +99,10 @@
//! let between = Range::new(-1f64, 1.);
//! let mut rng = rand::thread_rng();
//!
//! let total = 1_000_000
u
;
//! let mut in_circle = 0
u
;
//! let total = 1_000_000;
//! let mut in_circle = 0;
//!
//! for _ in range(0
u
, total) {
//! for _ in range(0, total) {
//! let a = between.ind_sample(&mut rng);
//! let b = between.ind_sample(&mut rng);
//! if a*a + b*b <= 1. {
...
...
@@ -176,18 +176,18 @@
//! }
//!
//! fn free_doors(blocked: &[uint]) -> Vec<uint> {
//! range(0
u
, 3).filter(|x| !blocked.contains(x)).collect()
//! range(0, 3).filter(|x| !blocked.contains(x)).collect()
//! }
//!
//! fn main() {
//! // The estimation will be more accurate with more simulations
//! let num_simulations = 10000
u
;
//! let num_simulations = 10000;
//!
//! let mut rng = rand::thread_rng();
//! let random_door = Range::new(0
u
, 3);
//! let random_door = Range::new(0, 3);
//!
//! let (mut switch_wins, mut switch_losses) = (0
u, 0u
);
//! let (mut keep_wins, mut keep_losses) = (0
u, 0u
);
//! let (mut switch_wins, mut switch_losses) = (0
, 0
);
//! let (mut keep_wins, mut keep_losses) = (0
, 0
);
//!
//! println!("Running {} simulations...", num_simulations);
//! for _ in range(0, num_simulations) {
...
...
@@ -279,14 +279,14 @@ fn next_u64(&mut self) -> u64 {
}
}
impl
<
'a
>
SeedableRng
<&
'a
[
u
int
]
>
for
StdRng
{
fn
reseed
(
&
mut
self
,
seed
:
&
'a
[
u
int
])
{
impl
<
'a
>
SeedableRng
<&
'a
[
u
size
]
>
for
StdRng
{
fn
reseed
(
&
mut
self
,
seed
:
&
'a
[
u
size
])
{
// the internal RNG can just be seeded from the above
// randomness.
self
.rng
.reseed
(
unsafe
{
mem
::
transmute
(
seed
)})
}
fn
from_seed
(
seed
:
&
'a
[
u
int
])
->
StdRng
{
fn
from_seed
(
seed
:
&
'a
[
u
size
])
->
StdRng
{
StdRng
{
rng
:
SeedableRng
::
from_seed
(
unsafe
{
mem
::
transmute
(
seed
)})
}
}
}
...
...
@@ -318,7 +318,7 @@ fn reseed(&mut self, rng: &mut StdRng) {
}
}
}
static
THREAD_RNG_RESEED_THRESHOLD
:
u
int
=
32_768
;
static
THREAD_RNG_RESEED_THRESHOLD
:
u
size
=
32_768
;
type
ThreadRngInner
=
reseeding
::
ReseedingRng
<
StdRng
,
ThreadRngReseeder
>
;
/// The thread-local RNG.
...
...
@@ -384,7 +384,7 @@ fn fill_bytes(&mut self, bytes: &mut [u8]) {
/// use std::rand;
///
/// let x = rand::random();
/// println!("{}", 2u * x);
/// println!("{}", 2u
8
* x);
///
/// let y = rand::random::<f64>();
/// println!("{}", y);
...
...
@@ -432,7 +432,7 @@ pub fn random<T: Rand>() -> T {
/// ```
pub
fn
sample
<
T
,
I
:
Iterator
<
Item
=
T
>
,
R
:
Rng
>
(
rng
:
&
mut
R
,
mut
iter
:
I
,
amount
:
u
int
)
->
Vec
<
T
>
{
amount
:
u
size
)
->
Vec
<
T
>
{
let
mut
reservoir
:
Vec
<
T
>
=
iter
.by_ref
()
.take
(
amount
)
.collect
();
for
(
i
,
elem
)
in
iter
.enumerate
()
{
let
k
=
rng
.gen_range
(
0
,
i
+
1
+
amount
);
...
...
@@ -480,18 +480,18 @@ fn test_fill_bytes_default() {
#[test]
fn
test_gen_range
()
{
let
mut
r
=
thread_rng
();
for
_
in
range
(
0
u
,
1000
)
{
for
_
in
range
(
0
,
1000
)
{
let
a
=
r
.gen_range
(
-
3
i
,
42
);
assert
!
(
a
>=
-
3
&&
a
<
42
);
assert_eq!
(
r
.gen_range
(
0
i
,
1
),
0
);
assert_eq!
(
r
.gen_range
(
-
12
i
,
-
11
),
-
12
);
}
for
_
in
range
(
0
u
,
1000
)
{
for
_
in
range
(
0
,
1000
)
{
let
a
=
r
.gen_range
(
10
i
,
42
);
assert
!
(
a
>=
10
&&
a
<
42
);
assert_eq!
(
r
.gen_range
(
0
i
,
1
),
0
);
assert_eq!
(
r
.gen_range
(
3_000_000
u
,
3_000_001
),
3_000_000
);
assert_eq!
(
r
.gen_range
(
3_000_000
,
3_000_001
),
3_000_000
);
}
}
...
...
@@ -507,7 +507,7 @@ fn test_gen_range_panic_int() {
#[should_fail]
fn
test_gen_range_panic_uint
()
{
let
mut
r
=
thread_rng
();
r
.gen_range
(
5u
,
2u
);
r
.gen_range
(
5u
s
,
2u
s
);
}
#[test]
...
...
@@ -521,24 +521,24 @@ fn test_gen_f64() {
#[test]
fn
test_gen_weighted_bool
()
{
let
mut
r
=
thread_rng
();
assert_eq!
(
r
.gen_weighted_bool
(
0
u
),
true
);
assert_eq!
(
r
.gen_weighted_bool
(
1
u
),
true
);
assert_eq!
(
r
.gen_weighted_bool
(
0
),
true
);
assert_eq!
(
r
.gen_weighted_bool
(
1
),
true
);
}
#[test]
fn
test_gen_ascii_str
()
{
let
mut
r
=
thread_rng
();
assert_eq!
(
r
.gen_ascii_chars
()
.take
(
0
)
.count
(),
0
u
);
assert_eq!
(
r
.gen_ascii_chars
()
.take
(
10
)
.count
(),
10
u
);
assert_eq!
(
r
.gen_ascii_chars
()
.take
(
16
)
.count
(),
16
u
);
assert_eq!
(
r
.gen_ascii_chars
()
.take
(
0
)
.count
(),
0
);
assert_eq!
(
r
.gen_ascii_chars
()
.take
(
10
)
.count
(),
10
);
assert_eq!
(
r
.gen_ascii_chars
()
.take
(
16
)
.count
(),
16
);
}
#[test]
fn
test_gen_vec
()
{
let
mut
r
=
thread_rng
();
assert_eq!
(
r
.gen_iter
::
<
u8
>
()
.take
(
0
)
.count
(),
0
u
);
assert_eq!
(
r
.gen_iter
::
<
u8
>
()
.take
(
10
)
.count
(),
10
u
);
assert_eq!
(
r
.gen_iter
::
<
f64
>
()
.take
(
16
)
.count
(),
16
u
);
assert_eq!
(
r
.gen_iter
::
<
u8
>
()
.take
(
0
)
.count
(),
0
);
assert_eq!
(
r
.gen_iter
::
<
u8
>
()
.take
(
10
)
.count
(),
10
);
assert_eq!
(
r
.gen_iter
::
<
f64
>
()
.take
(
16
)
.count
(),
16
);
}
#[test]
...
...
@@ -578,7 +578,7 @@ fn test_thread_rng() {
r
.shuffle
(
&
mut
v
);
let
b
:
&
[
_
]
=
&
[
1
,
1
,
1
];
assert_eq!
(
v
,
b
);
assert_eq!
(
r
.gen_range
(
0
u
,
1u
),
0u
);
assert_eq!
(
r
.gen_range
(
0
,
1
),
0
);
}
#[test]
...
...
src/libstd/rand/os.rs
浏览文件 @
ee0be3b3
...
...
@@ -49,7 +49,7 @@ fn getrandom(buf: &mut [u8]) -> libc::c_long {
const
NR_GETRANDOM
:
libc
::
c_long
=
384
;
unsafe
{
syscall
(
NR_GETRANDOM
,
buf
.as_mut_ptr
(),
buf
.len
(),
0
u
)
syscall
(
NR_GETRANDOM
,
buf
.as_mut_ptr
(),
buf
.len
(),
0
)
}
}
...
...
@@ -74,7 +74,7 @@ fn getrandom_fill_bytes(v: &mut [u8]) {
panic!
(
"unexpected getrandom error: {}"
,
err
);
}
}
else
{
read
+=
result
as
u
int
;
read
+=
result
as
u
size
;
}
}
}
...
...
@@ -378,7 +378,7 @@ fn test_os_rng() {
fn
test_os_rng_tasks
()
{
let
mut
txs
=
vec!
();
for
_
in
range
(
0
u
,
20
)
{
for
_
in
range
(
0
,
20
)
{
let
(
tx
,
rx
)
=
channel
();
txs
.push
(
tx
);
...
...
@@ -392,7 +392,7 @@ fn test_os_rng_tasks() {
Thread
::
yield_now
();
let
mut
v
=
[
0u8
;
1000
];
for
_
in
range
(
0
u
,
100
)
{
for
_
in
range
(
0
,
100
)
{
r
.next_u32
();
Thread
::
yield_now
();
r
.next_u64
();
...
...
src/libunicode/lib.rs
浏览文件 @
ee0be3b3
...
...
@@ -83,4 +83,5 @@ mod std {
pub
use
core
::
clone
;
pub
use
core
::
cmp
;
pub
use
core
::
fmt
;
pub
use
core
::
marker
;
}
src/libunicode/tables.rs
浏览文件 @
ee0be3b3
...
...
@@ -7801,13 +7801,12 @@ pub fn width(c: char, is_cjk: bool) -> Option<uint> {
}
pub mod grapheme {
use core::marker::Copy;
use core::slice::SliceExt;
pub use self::GraphemeCat::*;
use core::result::Result::{Ok, Err};
#[allow(non_camel_case_types)]
#[derive(Clone)]
#[derive(Clone
, Copy
)]
pub enum GraphemeCat {
GC_LV,
GC_LVT,
...
...
@@ -7821,8 +7820,6 @@ pub enum GraphemeCat {
GC_Any,
}
impl Copy for GraphemeCat {}
fn bsearch_range_value_table(c: char, r: &'static [(char, char, GraphemeCat)]) -> GraphemeCat {
use core::cmp::Ordering::{Equal, Less, Greater};
match r.binary_search_by(|&(lo, hi, _)| {
...
...
src/libunicode/u_str.rs
浏览文件 @
ee0be3b3
...
...
@@ -410,7 +410,7 @@ pub struct Utf16Items<'a> {
iter
:
slice
::
Iter
<
'a
,
u16
>
}
/// The possibilities for values decoded from a `u16` stream.
#[derive(PartialEq,
Eq,
Clone,
Show)]
#[derive(
Copy,
PartialEq,
Eq,
Clone,
Show)]
pub
enum
Utf16Item
{
/// A valid codepoint.
ScalarValue
(
char
),
...
...
@@ -418,8 +418,6 @@ pub enum Utf16Item {
LoneSurrogate
(
u16
)
}
impl
Copy
for
Utf16Item
{}
impl
Utf16Item
{
/// Convert `self` to a `char`, taking `LoneSurrogate`s to the
/// replacement character (U+FFFD).
...
...
src/test/auxiliary/issue-14422.rs
浏览文件 @
ee0be3b3
...
...
@@ -23,10 +23,9 @@ pub mod aliases {
pub
mod
hidden_core
{
use
super
::
aliases
::
B
;
#[derive(Copy)]
pub
struct
A
;
impl
Copy
for
A
{}
pub
fn
make
()
->
B
{
A
}
impl
A
{
...
...
src/test/auxiliary/issue13213aux.rs
浏览文件 @
ee0be3b3
...
...
@@ -13,19 +13,18 @@
pub
use
private
::
P
;
#[derive(Copy)]
pub
struct
S
{
p
:
P
,
}
mod
private
{
#[derive(Copy)]
pub
struct
P
{
p
:
i32
,
}
pub
const
THREE
:
P
=
P
{
p
:
3
};
impl
Copy
for
P
{}
}
pub
static
A
:
S
=
S
{
p
:
private
::
THREE
};
impl
Copy
for
S
{}
src/test/auxiliary/method_self_arg1.rs
浏览文件 @
ee0be3b3
...
...
@@ -17,10 +17,9 @@
pub
fn
get_count
()
->
u64
{
unsafe
{
COUNT
}
}
#[derive(Copy)]
pub
struct
Foo
;
impl
Copy
for
Foo
{}
impl
Foo
{
pub
fn
foo
(
self
,
x
:
&
Foo
)
{
unsafe
{
COUNT
*=
2
;
}
...
...
src/test/auxiliary/method_self_arg2.rs
浏览文件 @
ee0be3b3
...
...
@@ -17,10 +17,9 @@
pub
fn
get_count
()
->
u64
{
unsafe
{
COUNT
}
}
#[derive(Copy)]
pub
struct
Foo
;
impl
Copy
for
Foo
{}
impl
Foo
{
pub
fn
run_trait
(
self
)
{
unsafe
{
COUNT
*=
17
;
}
...
...
src/test/auxiliary/xcrate_unit_struct.rs
浏览文件 @
ee0be3b3
...
...
@@ -12,33 +12,28 @@
// used by the rpass test
#[derive(Copy)]
pub
struct
Struct
;
impl
Copy
for
Struct
{}
#[derive(Copy)]
pub
enum
Unit
{
UnitVariant
,
Argument
(
Struct
)
}
impl
Copy
for
Unit
{}
#[derive(Copy)]
pub
struct
TupleStruct
(
pub
uint
,
pub
&
'static
str
);
impl
Copy
for
TupleStruct
{}
// used by the cfail test
#[derive(Copy)]
pub
struct
StructWithFields
{
foo
:
int
,
}
impl
Copy
for
StructWithFields
{}
#[derive(Copy)]
pub
enum
EnumWithVariants
{
EnumVariant
,
EnumVariantArg
(
int
)
}
impl
Copy
for
EnumWithVariants
{}
src/test/bench/noise.rs
浏览文件 @
ee0be3b3
...
...
@@ -16,13 +16,12 @@
use
std
::
num
::
Float
;
use
std
::
rand
::{
Rng
,
StdRng
};
#[derive(Copy)]
struct
Vec2
{
x
:
f32
,
y
:
f32
,
}
impl
Copy
for
Vec2
{}
fn
lerp
(
a
:
f32
,
b
:
f32
,
v
:
f32
)
->
f32
{
a
*
(
1.0
-
v
)
+
b
*
v
}
fn
smooth
(
v
:
f32
)
->
f32
{
v
*
v
*
(
3.0
-
2.0
*
v
)
}
...
...
src/test/bench/shootout-chameneos-redux.rs
浏览文件 @
ee0be3b3
...
...
@@ -54,14 +54,13 @@ fn print_complements() {
}
}
#[derive(Copy)]
enum
Color
{
Red
,
Yellow
,
Blue
,
}
impl
Copy
for
Color
{}
impl
fmt
::
Show
for
Color
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
let
str
=
match
*
self
{
...
...
@@ -73,13 +72,12 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
}
}
#[derive(Copy)]
struct
CreatureInfo
{
name
:
uint
,
color
:
Color
}
impl
Copy
for
CreatureInfo
{}
fn
show_color_list
(
set
:
Vec
<
Color
>
)
->
String
{
let
mut
out
=
String
::
new
();
for
col
in
set
.iter
()
{
...
...
src/test/bench/shootout-fannkuch-redux.rs
浏览文件 @
ee0be3b3
...
...
@@ -61,12 +61,12 @@ fn next_permutation(perm: &mut [i32], count: &mut [i32]) {
}
}
#[derive(Copy)]
struct
P
{
p
:
[
i32
;
16
],
}
impl
Copy
for
P
{}
#[derive(Copy)]
struct
Perm
{
cnt
:
[
i32
;
16
],
fact
:
[
u32
;
16
],
...
...
@@ -75,8 +75,6 @@ struct Perm {
perm
:
P
,
}
impl
Copy
for
Perm
{}
impl
Perm
{
fn
new
(
n
:
u32
)
->
Perm
{
let
mut
fact
=
[
1
;
16
];
...
...
src/test/bench/shootout-fasta-redux.rs
浏览文件 @
ee0be3b3
...
...
@@ -103,13 +103,12 @@ fn sum_and_scale(a: &'static [AminoAcid]) -> Vec<AminoAcid> {
result
}
#[derive(Copy)]
struct
AminoAcid
{
c
:
u8
,
p
:
f32
,
}
impl
Copy
for
AminoAcid
{}
struct
RepeatFasta
<
'a
,
W
:
'a
>
{
alu
:
&
'static
str
,
out
:
&
'a
mut
W
...
...
src/test/bench/shootout-k-nucleotide.rs
浏览文件 @
ee0be3b3
...
...
@@ -60,11 +60,9 @@
// Code implementation
#[derive(PartialEq,
PartialOrd,
Ord,
Eq)]
#[derive(
Copy,
PartialEq,
PartialOrd,
Ord,
Eq)]
struct
Code
(
u64
);
impl
Copy
for
Code
{}
impl
Code
{
fn
hash
(
&
self
)
->
u64
{
let
Code
(
ret
)
=
*
self
;
...
...
src/test/bench/shootout-nbody.rs
浏览文件 @
ee0be3b3
...
...
@@ -94,14 +94,13 @@
},
];
#[derive(Copy)]
struct
Planet
{
x
:
f64
,
y
:
f64
,
z
:
f64
,
vx
:
f64
,
vy
:
f64
,
vz
:
f64
,
mass
:
f64
,
}
impl
Copy
for
Planet
{}
fn
advance
(
bodies
:
&
mut
[
Planet
;
N_BODIES
],
dt
:
f64
,
steps
:
int
)
{
for
_
in
range
(
0
,
steps
)
{
let
mut
b_slice
=
bodies
.as_mut_slice
();
...
...
src/test/bench/task-perf-one-million.rs
已删除
100644 → 0
浏览文件 @
a45e1177
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test for concurrent tasks
// ignore-test OOM on linux-32 without opts
use
std
::
os
;
use
std
::
task
;
use
std
::
uint
;
use
std
::
slice
;
fn
calc
(
children
:
uint
,
parent_wait_chan
:
&
Sender
<
Sender
<
Sender
<
int
>>>
)
{
let
wait_ports
:
Vec
<
Reciever
<
Sender
<
Sender
<
int
>>>>
=
vec
::
from_fn
(
children
,
|
_
|
{
let
(
wait_port
,
wait_chan
)
=
stream
::
<
Sender
<
Sender
<
int
>>>
();
task
::
spawn
(
move
||
{
calc
(
children
/
2
,
&
wait_chan
);
});
wait_port
});
let
child_start_chans
:
Vec
<
Sender
<
Sender
<
int
>>>
=
wait_ports
.into_iter
()
.map
(|
port
|
port
.recv
())
.collect
();
let
(
start_port
,
start_chan
)
=
stream
::
<
Sender
<
int
>>
();
parent_wait_chan
.send
(
start_chan
);
let
parent_result_chan
:
Sender
<
int
>
=
start_port
.recv
();
let
child_sum_ports
:
Vec
<
Reciever
<
int
>>
=
child_start_chans
.into_iter
()
.map
(|
child_start_chan
|
{
let
(
child_sum_port
,
child_sum_chan
)
=
stream
::
<
int
>
();
child_start_chan
.send
(
child_sum_chan
);
child_sum_port
})
.collect
();
let
sum
=
child_sum_ports
.into_iter
()
.fold
(
0
,
|
sum
,
sum_port
|
sum
+
sum_port
.recv
()
);
parent_result_chan
.send
(
sum
+
1
);
}
fn
main
()
{
let
args
=
os
::
args
();
let
args
=
if
os
::
getenv
(
"RUST_BENCH"
)
.is_some
()
{
vec!
(
""
.to_string
(),
"30"
.to_string
())
}
else
if
args
.len
()
<=
1u
{
vec!
(
""
.to_string
(),
"10"
.to_string
())
}
else
{
args
};
let
children
=
from_str
::
<
uint
>
(
args
[
1
])
.unwrap
();
let
(
wait_port
,
wait_chan
)
=
stream
();
task
::
spawn
(
move
||
{
calc
(
children
,
&
wait_chan
);
});
let
start_chan
=
wait_port
.recv
();
let
(
sum_port
,
sum_chan
)
=
stream
::
<
int
>
();
start_chan
.send
(
sum_chan
);
let
sum
=
sum_port
.recv
();
println!
(
"How many tasks? {} tasks."
,
sum
);
}
src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs
浏览文件 @
ee0be3b3
...
...
@@ -9,20 +9,18 @@
// except according to those terms.
#[derive(Copy)]
struct
Foo
{
bar1
:
Bar
,
bar2
:
Bar
}
impl
Copy
for
Foo
{}
#[derive(Copy)]
struct
Bar
{
int1
:
isize
,
int2
:
isize
,
}
impl
Copy
for
Bar
{}
fn
make_foo
()
->
Box
<
Foo
>
{
panic!
()
}
fn
borrow_same_field_twice_mut_mut
()
{
...
...
src/test/compile-fail/borrowck-borrow-from-stack-variable.rs
浏览文件 @
ee0be3b3
...
...
@@ -8,20 +8,18 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[derive(Copy)]
struct
Foo
{
bar1
:
Bar
,
bar2
:
Bar
}
impl
Copy
for
Foo
{}
#[derive(Copy)]
struct
Bar
{
int1
:
isize
,
int2
:
isize
,
}
impl
Copy
for
Bar
{}
fn
make_foo
()
->
Foo
{
panic!
()
}
fn
borrow_same_field_twice_mut_mut
()
{
...
...
src/test/compile-fail/borrowck-use-mut-borrow.rs
浏览文件 @
ee0be3b3
...
...
@@ -10,10 +10,9 @@
#![feature(box_syntax)]
#[derive(Copy)]
struct
A
{
a
:
isize
,
b
:
isize
}
impl
Copy
for
A
{}
struct
B
{
a
:
isize
,
b
:
Box
<
isize
>
}
fn
var_copy_after_var_borrow
()
{
...
...
src/test/compile-fail/dst-index.rs
浏览文件 @
ee0be3b3
...
...
@@ -14,10 +14,9 @@
use
std
::
ops
::
Index
;
use
std
::
fmt
::
Debug
;
#[derive(Copy)]
struct
S
;
impl
Copy
for
S
{}
impl
Index
<
usize
>
for
S
{
type
Output
=
str
;
...
...
@@ -26,10 +25,9 @@ fn index<'a>(&'a self, _: &usize) -> &'a str {
}
}
#[derive(Copy)]
struct
T
;
impl
Copy
for
T
{}
impl
Index
<
usize
>
for
T
{
type
Output
=
Debug
+
'static
;
...
...
src/test/compile-fail/kindck-copy.rs
浏览文件 @
ee0be3b3
...
...
@@ -17,13 +17,12 @@ fn assert_copy<T:Copy>() { }
trait
Dummy
{
}
#[derive(Copy)]
struct
MyStruct
{
x
:
isize
,
y
:
isize
,
}
impl
Copy
for
MyStruct
{}
struct
MyNoncopyStruct
{
x
:
Box
<
char
>
,
}
...
...
src/test/debuginfo/generic-method-on-generic-struct.rs
浏览文件 @
ee0be3b3
...
...
@@ -115,6 +115,7 @@
#![feature(box_syntax)]
#![omit_gdb_pretty_printer_section]
#[derive(Copy)]
struct
Struct
<
T
>
{
x
:
T
}
...
...
@@ -150,5 +151,3 @@ fn main() {
fn
zzz
()
{()}
impl
<
T
:
Copy
>
Copy
for
Struct
<
T
>
{}
src/test/debuginfo/method-on-enum.rs
浏览文件 @
ee0be3b3
...
...
@@ -116,6 +116,7 @@
#![feature(box_syntax)]
#![omit_gdb_pretty_printer_section]
#[derive(Copy)]
enum
Enum
{
Variant1
{
x
:
u16
,
y
:
u16
},
Variant2
(
u32
)
...
...
@@ -152,5 +153,3 @@ fn main() {
fn
zzz
()
{()}
impl
Copy
for
Enum
{}
src/test/debuginfo/method-on-generic-struct.rs
浏览文件 @
ee0be3b3
...
...
@@ -116,6 +116,7 @@
#![feature(box_syntax)]
#![omit_gdb_pretty_printer_section]
#[derive(Copy)]
struct
Struct
<
T
>
{
x
:
T
}
...
...
@@ -151,5 +152,3 @@ fn main() {
fn
zzz
()
{()}
impl
<
T
:
Copy
>
Copy
for
Struct
<
T
>
{}
src/test/debuginfo/method-on-struct.rs
浏览文件 @
ee0be3b3
...
...
@@ -116,6 +116,7 @@
#![feature(box_syntax)]
#![omit_gdb_pretty_printer_section]
#[derive(Copy)]
struct
Struct
{
x
:
int
}
...
...
@@ -151,5 +152,3 @@ fn main() {
fn
zzz
()
{()}
impl
Copy
for
Struct
{}
src/test/debuginfo/method-on-trait.rs
浏览文件 @
ee0be3b3
...
...
@@ -116,6 +116,7 @@
#![feature(box_syntax)]
#![omit_gdb_pretty_printer_section]
#[derive(Copy)]
struct
Struct
{
x
:
int
}
...
...
@@ -157,5 +158,3 @@ fn main() {
fn
zzz
()
{()}
impl
Copy
for
Struct
{}
src/test/debuginfo/method-on-tuple-struct.rs
浏览文件 @
ee0be3b3
...
...
@@ -116,6 +116,7 @@
#![feature(box_syntax)]
#![omit_gdb_pretty_printer_section]
#[derive(Copy)]
struct
TupleStruct
(
int
,
f64
);
impl
TupleStruct
{
...
...
@@ -149,5 +150,3 @@ fn main() {
fn
zzz
()
{()}
impl
Copy
for
TupleStruct
{}
src/test/debuginfo/self-in-default-method.rs
浏览文件 @
ee0be3b3
...
...
@@ -115,6 +115,7 @@
#![feature(box_syntax)]
#![omit_gdb_pretty_printer_section]
#[derive(Copy)]
struct
Struct
{
x
:
int
}
...
...
@@ -151,5 +152,3 @@ fn main() {
fn
zzz
()
{()}
impl
Copy
for
Struct
{}
src/test/debuginfo/self-in-generic-default-method.rs
浏览文件 @
ee0be3b3
...
...
@@ -115,6 +115,7 @@
#![feature(box_syntax)]
#![omit_gdb_pretty_printer_section]
#[derive(Copy)]
struct
Struct
{
x
:
int
}
...
...
@@ -152,5 +153,3 @@ fn main() {
fn
zzz
()
{()}
impl
Copy
for
Struct
{}
src/test/pretty/block-disambig.rs
浏览文件 @
ee0be3b3
...
...
@@ -19,10 +19,9 @@
fn
test2
()
->
int
{
let
val
=
&
0
i
;
{
}
*
val
}
#[derive(Copy)]
struct
S
{
eax
:
int
}
impl
Copy
for
S
{}
fn
test3
()
{
let
regs
=
&
Cell
::
new
(
S
{
eax
:
0
});
match
true
{
true
=>
{
}
_
=>
{
}
}
...
...
src/test/run-make/extern-fn-with-packed-struct/test.rs
浏览文件 @
ee0be3b3
...
...
@@ -9,15 +9,13 @@
// except according to those terms.
#[repr(packed)]
#[derive(PartialEq,
Show)]
#[derive(
Copy,
PartialEq,
Show)]
struct
Foo
{
a
:
i8
,
b
:
i16
,
c
:
i8
}
impl
Copy
for
Foo
{}
#[link(name
=
"test"
,
kind
=
"static"
)]
extern
{
fn
foo
(
f
:
Foo
)
->
Foo
;
...
...
src/test/run-pass/borrowck-univariant-enum.rs
浏览文件 @
ee0be3b3
...
...
@@ -11,12 +11,11 @@
use
std
::
cell
::
Cell
;
#[derive(Copy)]
enum
newtype
{
newvar
(
int
)
}
impl
Copy
for
newtype
{}
pub
fn
main
()
{
// Test that borrowck treats enums with a single variant
...
...
src/test/run-pass/builtin-superkinds-in-metadata.rs
浏览文件 @
ee0be3b3
...
...
@@ -17,10 +17,9 @@
use
trait_superkinds_in_metadata
::{
RequiresRequiresShareAndSend
,
RequiresShare
};
use
trait_superkinds_in_metadata
::{
RequiresCopy
};
#[derive(Copy)]
struct
X
<
T
>
(
T
);
impl
<
T
:
Copy
>
Copy
for
X
<
T
>
{}
impl
<
T
:
Sync
>
RequiresShare
for
X
<
T
>
{
}
impl
<
T
:
Sync
+
Send
>
RequiresRequiresShareAndSend
for
X
<
T
>
{
}
...
...
src/test/run-pass/cell-does-not-clone.rs
浏览文件 @
ee0be3b3
...
...
@@ -10,6 +10,7 @@
use
std
::
cell
::
Cell
;
#[derive(Copy)]
struct
Foo
{
x
:
int
}
...
...
@@ -24,8 +25,6 @@ fn clone(&self) -> Foo {
}
}
impl
Copy
for
Foo
{}
pub
fn
main
()
{
let
x
=
Cell
::
new
(
Foo
{
x
:
22
});
let
_
y
=
x
.get
();
...
...
src/test/run-pass/class-impl-very-parameterized-trait.rs
浏览文件 @
ee0be3b3
...
...
@@ -11,11 +11,9 @@
use
std
::
cmp
;
#[derive(Show)]
#[derive(
Copy,
Show)]
enum
cat_type
{
tuxedo
,
tabby
,
tortoiseshell
}
impl
Copy
for
cat_type
{}
impl
cmp
::
PartialEq
for
cat_type
{
fn
eq
(
&
self
,
other
:
&
cat_type
)
->
bool
{
((
*
self
)
as
uint
)
==
((
*
other
)
as
uint
)
...
...
src/test/run-pass/coherence-impl-in-fn.rs
浏览文件 @
ee0be3b3
...
...
@@ -9,8 +9,8 @@
// except according to those terms.
pub
fn
main
()
{
#[derive(Copy)]
enum
x
{
foo
}
impl
Copy
for
x
{}
impl
::
std
::
cmp
::
PartialEq
for
x
{
fn
eq
(
&
self
,
other
:
&
x
)
->
bool
{
(
*
self
)
as
int
==
(
*
other
)
as
int
...
...
src/test/run-pass/coherence-where-clause.rs
浏览文件 @
ee0be3b3
...
...
@@ -23,13 +23,11 @@ fn get(&self) -> T {
}
}
#[derive(Clone,
Debug,
PartialEq)]
#[derive(Clone,
Copy,
Debug,
PartialEq)]
struct
MyType
{
dummy
:
uint
}
impl
Copy
for
MyType
{}
impl
MyTrait
for
MyType
{
fn
get
(
&
self
)
->
MyType
{
(
*
self
)
.clone
()
}
}
...
...
src/test/run-pass/const-nullary-univariant-enum.rs
浏览文件 @
ee0be3b3
...
...
@@ -8,12 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[derive(Copy)]
enum
Foo
{
Bar
=
0xDEADBEE
}
impl
Copy
for
Foo
{}
static
X
:
Foo
=
Foo
::
Bar
;
pub
fn
main
()
{
...
...
src/test/run-pass/dst-struct-sole.rs
浏览文件 @
ee0be3b3
...
...
@@ -30,11 +30,9 @@ fn foo2<T:ToBar>(x: &Fat<[T]>) {
assert
!
(
x
.ptr
[
1
]
.to_bar
()
==
bar
);
}
#[derive(
PartialEq,
Eq)]
#[derive(
Copy,
PartialEq,
Eq)]
struct
Bar
;
impl
Copy
for
Bar
{}
trait
ToBar
{
fn
to_bar
(
&
self
)
->
Bar
;
}
...
...
src/test/run-pass/dst-struct.rs
浏览文件 @
ee0be3b3
...
...
@@ -49,11 +49,9 @@ fn foo3(x: &Fat<Fat<[int]>>) {
}
#[derive(
PartialEq,
Eq)]
#[derive(
Copy,
PartialEq,
Eq)]
struct
Bar
;
impl
Copy
for
Bar
{}
trait
ToBar
{
fn
to_bar
(
&
self
)
->
Bar
;
}
...
...
src/test/run-pass/dst-trait.rs
浏览文件 @
ee0be3b3
...
...
@@ -17,18 +17,14 @@ struct Fat<T: ?Sized> {
ptr
:
T
}
#[derive(
PartialEq,
Eq)]
#[derive(
Copy,
PartialEq,
Eq)]
struct
Bar
;
impl
Copy
for
Bar
{}
#[derive(PartialEq,Eq)]
#[derive(Copy,
PartialEq,
Eq)]
struct
Bar1
{
f
:
int
}
impl
Copy
for
Bar1
{}
trait
ToBar
{
fn
to_bar
(
&
self
)
->
Bar
;
fn
to_val
(
&
self
)
->
int
;
...
...
src/test/run-pass/empty-tag.rs
浏览文件 @
ee0be3b3
...
...
@@ -8,11 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[derive(Show)]
#[derive(
Copy,
Show)]
enum
chan
{
chan_t
,
}
impl
Copy
for
chan
{}
impl
PartialEq
for
chan
{
fn
eq
(
&
self
,
other
:
&
chan
)
->
bool
{
((
*
self
)
as
uint
)
==
((
*
other
)
as
uint
)
...
...
src/test/run-pass/enum-discrim-width-stuff.rs
浏览文件 @
ee0be3b3
...
...
@@ -12,13 +12,12 @@
(
$m:ident
,
$t:ty
,
$v:expr
)
=>
{{
mod
$m
{
use
std
::
mem
::
size_of
;
#[derive(Show)]
#[derive(
Copy,
Show)]
enum
E
{
V
=
$v
,
A
=
0
}
static
C
:
E
=
E
::
V
;
impl
Copy
for
E
{}
pub
fn
check
()
{
assert_eq!
(
size_of
::
<
E
>
(),
size_of
::
<
$t
>
());
assert_eq!
(
E
::
V
as
$t
,
$v
as
$t
);
...
...
src/test/run-pass/explicit-self-generic.rs
浏览文件 @
ee0be3b3
...
...
@@ -11,10 +11,9 @@
#![allow(unknown_features)]
#![feature(box_syntax)]
#[derive(Copy)]
struct
LM
{
resize_at
:
uint
,
size
:
uint
}
impl
Copy
for
LM
{}
enum
HashMap
<
K
,
V
>
{
HashMap_
(
LM
)
}
...
...
src/test/run-pass/export-unexported-dep.rs
浏览文件 @
ee0be3b3
...
...
@@ -13,10 +13,9 @@
mod
foo
{
// not exported
#[derive(Copy)]
enum
t
{
t1
,
t2
,
}
impl
Copy
for
t
{}
impl
PartialEq
for
t
{
fn
eq
(
&
self
,
other
:
&
t
)
->
bool
{
((
*
self
)
as
uint
)
==
((
*
other
)
as
uint
)
...
...
src/test/run-pass/expr-copy.rs
浏览文件 @
ee0be3b3
...
...
@@ -13,10 +13,9 @@ fn f(arg: &mut A) {
arg
.a
=
100
;
}
#[derive(Copy)]
struct
A
{
a
:
int
}
impl
Copy
for
A
{}
pub
fn
main
()
{
let
mut
x
=
A
{
a
:
10
};
f
(
&
mut
x
);
...
...
src/test/run-pass/expr-if-struct.rs
浏览文件 @
ee0be3b3
...
...
@@ -14,20 +14,17 @@
// Tests for if as expressions returning nominal types
#[derive(Copy)]
struct
I
{
i
:
int
}
impl
Copy
for
I
{}
fn
test_rec
()
{
let
rs
=
if
true
{
I
{
i
:
100
}
}
else
{
I
{
i
:
101
}
};
assert_eq!
(
rs
.i
,
100
);
}
#[derive(Show)]
#[derive(
Copy,
Show)]
enum
mood
{
happy
,
sad
,
}
impl
Copy
for
mood
{}
impl
PartialEq
for
mood
{
fn
eq
(
&
self
,
other
:
&
mood
)
->
bool
{
((
*
self
)
as
uint
)
==
((
*
other
)
as
uint
)
...
...
src/test/run-pass/expr-match-struct.rs
浏览文件 @
ee0be3b3
...
...
@@ -13,20 +13,17 @@
// Tests for match as expressions resulting in struct types
#[derive(Copy)]
struct
R
{
i
:
int
}
impl
Copy
for
R
{}
fn
test_rec
()
{
let
rs
=
match
true
{
true
=>
R
{
i
:
100
},
_
=>
panic!
()
};
assert_eq!
(
rs
.i
,
100
);
}
#[derive(Show)]
#[derive(
Copy,
Show)]
enum
mood
{
happy
,
sad
,
}
impl
Copy
for
mood
{}
impl
PartialEq
for
mood
{
fn
eq
(
&
self
,
other
:
&
mood
)
->
bool
{
((
*
self
)
as
uint
)
==
((
*
other
)
as
uint
)
...
...
src/test/run-pass/exterior.rs
浏览文件 @
ee0be3b3
...
...
@@ -11,10 +11,9 @@
use
std
::
cell
::
Cell
;
#[derive(Copy)]
struct
Point
{
x
:
int
,
y
:
int
,
z
:
int
}
impl
Copy
for
Point
{}
fn
f
(
p
:
&
Cell
<
Point
>
)
{
assert
!
((
p
.get
()
.z
==
12
));
p
.set
(
Point
{
x
:
10
,
y
:
11
,
z
:
13
});
...
...
src/test/run-pass/extern-pass-TwoU16s.rs
浏览文件 @
ee0be3b3
...
...
@@ -11,13 +11,11 @@
// Test a foreign function that accepts and returns a struct
// by value.
#[derive(PartialEq,
Show)]
#[derive(
Copy,
PartialEq,
Show)]
pub
struct
TwoU16s
{
one
:
u16
,
two
:
u16
}
impl
Copy
for
TwoU16s
{}
#[link(name
=
"rust_test_helpers"
)]
extern
{
pub
fn
rust_dbg_extern_identity_TwoU16s
(
v
:
TwoU16s
)
->
TwoU16s
;
...
...
src/test/run-pass/extern-pass-TwoU32s.rs
浏览文件 @
ee0be3b3
...
...
@@ -11,13 +11,11 @@
// Test a foreign function that accepts and returns a struct
// by value.
#[derive(PartialEq,
Show)]
#[derive(
Copy,
PartialEq,
Show)]
pub
struct
TwoU32s
{
one
:
u32
,
two
:
u32
}
impl
Copy
for
TwoU32s
{}
#[link(name
=
"rust_test_helpers"
)]
extern
{
pub
fn
rust_dbg_extern_identity_TwoU32s
(
v
:
TwoU32s
)
->
TwoU32s
;
...
...
src/test/run-pass/extern-pass-TwoU64s.rs
浏览文件 @
ee0be3b3
...
...
@@ -11,13 +11,11 @@
// Test a foreign function that accepts and returns a struct
// by value.
#[derive(PartialEq,
Show)]
#[derive(
Copy,
PartialEq,
Show)]
pub
struct
TwoU64s
{
one
:
u64
,
two
:
u64
}
impl
Copy
for
TwoU64s
{}
#[link(name
=
"rust_test_helpers"
)]
extern
{
pub
fn
rust_dbg_extern_identity_TwoU64s
(
v
:
TwoU64s
)
->
TwoU64s
;
...
...
src/test/run-pass/extern-pass-TwoU8s.rs
浏览文件 @
ee0be3b3
...
...
@@ -11,13 +11,11 @@
// Test a foreign function that accepts and returns a struct
// by value.
#[derive(PartialEq,
Show)]
#[derive(
Copy,
PartialEq,
Show)]
pub
struct
TwoU8s
{
one
:
u8
,
two
:
u8
}
impl
Copy
for
TwoU8s
{}
#[link(name
=
"rust_test_helpers"
)]
extern
{
pub
fn
rust_dbg_extern_identity_TwoU8s
(
v
:
TwoU8s
)
->
TwoU8s
;
...
...
src/test/run-pass/foreign-fn-with-byval.rs
浏览文件 @
ee0be3b3
...
...
@@ -8,14 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[derive(Copy)]
pub
struct
S
{
x
:
u64
,
y
:
u64
,
z
:
u64
,
}
impl
Copy
for
S
{}
#[link(name
=
"rust_test_helpers"
)]
extern
{
pub
fn
get_x
(
x
:
S
)
->
u64
;
...
...
src/test/run-pass/generic-fn.rs
浏览文件 @
ee0be3b3
...
...
@@ -12,10 +12,9 @@
fn
id
<
T
>
(
x
:
T
)
->
T
{
return
x
;
}
#[derive(Copy)]
struct
Triple
{
x
:
int
,
y
:
int
,
z
:
int
}
impl
Copy
for
Triple
{}
pub
fn
main
()
{
let
mut
x
=
62
;
let
mut
y
=
63
;
...
...
src/test/run-pass/guards-not-exhaustive.rs
浏览文件 @
ee0be3b3
...
...
@@ -8,10 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[derive(Copy)]
enum
Q
{
R
(
Option
<
uint
>
)
}
impl
Copy
for
Q
{}
fn
xyzzy
(
q
:
Q
)
->
uint
{
match
q
{
Q
::
R
(
S
)
if
S
.is_some
()
=>
{
0
}
...
...
src/test/run-pass/guards.rs
浏览文件 @
ee0be3b3
...
...
@@ -8,10 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[derive(Copy)]
struct
Pair
{
x
:
int
,
y
:
int
}
impl
Copy
for
Pair
{}
pub
fn
main
()
{
let
a
:
int
=
match
10
i
{
x
if
x
<
7
=>
{
1
i
}
x
if
x
<
11
=>
{
2
i
}
10
=>
{
3
i
}
_
=>
{
4
i
}
};
...
...
src/test/run-pass/hrtb-opt-in-copy.rs
浏览文件 @
ee0be3b3
...
...
@@ -29,10 +29,9 @@ enum TyS<'tcx> {
Boop
(
marker
::
InvariantLifetime
<
'tcx
>
)
}
#[derive(Copy)]
enum
Bar
<
'tcx
>
{
Baz
(
Foo
<
Ty
<
'tcx
>>
)
}
impl
<
'tcx
>
Copy
for
Bar
<
'tcx
>
{
}
fn
main
()
{
}
src/test/run-pass/issue-12860.rs
浏览文件 @
ee0be3b3
...
...
@@ -13,15 +13,13 @@
use
std
::
collections
::
HashSet
;
#[derive(PartialEq,
Eq,
Hash)]
#[derive(
Copy,
PartialEq,
Eq,
Hash)]
struct
XYZ
{
x
:
int
,
y
:
int
,
z
:
int
}
impl
Copy
for
XYZ
{}
fn
main
()
{
let
mut
connected
=
HashSet
::
new
();
let
mut
border
=
HashSet
::
new
();
...
...
src/test/run-pass/issue-19100.rs
浏览文件 @
ee0be3b3
...
...
@@ -8,13 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[derive(Copy)]
enum
Foo
{
Bar
,
Baz
}
impl
Copy
for
Foo
{}
impl
Foo
{
fn
foo
(
&
self
)
{
match
self
{
...
...
src/test/run-pass/issue-2288.rs
浏览文件 @
ee0be3b3
...
...
@@ -15,12 +15,11 @@ trait clam<A> {
fn
chowder
(
&
self
,
y
:
A
);
}
#[derive(Copy)]
struct
foo
<
A
>
{
x
:
A
,
}
impl
<
A
:
Copy
>
Copy
for
foo
<
A
>
{}
impl
<
A
>
clam
<
A
>
for
foo
<
A
>
{
fn
chowder
(
&
self
,
_
y
:
A
)
{
}
...
...
src/test/run-pass/issue-2633.rs
浏览文件 @
ee0be3b3
...
...
@@ -8,12 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[derive(Copy)]
struct
cat
{
meow
:
extern
"Rust"
fn
(),
}
impl
Copy
for
cat
{}
fn
meow
()
{
println!
(
"meow"
)
}
...
...
@@ -24,10 +23,9 @@ fn cat() -> cat {
}
}
#[derive(Copy)]
struct
KittyInfo
{
kitty
:
cat
}
impl
Copy
for
KittyInfo
{}
// Code compiles and runs successfully if we add a + before the first arg
fn
nyan
(
kitty
:
cat
,
_
kitty_info
:
KittyInfo
)
{
(
kitty
.meow
)();
...
...
src/test/run-pass/issue-3121.rs
浏览文件 @
ee0be3b3
...
...
@@ -11,14 +11,13 @@
#![allow(unknown_features)]
#![feature(box_syntax)]
#[derive(Copy)]
enum
side
{
mayo
,
catsup
,
vinegar
}
#[derive(Copy)]
enum
order
{
hamburger
,
fries
(
side
),
shake
}
#[derive(Copy)]
enum
meal
{
to_go
(
order
),
for_here
(
order
)
}
impl
Copy
for
side
{}
impl
Copy
for
order
{}
impl
Copy
for
meal
{}
fn
foo
(
m
:
Box
<
meal
>
,
cond
:
bool
)
{
match
*
m
{
meal
::
to_go
(
_
)
=>
{
}
...
...
src/test/run-pass/issue-3563-3.rs
浏览文件 @
ee0be3b3
...
...
@@ -27,29 +27,26 @@
use
std
::
slice
;
// Represents a position on a canvas.
#[derive(Copy)]
struct
Point
{
x
:
int
,
y
:
int
,
}
impl
Copy
for
Point
{}
// Represents an offset on a canvas. (This has the same structure as a Point.
// but different semantics).
#[derive(Copy)]
struct
Size
{
width
:
int
,
height
:
int
,
}
impl
Copy
for
Size
{}
#[derive(Copy)]
struct
Rect
{
top_left
:
Point
,
size
:
Size
,
}
impl
Copy
for
Rect
{}
// Contains the information needed to do shape rendering via ASCII art.
struct
AsciiArt
{
width
:
uint
,
...
...
src/test/run-pass/issue-3743.rs
浏览文件 @
ee0be3b3
...
...
@@ -14,13 +14,12 @@
use
std
::
ops
::
Mul
;
#[derive(Copy)]
struct
Vec2
{
x
:
f64
,
y
:
f64
}
impl
Copy
for
Vec2
{}
// methods we want to export as methods as well as operators
impl
Vec2
{
#[inline(always)]
...
...
src/test/run-pass/issue-3753.rs
浏览文件 @
ee0be3b3
...
...
@@ -14,20 +14,18 @@
use
std
::
f64
;
#[derive(Copy)]
pub
struct
Point
{
x
:
f64
,
y
:
f64
}
impl
Copy
for
Point
{}
#[derive(Copy)]
pub
enum
Shape
{
Circle
(
Point
,
f64
),
Rectangle
(
Point
,
Point
)
}
impl
Copy
for
Shape
{}
impl
Shape
{
pub
fn
area
(
&
self
,
sh
:
Shape
)
->
f64
{
match
sh
{
...
...
src/test/run-pass/issue-5688.rs
浏览文件 @
ee0be3b3
...
...
@@ -17,10 +17,9 @@
failed to typecheck correctly.
*/
#[derive(Copy)]
struct
X
{
vec
:
&
'static
[
int
]
}
impl
Copy
for
X
{}
static
V
:
&
'static
[
X
]
=
&
[
X
{
vec
:
&
[
1
,
2
,
3
]
}];
pub
fn
main
()
{
...
...
src/test/run-pass/match-arm-statics.rs
浏览文件 @
ee0be3b3
...
...
@@ -36,10 +36,9 @@ enum EnumWithStructVariants {
dir
:
Direction
::
North
};
pub
mod
glfw
{
#[derive(Copy)]
pub
struct
InputState
(
uint
);
impl
Copy
for
InputState
{}
pub
const
RELEASE
:
InputState
=
InputState
(
0
);
pub
const
PRESS
:
InputState
=
InputState
(
1
);
pub
const
REPEAT
:
InputState
=
InputState
(
2
);
...
...
src/test/run-pass/method-self-arg-trait.rs
浏览文件 @
ee0be3b3
...
...
@@ -15,10 +15,9 @@
static
mut
COUNT
:
u64
=
1
;
#[derive(Copy)]
struct
Foo
;
impl
Copy
for
Foo
{}
trait
Bar
:
Sized
{
fn
foo1
(
&
self
);
fn
foo2
(
self
);
...
...
src/test/run-pass/method-self-arg.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/monomorphize-abi-alignment.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/multidispatch1.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/multidispatch2.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/newtype.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/out-pointer-aliasing.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/overloaded-autoderef-order.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/packed-struct-vec.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/rec-tup.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/rec.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/regions-dependent-addr-of.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/regions-early-bound-used-in-bound-method.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/regions-early-bound-used-in-type-param.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/regions-mock-tcx.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/self-in-mut-slot-immediate-value.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/simd-generics.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/small-enum-range-edge.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/struct-return.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/structured-compare.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/tag-variant-disr-val.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/trait-coercion-generic.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/trait-coercion.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/typeclasses-eq-example-static.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/typeclasses-eq-example.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/ufcs-explicit-self.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
src/test/run-pass/unboxed-closures-monomorphization.rs
浏览文件 @
ee0be3b3
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录