Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
4128cc4c
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,发现更多精彩内容 >>
提交
4128cc4c
编写于
8月 30, 2012
作者:
T
Tim Chevalier
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make utility funs in core::int, core::uint, etc. not by-reference
Closes #3302
上级
638db28c
变更
23
隐藏空白更改
内联
并排
Showing
23 changed file
with
103 addition
and
102 deletion
+103
-102
src/fuzzer/fuzzer.rs
src/fuzzer/fuzzer.rs
+5
-5
src/libcore/int-template.rs
src/libcore/int-template.rs
+15
-15
src/libcore/int-template/int.rs
src/libcore/int-template/int.rs
+3
-3
src/libcore/io.rs
src/libcore/io.rs
+2
-2
src/libcore/str.rs
src/libcore/str.rs
+2
-2
src/libcore/uint-template.rs
src/libcore/uint-template.rs
+15
-15
src/libcore/uint-template/uint.rs
src/libcore/uint-template/uint.rs
+2
-2
src/libcore/vec.rs
src/libcore/vec.rs
+2
-2
src/libstd/arena.rs
src/libstd/arena.rs
+2
-2
src/libstd/map.rs
src/libstd/map.rs
+5
-5
src/libstd/net_tcp.rs
src/libstd/net_tcp.rs
+1
-1
src/libstd/par.rs
src/libstd/par.rs
+2
-2
src/libstd/rope.rs
src/libstd/rope.rs
+1
-1
src/libstd/sort.rs
src/libstd/sort.rs
+1
-1
src/libsyntax/ast_util.rs
src/libsyntax/ast_util.rs
+2
-2
src/libsyntax/parse/comments.rs
src/libsyntax/parse/comments.rs
+1
-1
src/rustc/back/rpath.rs
src/rustc/back/rpath.rs
+7
-7
src/rustc/driver/rustc.rs
src/rustc/driver/rustc.rs
+2
-2
src/rustc/middle/resolve.rs
src/rustc/middle/resolve.rs
+1
-1
src/rustc/middle/trans/foreign.rs
src/rustc/middle/trans/foreign.rs
+24
-25
src/rustc/middle/ty.rs
src/rustc/middle/ty.rs
+2
-2
src/rustdoc/unindent_pass.rs
src/rustdoc/unindent_pass.rs
+3
-3
src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs
src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs
+3
-1
未找到文件。
src/fuzzer/fuzzer.rs
浏览文件 @
4128cc4c
...
...
@@ -249,18 +249,18 @@ fn check_variants_T<T: copy>(
cx
:
context
)
{
error!
(
"%s contains %u %s objects"
,
filename
.to_str
(),
vec
::
len
(
things
),
thing_label
);
things
.len
(
),
thing_label
);
// Assuming we're not generating any token_trees
let
intr
=
syntax
::
parse
::
token
::
mk_fake_ident_interner
();
let
L
=
vec
::
len
(
things
);
let
L
=
things
.len
(
);
if
L
<
100
u
{
do
under
(
uint
::
min
(
&
L
,
&
20u
))
|
i
|
{
if
L
<
100
{
do
under
(
uint
::
min
(
L
,
20
))
|
i
|
{
log
(
error
,
~
"Replacing... #"
+
uint
::
str
(
i
));
let
fname
=
str
::
from_slice
(
filename
.to_str
());
do
under
(
uint
::
min
(
&
L
,
&
30u
))
|
j
|
{
do
under
(
uint
::
min
(
L
,
30
))
|
j
|
{
log
(
error
,
~
"With... "
+
stringifier
(
@
things
[
j
],
intr
));
let
crate2
=
@
replacer
(
crate
,
i
,
things
[
j
],
cx
.mode
);
// It would be best to test the *crate* for stability, but
...
...
src/libcore/int-template.rs
浏览文件 @
4128cc4c
...
...
@@ -25,21 +25,21 @@
const
min_value
:
T
=
(
-
1
as
T
)
<<
(
bits
-
1
);
const
max_value
:
T
=
min_value
-
1
as
T
;
pure
fn
min
(
x
:
&
T
,
y
:
&
T
)
->
T
{
if
*
x
<
*
y
{
*
x
}
else
{
*
y
}
}
pure
fn
max
(
x
:
&
T
,
y
:
&
T
)
->
T
{
if
*
x
>
*
y
{
*
x
}
else
{
*
y
}
}
pure
fn
add
(
x
:
&
T
,
y
:
&
T
)
->
T
{
*
x
+
*
y
}
pure
fn
sub
(
x
:
&
T
,
y
:
&
T
)
->
T
{
*
x
-
*
y
}
pure
fn
mul
(
x
:
&
T
,
y
:
&
T
)
->
T
{
*
x
*
*
y
}
pure
fn
div
(
x
:
&
T
,
y
:
&
T
)
->
T
{
*
x
/
*
y
}
pure
fn
rem
(
x
:
&
T
,
y
:
&
T
)
->
T
{
*
x
%
*
y
}
pure
fn
lt
(
x
:
&
T
,
y
:
&
T
)
->
bool
{
*
x
<
*
y
}
pure
fn
le
(
x
:
&
T
,
y
:
&
T
)
->
bool
{
*
x
<=
*
y
}
pure
fn
eq
(
x
:
&
T
,
y
:
&
T
)
->
bool
{
*
x
==
*
y
}
pure
fn
ne
(
x
:
&
T
,
y
:
&
T
)
->
bool
{
*
x
!=
*
y
}
pure
fn
ge
(
x
:
&
T
,
y
:
&
T
)
->
bool
{
*
x
>=
*
y
}
pure
fn
gt
(
x
:
&
T
,
y
:
&
T
)
->
bool
{
*
x
>
*
y
}
pure
fn
min
(
x
:
T
,
y
:
T
)
->
T
{
if
x
<
y
{
x
}
else
{
y
}
}
pure
fn
max
(
x
:
T
,
y
:
T
)
->
T
{
if
x
>
y
{
x
}
else
{
y
}
}
pure
fn
add
(
x
:
T
,
y
:
T
)
->
T
{
x
+
y
}
pure
fn
sub
(
x
:
T
,
y
:
T
)
->
T
{
x
-
y
}
pure
fn
mul
(
x
:
T
,
y
:
T
)
->
T
{
x
*
y
}
pure
fn
div
(
x
:
T
,
y
:
T
)
->
T
{
x
/
y
}
pure
fn
rem
(
x
:
T
,
y
:
T
)
->
T
{
x
%
y
}
pure
fn
lt
(
x
:
T
,
y
:
T
)
->
bool
{
x
<
y
}
pure
fn
le
(
x
:
T
,
y
:
T
)
->
bool
{
x
<=
y
}
pure
fn
eq
(
x
:
T
,
y
:
T
)
->
bool
{
x
==
y
}
pure
fn
ne
(
x
:
T
,
y
:
T
)
->
bool
{
x
!=
y
}
pure
fn
ge
(
x
:
T
,
y
:
T
)
->
bool
{
x
>=
y
}
pure
fn
gt
(
x
:
T
,
y
:
T
)
->
bool
{
x
>
y
}
pure
fn
is_positive
(
x
:
T
)
->
bool
{
x
>
0
as
T
}
pure
fn
is_negative
(
x
:
T
)
->
bool
{
x
<
0
as
T
}
...
...
src/libcore/int-template/int.rs
浏览文件 @
4128cc4c
...
...
@@ -2,9 +2,9 @@
const
bits
:
uint
=
uint
::
bits
;
/// Produce a uint suitable for use in a hash table
pure
fn
hash
(
x
:
&
int
)
->
uint
{
let
u
:
uint
=
*
x
as
uint
;
uint
::
hash
(
&
u
)
pure
fn
hash
(
x
:
int
)
->
uint
{
let
u
:
uint
=
x
as
uint
;
uint
::
hash
(
u
)
}
/// Returns `base` raised to the power of `exponent`
...
...
src/libcore/io.rs
浏览文件 @
4128cc4c
...
...
@@ -285,7 +285,7 @@ fn file_reader(path: &Path) -> Result<Reader, ~str> {
impl
ByteBuf
:
Reader
{
fn
read
(
buf
:
&
[
mut
u8
],
len
:
uint
)
->
uint
{
let
count
=
uint
::
min
(
&
len
,
&
(
self
.buf
.len
()
-
self
.pos
)
);
let
count
=
uint
::
min
(
len
,
self
.buf
.len
()
-
self
.pos
);
vec
::
u8
::
memcpy
(
buf
,
vec
::
const_view
(
self
.buf
,
self
.pos
,
self
.buf
.len
()),
...
...
@@ -668,7 +668,7 @@ fn write(v: &[const u8]) {
let
v_len
=
v
.len
();
let
buf_len
=
buf
.len
();
let
count
=
uint
::
max
(
&
buf_len
,
&
(
self
.pos
+
v_len
)
);
let
count
=
uint
::
max
(
buf_len
,
self
.pos
+
v_len
);
vec
::
reserve
(
buf
,
count
);
unsafe
{
vec
::
unsafe
::
set_len
(
buf
,
count
);
}
...
...
src/libcore/str.rs
浏览文件 @
4128cc4c
...
...
@@ -682,7 +682,7 @@ fn view_shift_char(s: &a/str) -> (char, &a/str) {
/// Bytewise slice less than
pure
fn
lt
(
a
:
&
str
,
b
:
&
str
)
->
bool
{
let
(
a_len
,
b_len
)
=
(
a
.len
(),
b
.len
());
let
mut
end
=
uint
::
min
(
&
a_len
,
&
b_len
);
let
mut
end
=
uint
::
min
(
a_len
,
b_len
);
let
mut
i
=
0
;
while
i
<
end
{
...
...
@@ -698,7 +698,7 @@ fn view_shift_char(s: &a/str) -> (char, &a/str) {
/// Bytewise less than or equal
pure
fn
le
(
a
:
&
str
,
b
:
&
str
)
->
bool
{
let
(
a_len
,
b_len
)
=
(
a
.len
(),
b
.len
());
let
mut
end
=
uint
::
min
(
&
a_len
,
&
b_len
);
let
mut
end
=
uint
::
min
(
a_len
,
b_len
);
let
mut
i
=
0
;
while
i
<
end
{
...
...
src/libcore/uint-template.rs
浏览文件 @
4128cc4c
...
...
@@ -24,21 +24,21 @@
const
min_value
:
T
=
0
as
T
;
const
max_value
:
T
=
0
as
T
-
1
as
T
;
pure
fn
min
(
x
:
&
T
,
y
:
&
T
)
->
T
{
if
*
x
<
*
y
{
*
x
}
else
{
*
y
}
}
pure
fn
max
(
x
:
&
T
,
y
:
&
T
)
->
T
{
if
*
x
>
*
y
{
*
x
}
else
{
*
y
}
}
pure
fn
add
(
x
:
&
T
,
y
:
&
T
)
->
T
{
*
x
+
*
y
}
pure
fn
sub
(
x
:
&
T
,
y
:
&
T
)
->
T
{
*
x
-
*
y
}
pure
fn
mul
(
x
:
&
T
,
y
:
&
T
)
->
T
{
*
x
*
*
y
}
pure
fn
div
(
x
:
&
T
,
y
:
&
T
)
->
T
{
*
x
/
*
y
}
pure
fn
rem
(
x
:
&
T
,
y
:
&
T
)
->
T
{
*
x
%
*
y
}
pure
fn
lt
(
x
:
&
T
,
y
:
&
T
)
->
bool
{
*
x
<
*
y
}
pure
fn
le
(
x
:
&
T
,
y
:
&
T
)
->
bool
{
*
x
<=
*
y
}
pure
fn
eq
(
x
:
&
T
,
y
:
&
T
)
->
bool
{
*
x
==
*
y
}
pure
fn
ne
(
x
:
&
T
,
y
:
&
T
)
->
bool
{
*
x
!=
*
y
}
pure
fn
ge
(
x
:
&
T
,
y
:
&
T
)
->
bool
{
*
x
>=
*
y
}
pure
fn
gt
(
x
:
&
T
,
y
:
&
T
)
->
bool
{
*
x
>
*
y
}
pure
fn
min
(
x
:
T
,
y
:
T
)
->
T
{
if
x
<
y
{
x
}
else
{
y
}
}
pure
fn
max
(
x
:
T
,
y
:
T
)
->
T
{
if
x
>
y
{
x
}
else
{
y
}
}
pure
fn
add
(
x
:
T
,
y
:
T
)
->
T
{
x
+
y
}
pure
fn
sub
(
x
:
T
,
y
:
T
)
->
T
{
x
-
y
}
pure
fn
mul
(
x
:
T
,
y
:
T
)
->
T
{
x
*
y
}
pure
fn
div
(
x
:
T
,
y
:
T
)
->
T
{
x
/
y
}
pure
fn
rem
(
x
:
T
,
y
:
T
)
->
T
{
x
%
y
}
pure
fn
lt
(
x
:
T
,
y
:
T
)
->
bool
{
x
<
y
}
pure
fn
le
(
x
:
T
,
y
:
T
)
->
bool
{
x
<=
y
}
pure
fn
eq
(
x
:
T
,
y
:
T
)
->
bool
{
x
==
y
}
pure
fn
ne
(
x
:
T
,
y
:
T
)
->
bool
{
x
!=
y
}
pure
fn
ge
(
x
:
T
,
y
:
T
)
->
bool
{
x
>=
y
}
pure
fn
gt
(
x
:
T
,
y
:
T
)
->
bool
{
x
>
y
}
pure
fn
is_positive
(
x
:
T
)
->
bool
{
x
>
0
as
T
}
pure
fn
is_negative
(
x
:
T
)
->
bool
{
x
<
0
as
T
}
...
...
src/libcore/uint-template/uint.rs
浏览文件 @
4128cc4c
...
...
@@ -61,8 +61,8 @@
pure
fn
div_floor
(
x
:
uint
,
y
:
uint
)
->
uint
{
return
x
/
y
;
}
/// Produce a uint suitable for use in a hash table
pure
fn
hash
(
x
:
&
uint
)
->
uint
{
hash
::
hash_uint
(
*
x
)
as
uint
pure
fn
hash
(
x
:
uint
)
->
uint
{
hash
::
hash_uint
(
x
)
as
uint
}
/**
...
...
src/libcore/vec.rs
浏览文件 @
4128cc4c
...
...
@@ -1427,7 +1427,7 @@ impl<T: Eq> @[T]: Eq {
pure
fn
lt
<
T
:
Ord
>
(
a
:
&
[
T
],
b
:
&
[
T
])
->
bool
{
let
(
a_len
,
b_len
)
=
(
a
.len
(),
b
.len
());
let
mut
end
=
uint
::
min
(
&
a_len
,
&
b_len
);
let
mut
end
=
uint
::
min
(
a_len
,
b_len
);
let
mut
i
=
0
;
while
i
<
end
{
...
...
@@ -1841,7 +1841,7 @@ mod u8 {
pure
fn
cmp
(
a
:
&~
[
u8
],
b
:
&~
[
u8
])
->
int
{
let
a_len
=
len
(
*
a
);
let
b_len
=
len
(
*
b
);
let
n
=
uint
::
min
(
&
a_len
,
&
b_len
)
as
libc
::
size_t
;
let
n
=
uint
::
min
(
a_len
,
b_len
)
as
libc
::
size_t
;
let
r
=
unsafe
{
libc
::
memcmp
(
unsafe
::
to_ptr
(
*
a
)
as
*
libc
::
c_void
,
unsafe
::
to_ptr
(
*
b
)
as
*
libc
::
c_void
,
n
)
as
int
...
...
src/libstd/arena.rs
浏览文件 @
4128cc4c
...
...
@@ -135,7 +135,7 @@ impl &Arena {
fn
alloc_pod_grow
(
n_bytes
:
uint
,
align
:
uint
)
->
*
u8
{
// Allocate a new chunk.
let
chunk_size
=
at_vec
::
capacity
(
self
.pod_head.data
);
let
new_min_chunk_size
=
uint
::
max
(
&
n_bytes
,
&
chunk_size
);
let
new_min_chunk_size
=
uint
::
max
(
n_bytes
,
chunk_size
);
self
.chunks
=
@
cons
(
copy
self
.pod_head
,
self
.chunks
);
self
.pod_head
=
chunk
(
uint
::
next_power_of_two
(
new_min_chunk_size
+
1u
),
true
);
...
...
@@ -177,7 +177,7 @@ fn alloc_pod<T>(op: fn() -> T) -> &self/T {
fn
alloc_nonpod_grow
(
n_bytes
:
uint
,
align
:
uint
)
->
(
*
u8
,
*
u8
)
{
// Allocate a new chunk.
let
chunk_size
=
at_vec
::
capacity
(
self
.head.data
);
let
new_min_chunk_size
=
uint
::
max
(
&
n_bytes
,
&
chunk_size
);
let
new_min_chunk_size
=
uint
::
max
(
n_bytes
,
chunk_size
);
self
.chunks
=
@
cons
(
copy
self
.head
,
self
.chunks
);
self
.head
=
chunk
(
uint
::
next_power_of_two
(
new_min_chunk_size
+
1u
),
false
);
...
...
src/libstd/map.rs
浏览文件 @
4128cc4c
...
...
@@ -426,12 +426,12 @@ fn bytes_hash<V: copy>() -> hashmap<~[u8], V> {
/// Construct a hashmap for int keys
fn
int_hash
<
V
:
copy
>
()
->
hashmap
<
int
,
V
>
{
return
hashmap
(
int
::
hash
,
int
::
eq
);
return
hashmap
(|
x
|
{
int
::
hash
(
*
x
)
},
|
x
,
y
|
{
int
::
eq
(
*
x
,
*
y
)}
);
}
/// Construct a hashmap for uint keys
fn
uint_hash
<
V
:
copy
>
()
->
hashmap
<
uint
,
V
>
{
return
hashmap
(
uint
::
hash
,
uint
::
eq
);
return
hashmap
(|
x
|
{
uint
::
hash
(
*
x
)
},
|
x
,
y
|
{
uint
::
eq
(
*
x
,
*
y
)
}
);
}
/// Convenience function for adding keys to a hashmap with nil type keys
...
...
@@ -473,15 +473,15 @@ fn hash_from_bytes<V: copy>(items: &[(~[u8], V)]) -> hashmap<~[u8], V> {
/// Construct a hashmap from a vector with int keys
fn
hash_from_ints
<
V
:
copy
>
(
items
:
&
[(
int
,
V
)])
->
hashmap
<
int
,
V
>
{
hash_from_vec
(
int
::
hash
,
int
::
eq
,
items
)
hash_from_vec
(
|
x
|
{
int
::
hash
(
*
x
)
},
|
x
,
y
|
{
int
::
eq
(
*
x
,
*
y
)
}
,
items
)
}
/// Construct a hashmap from a vector with uint keys
fn
hash_from_uints
<
V
:
copy
>
(
items
:
&
[(
uint
,
V
)])
->
hashmap
<
uint
,
V
>
{
hash_from_vec
(
uint
::
hash
,
uint
::
eq
,
items
)
hash_from_vec
(
|
x
|
{
uint
::
hash
(
*
x
)
},
|
x
,
y
|
{
uint
::
eq
(
*
x
,
*
y
)
}
,
items
)
}
// XXX Transitiona
ry
// XXX Transitiona
l
impl
<
K
:
Eq
IterBytes
Hash
copy
,
V
:
copy
>
Managed
<
LinearMap
<
K
,
V
>>
:
map
<
K
,
V
>
{
pure
fn
size
()
->
uint
{
...
...
src/libstd/net_tcp.rs
浏览文件 @
4128cc4c
...
...
@@ -772,7 +772,7 @@ fn read(buf: &[mut u8], len: uint) -> uint {
}
}
let
count
=
uint
::
min
(
&
len
,
&
self
.data.buf
.len
());
let
count
=
uint
::
min
(
len
,
self
.data.buf
.len
());
let
mut
data
=
~
[];
self
.data.buf
<->
data
;
...
...
src/libstd/par.rs
浏览文件 @
4128cc4c
...
...
@@ -30,7 +30,7 @@ fn map_slices<A: copy send, B: copy send>(
~
[
f
()(
0u
,
xs
)]
}
else
{
let
num_tasks
=
uint
::
min
(
&
max_tasks
,
&
(
len
/
min_granularity
)
);
let
num_tasks
=
uint
::
min
(
max_tasks
,
len
/
min_granularity
);
let
items_per_task
=
len
/
num_tasks
;
...
...
@@ -38,7 +38,7 @@ fn map_slices<A: copy send, B: copy send>(
let
mut
base
=
0u
;
log
(
info
,
~
"spawning tasks"
);
while
base
<
len
{
let
end
=
uint
::
min
(
&
len
,
&
(
base
+
items_per_task
)
);
let
end
=
uint
::
min
(
len
,
base
+
items_per_task
);
// FIXME: why is the ::<A, ()> annotation required here? (#2617)
do
vec
::
as_buf
::
<
A
,
()
>
(
xs
)
|
p
,
_
len
|
{
let
f
=
f
();
...
...
src/libstd/rope.rs
浏览文件 @
4128cc4c
...
...
@@ -1004,7 +1004,7 @@ fn concat2(left: @node, right: @node) -> @node {
right
:
right
,
char_len
:
char_len
(
left
)
+
char_len
(
right
),
byte_len
:
byte_len
(
left
)
+
byte_len
(
right
),
height
:
uint
::
max
(
&
height
(
left
),
&
height
(
right
))
+
1u
height
:
uint
::
max
(
height
(
left
),
height
(
right
))
+
1u
})
}
...
...
src/libstd/sort.rs
浏览文件 @
4128cc4c
...
...
@@ -242,7 +242,7 @@ fn test_simple() {
let
expected
=
~
[
1
,
2
,
3
];
sort
::
quick_sort
(
int
::
le
,
names
);
sort
::
quick_sort
(
|
x
,
y
|
{
int
::
le
(
*
x
,
*
y
)
}
,
names
);
let
immut_names
=
vec
::
from_mut
(
names
);
...
...
src/libsyntax/ast_util.rs
浏览文件 @
4128cc4c
...
...
@@ -568,8 +568,8 @@ fn compute_id_range(visit_ids_fn: fn(fn@(node_id))) -> id_range {
let
min
=
@
mut
int
::
max_value
;
let
max
=
@
mut
int
::
min_value
;
do
visit_ids_fn
|
id
|
{
*
min
=
int
::
min
(
min
,
&
id
);
*
max
=
int
::
max
(
max
,
&
(
id
+
1
)
);
*
min
=
int
::
min
(
*
min
,
id
);
*
max
=
int
::
max
(
*
max
,
id
+
1
);
}
return
{
min
:
*
min
,
max
:
*
max
};
}
...
...
src/libsyntax/parse/comments.rs
浏览文件 @
4128cc4c
...
...
@@ -182,7 +182,7 @@ fn trim_whitespace_prefix_and_push_line(&lines: ~[~str],
s
:
~
str
,
col
:
uint
)
unsafe
{
let
mut
s1
;
let
len
=
str
::
len
(
s
);
if
all_whitespace
(
s
,
0u
,
uint
::
min
(
&
len
,
&
col
))
{
if
all_whitespace
(
s
,
0u
,
uint
::
min
(
len
,
col
))
{
if
col
<
len
{
s1
=
str
::
slice
(
s
,
col
,
len
);
}
else
{
s1
=
~
""
;
}
...
...
src/rustc/back/rpath.rs
浏览文件 @
4128cc4c
...
...
@@ -125,20 +125,20 @@ fn get_relative_to(abs1: &Path, abs2: &Path) -> Path {
let
split2
=
abs2
.components
;
let
len1
=
vec
::
len
(
split1
);
let
len2
=
vec
::
len
(
split2
);
assert
len1
>
0
u
;
assert
len2
>
0
u
;
assert
len1
>
0
;
assert
len2
>
0
;
let
max_common_path
=
uint
::
min
(
&
len1
,
&
len2
)
-
1u
;
let
mut
start_idx
=
0
u
;
let
max_common_path
=
uint
::
min
(
len1
,
len2
)
-
1
;
let
mut
start_idx
=
0
;
while
start_idx
<
max_common_path
&&
split1
[
start_idx
]
==
split2
[
start_idx
]
{
start_idx
+=
1
u
;
start_idx
+=
1
;
}
let
mut
path
=
~
[];
for
uint
::
range
(
start_idx
,
len1
-
1
u
)
|
_
i
|
{
vec
::
push
(
path
,
~
".."
);
};
for
uint
::
range
(
start_idx
,
len1
-
1
)
|
_
i
|
{
vec
::
push
(
path
,
~
".."
);
};
vec
::
push_all
(
path
,
vec
::
view
(
split2
,
start_idx
,
len2
-
1
u
));
vec
::
push_all
(
path
,
vec
::
view
(
split2
,
start_idx
,
len2
-
1
));
if
vec
::
is_not_empty
(
path
)
{
return
Path
(
""
)
.push_many
(
path
);
...
...
src/rustc/driver/rustc.rs
浏览文件 @
4128cc4c
...
...
@@ -81,8 +81,8 @@ fn usage(argv0: ~str) {
fn
describe_warnings
()
{
let
lint_dict
=
lint
::
get_lint_dict
();
let
mut
max_key
=
0
u
;
for
lint_dict
.each_key
|
k
|
{
max_key
=
uint
::
max
(
&
k
.len
(),
&
max_key
);
}
let
mut
max_key
=
0
;
for
lint_dict
.each_key
|
k
|
{
max_key
=
uint
::
max
(
k
.len
(),
max_key
);
}
fn
padded
(
max
:
uint
,
s
:
~
str
)
->
~
str
{
str
::
from_bytes
(
vec
::
from_elem
(
max
-
s
.len
(),
' '
as
u8
))
+
s
}
...
...
src/rustc/middle/resolve.rs
浏览文件 @
4128cc4c
...
...
@@ -304,7 +304,7 @@ fn Atom(n: uint) -> Atom {
/// Creates a hash table of atoms.
fn
atom_hashmap
<
V
:
copy
>
()
->
hashmap
<
Atom
,
V
>
{
hashmap
::
<
Atom
,
V
>
(
uint
::
hash
,
uint
::
eq
)
hashmap
::
<
Atom
,
V
>
(|
x
|
{
uint
::
hash
(
*
x
)
},
|
x
,
y
|
{
uint
::
eq
(
*
x
,
*
y
)
}
)
}
/// One local scope.
...
...
src/rustc/middle/trans/foreign.rs
浏览文件 @
4128cc4c
...
...
@@ -5,11 +5,10 @@
import
syntax
::
codemap
::
span
;
import
libc
::
c_uint
;
import
syntax
::{
attr
,
ast_map
};
import
lib
::
llvm
::{
llvm
,
TypeRef
,
ValueRef
,
ModuleRef
,
CallConv
,
Attribute
,
StructRetAttribute
,
ByValAttribute
,
SequentiallyConsistent
,
Acquire
,
Release
,
Xchg
};
import
lib
::
llvm
::{
llvm
,
TypeRef
,
ValueRef
,
Integer
,
Pointer
,
Float
,
Double
,
Struct
,
Array
,
ModuleRef
,
CallConv
,
Attribute
,
StructRetAttribute
,
ByValAttribute
,
SequentiallyConsistent
,
Acquire
,
Release
,
Xchg
};
import
syntax
::{
ast
,
ast_util
};
import
back
::{
link
,
abi
};
import
common
::
*
;
...
...
@@ -79,19 +78,19 @@ fn struct_tys(ty: TypeRef) -> ~[TypeRef] {
}
fn
ty_align
(
ty
:
TypeRef
)
->
uint
{
return
match
llvm
::
LLVMGetTypeKind
(
ty
)
as
int
{
8
/* integer */
=>
{
((
llvm
::
LLVMGetIntTypeWidth
(
ty
)
as
uint
)
+
7
u
)
/
8u
return
match
llvm
::
LLVMGetTypeKind
(
ty
)
{
Integer
=>
{
((
llvm
::
LLVMGetIntTypeWidth
(
ty
)
as
uint
)
+
7
)
/
8
}
12
/* pointer */
=>
8u
,
2
/* float */
=>
4u
,
3
/* double */
=>
8u
,
10
/* struct */
=>
{
do
vec
::
foldl
(
0
u
,
struct_tys
(
ty
))
|
a
,
t
|
{
uint
::
max
(
&
a
,
&
ty_align
(
t
))
Pointer
=>
8
,
Float
=>
4
,
Double
=>
8
,
Struct
=>
{
do
vec
::
foldl
(
0
,
struct_tys
(
ty
))
|
a
,
t
|
{
uint
::
max
(
a
,
ty_align
(
t
))
}
}
11
/* array */
=>
{
Array
=>
{
let
elt
=
llvm
::
LLVMGetElementType
(
ty
);
ty_align
(
elt
)
}
...
...
@@ -100,19 +99,19 @@ fn ty_align(ty: TypeRef) -> uint {
}
fn
ty_size
(
ty
:
TypeRef
)
->
uint
{
return
match
llvm
::
LLVMGetTypeKind
(
ty
)
as
int
{
8
/* integer */
=>
{
((
llvm
::
LLVMGetIntTypeWidth
(
ty
)
as
uint
)
+
7
u
)
/
8u
return
match
llvm
::
LLVMGetTypeKind
(
ty
)
{
Integer
=>
{
((
llvm
::
LLVMGetIntTypeWidth
(
ty
)
as
uint
)
+
7
)
/
8
}
12
/* pointer */
=>
8u
,
2
/* float */
=>
4u
,
3
/* double */
=>
8u
,
10
/* struct */
=>
{
do
vec
::
foldl
(
0
u
,
struct_tys
(
ty
))
|
s
,
t
|
{
Pointer
=>
8
,
Float
=>
4
,
Double
=>
8
,
Struct
=>
{
do
vec
::
foldl
(
0
,
struct_tys
(
ty
))
|
s
,
t
|
{
s
+
ty_size
(
t
)
}
}
11
/* array */
=>
{
Array
=>
{
let
len
=
llvm
::
LLVMGetArrayLength
(
ty
)
as
uint
;
let
elt
=
llvm
::
LLVMGetElementType
(
ty
);
let
eltsz
=
ty_size
(
elt
);
...
...
@@ -123,7 +122,7 @@ fn ty_size(ty: TypeRef) -> uint {
}
fn
all_mem
(
cls
:
~
[
mut
x86_64_reg_class
])
{
for
uint
::
range
(
0
u
,
cls
.len
())
|
i
|
{
for
uint
::
range
(
0
,
cls
.len
())
|
i
|
{
cls
[
i
]
=
memory_class
;
}
}
...
...
src/rustc/middle/ty.rs
浏览文件 @
4128cc4c
...
...
@@ -1912,9 +1912,9 @@ fn type_size(cx: ctxt, ty: t) -> uint {
let
variants
=
substd_enum_variants
(
cx
,
did
,
substs
);
variants
.foldl
(
// find max size of any variant
0
,
|
m
,
v
|
uint
::
max
(
&
m
,
|
m
,
v
|
uint
::
max
(
m
,
// find size of this variant:
&
v
.args
.foldl
(
0
,
|
s
,
a
|
s
+
type_size
(
cx
,
a
))))
v
.args
.foldl
(
0
,
|
s
,
a
|
s
+
type_size
(
cx
,
a
))))
}
ty_param
(
_
)
|
ty_self
=>
{
...
...
src/rustdoc/unindent_pass.rs
浏览文件 @
4128cc4c
...
...
@@ -45,18 +45,18 @@ fn unindent(s: ~str) -> ~str {
min_indent
}
else
{
saw_first_line
=
true
;
let
mut
spaces
=
0
u
;
let
mut
spaces
=
0
;
do
str
::
all
(
line
)
|
char
|
{
// Only comparing against space because I wouldn't
// know what to do with mixed whitespace chars
if
char
==
' '
{
spaces
+=
1
u
;
spaces
+=
1
;
true
}
else
{
false
}
};
uint
::
min
(
&
min_indent
,
&
spaces
)
uint
::
min
(
min_indent
,
spaces
)
}
};
...
...
src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs
浏览文件 @
4128cc4c
...
...
@@ -4,7 +4,9 @@
import
std
::
map
;
fn
main
()
{
let
buggy_map
:
hashmap
<
uint
,
&
uint
>
=
hashmap
::
<
uint
,
&
uint
>
(
uint
::
hash
,
uint
::
eq
);
let
buggy_map
:
hashmap
<
uint
,
&
uint
>
=
hashmap
::
<
uint
,
&
uint
>
(|
x
|
{
uint
::
hash
(
*
x
)
},
|
x
,
y
|
{
uint
::
eq
(
*
x
,
*
y
)
});
buggy_map
.insert
(
42
,
~
1
);
//~ ERROR illegal borrow
// but it is ok if we use a temporary
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录