Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
df126589
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,发现更多精彩内容 >>
提交
df126589
编写于
2月 27, 2015
作者:
G
Guillaume Gomez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove int/uint from libstd/lib.rs
上级
c74d49c8
变更
13
显示空白变更内容
内联
并排
Showing
13 changed file
with
39 addition
and
65 deletion
+39
-65
src/libcoretest/iter.rs
src/libcoretest/iter.rs
+7
-7
src/libcoretest/num/int.rs
src/libcoretest/num/int.rs
+0
-11
src/libcoretest/num/int_macros.rs
src/libcoretest/num/int_macros.rs
+2
-2
src/libcoretest/num/mod.rs
src/libcoretest/num/mod.rs
+0
-2
src/libcoretest/num/uint.rs
src/libcoretest/num/uint.rs
+0
-11
src/libgetopts/lib.rs
src/libgetopts/lib.rs
+1
-1
src/librustc/middle/liveness.rs
src/librustc/middle/liveness.rs
+20
-20
src/librustc_trans/trans/_match.rs
src/librustc_trans/trans/_match.rs
+1
-1
src/libstd/lib.rs
src/libstd/lib.rs
+0
-2
src/test/compile-fail/issue-8460-const.rs
src/test/compile-fail/issue-8460-const.rs
+3
-3
src/test/compile-fail/unnecessary-private.rs
src/test/compile-fail/unnecessary-private.rs
+1
-1
src/test/run-fail/bounds-check-no-overflow.rs
src/test/run-fail/bounds-check-no-overflow.rs
+2
-2
src/test/run-fail/hashmap-capacity-overflow.rs
src/test/run-fail/hashmap-capacity-overflow.rs
+2
-2
未找到文件。
src/libcoretest/iter.rs
浏览文件 @
df126589
...
...
@@ -12,7 +12,7 @@
use
core
::
iter
::
order
::
*
;
use
core
::
iter
::
MinMaxResult
::
*
;
use
core
::
num
::
SignedInt
;
use
core
::
u
int
;
use
core
::
u
size
;
use
core
::
cmp
;
use
test
::
Bencher
;
...
...
@@ -292,7 +292,7 @@ fn count(st: &mut uint) -> Option<uint> {
fn
test_cycle
()
{
let
cycle_len
=
3
;
let
it
=
count
(
0
,
1
)
.take
(
cycle_len
)
.cycle
();
assert_eq!
(
it
.size_hint
(),
(
u
int
::
MAX
,
None
));
assert_eq!
(
it
.size_hint
(),
(
u
size
::
MAX
,
None
));
for
(
i
,
x
)
in
it
.take
(
100
)
.enumerate
()
{
assert_eq!
(
i
%
cycle_len
,
x
);
}
...
...
@@ -365,19 +365,19 @@ fn test_iterator_size_hint() {
let
v2
=
&
[
10
,
11
,
12
];
let
vi
=
v
.iter
();
assert_eq!
(
c
.size_hint
(),
(
u
int
::
MAX
,
None
));
assert_eq!
(
c
.size_hint
(),
(
u
size
::
MAX
,
None
));
assert_eq!
(
vi
.clone
()
.size_hint
(),
(
10
,
Some
(
10
)));
assert_eq!
(
c
.clone
()
.take
(
5
)
.size_hint
(),
(
5
,
Some
(
5
)));
assert_eq!
(
c
.clone
()
.skip
(
5
)
.size_hint
()
.1
,
None
);
assert_eq!
(
c
.clone
()
.take_while
(|
_
|
false
)
.size_hint
(),
(
0
,
None
));
assert_eq!
(
c
.clone
()
.skip_while
(|
_
|
false
)
.size_hint
(),
(
0
,
None
));
assert_eq!
(
c
.clone
()
.enumerate
()
.size_hint
(),
(
u
int
::
MAX
,
None
));
assert_eq!
(
c
.clone
()
.chain
(
vi
.clone
()
.cloned
())
.size_hint
(),
(
u
int
::
MAX
,
None
));
assert_eq!
(
c
.clone
()
.enumerate
()
.size_hint
(),
(
u
size
::
MAX
,
None
));
assert_eq!
(
c
.clone
()
.chain
(
vi
.clone
()
.cloned
())
.size_hint
(),
(
u
size
::
MAX
,
None
));
assert_eq!
(
c
.clone
()
.zip
(
vi
.clone
())
.size_hint
(),
(
10
,
Some
(
10
)));
assert_eq!
(
c
.clone
()
.scan
(
0
,
|
_
,
_
|
Some
(
0
))
.size_hint
(),
(
0
,
None
));
assert_eq!
(
c
.clone
()
.filter
(|
_
|
false
)
.size_hint
(),
(
0
,
None
));
assert_eq!
(
c
.clone
()
.map
(|
_
|
0
)
.size_hint
(),
(
u
int
::
MAX
,
None
));
assert_eq!
(
c
.clone
()
.map
(|
_
|
0
)
.size_hint
(),
(
u
size
::
MAX
,
None
));
assert_eq!
(
c
.filter_map
(|
_
|
Some
(
0
))
.size_hint
(),
(
0
,
None
));
assert_eq!
(
vi
.clone
()
.take
(
5
)
.size_hint
(),
(
5
,
Some
(
5
)));
...
...
@@ -753,7 +753,7 @@ fn test_range() {
assert_eq!
((
0
..
100
)
.size_hint
(),
(
100
,
Some
(
100
)));
// this test is only meaningful when sizeof uint < sizeof u64
assert_eq!
((
u
int
::
MAX
-
1
..
uint
::
MAX
)
.size_hint
(),
(
1
,
Some
(
1
)));
assert_eq!
((
u
size
::
MAX
-
1
..
usize
::
MAX
)
.size_hint
(),
(
1
,
Some
(
1
)));
assert_eq!
((
-
10
..-
1
)
.size_hint
(),
(
9
,
Some
(
9
)));
assert_eq!
((
-
1
..-
10
)
.size_hint
(),
(
0
,
Some
(
0
)));
}
...
...
src/libcoretest/num/int.rs
已删除
100644 → 0
浏览文件 @
c74d49c8
// Copyright 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.
int_module!
(
int
,
int
);
src/libcoretest/num/int_macros.rs
浏览文件 @
df126589
...
...
@@ -12,7 +12,7 @@
#[cfg(test)]
mod
tests
{
use
core
::
$T_i
::
*
;
use
core
::
i
nt
;
use
core
::
i
size
;
use
core
::
num
::{
FromStrRadix
,
Int
,
SignedInt
};
use
core
::
ops
::{
Shl
,
Shr
,
Not
,
BitXor
,
BitAnd
,
BitOr
};
use
num
;
...
...
@@ -153,7 +153,7 @@ fn test_be() {
fn
test_signed_checked_div
()
{
assert!
(
10
.checked_div
(
2
)
==
Some
(
5
));
assert!
(
5
.checked_div
(
0
)
==
None
);
assert!
(
i
nt
::
MIN
.checked_div
(
-
1
)
==
None
);
assert!
(
i
size
::
MIN
.checked_div
(
-
1
)
==
None
);
}
#[test]
...
...
src/libcoretest/num/mod.rs
浏览文件 @
df126589
...
...
@@ -21,7 +21,6 @@
mod
i16
;
mod
i32
;
mod
i64
;
mod
int
;
#[macro_use]
mod
uint_macros
;
...
...
@@ -30,7 +29,6 @@
mod
u16
;
mod
u32
;
mod
u64
;
mod
uint
;
/// Helper function for testing numeric operations
pub
fn
test_num
<
T
>
(
ten
:
T
,
two
:
T
)
where
...
...
src/libcoretest/num/uint.rs
已删除
100644 → 0
浏览文件 @
c74d49c8
// Copyright 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.
uint_module!
(
uint
,
uint
);
src/libgetopts/lib.rs
浏览文件 @
df126589
...
...
@@ -963,7 +963,7 @@ fn t(s: &str, i: uint, u: &[String]) {
"little lamb"
.to_string
(),
"Little lamb"
.to_string
()
]);
t
(
"
\n
Mary had a little lamb
\n
Little lamb
\n
"
,
::
std
::
u
int
::
MAX
,
t
(
"
\n
Mary had a little lamb
\n
Little lamb
\n
"
,
::
std
::
u
size
::
MAX
,
&
[
"Mary had a little lamb
\n
Little lamb"
.to_string
()]);
}
...
...
src/librustc/middle/liveness.rs
浏览文件 @
df126589
...
...
@@ -51,8 +51,8 @@
//! enclosing function. On the way down the tree, it identifies those AST
//! nodes and variable IDs that will be needed for the liveness analysis
//! and assigns them contiguous IDs. The liveness id for an AST node is
//! called a `live_node` (it's a newtype'd u
int
) and the id for a variable
//! is called a `variable` (another newtype'd u
int
).
//! called a `live_node` (it's a newtype'd u
size
) and the id for a variable
//! is called a `variable` (another newtype'd u
size
).
//!
//! On the way back up the tree, as we are about to exit from a function
//! declaration we allocate a `liveness` instance. Now that we know
...
...
@@ -118,7 +118,7 @@
use
lint
;
use
util
::
nodemap
::
NodeMap
;
use
std
::{
fmt
,
old_io
,
u
int
};
use
std
::{
fmt
,
old_io
,
u
size
};
use
std
::
rc
::
Rc
;
use
std
::
iter
::
repeat
;
use
syntax
::
ast
::{
self
,
NodeId
,
Expr
};
...
...
@@ -138,17 +138,17 @@ enum LoopKind<'a> {
}
#[derive(Copy,
PartialEq)]
struct
Variable
(
u
int
);
struct
Variable
(
u
size
);
#[derive(Copy,
PartialEq)]
struct
LiveNode
(
u
int
);
struct
LiveNode
(
u
size
);
impl
Variable
{
fn
get
(
&
self
)
->
u
int
{
let
Variable
(
v
)
=
*
self
;
v
}
fn
get
(
&
self
)
->
u
size
{
let
Variable
(
v
)
=
*
self
;
v
}
}
impl
LiveNode
{
fn
get
(
&
self
)
->
u
int
{
let
LiveNode
(
v
)
=
*
self
;
v
}
fn
get
(
&
self
)
->
u
size
{
let
LiveNode
(
v
)
=
*
self
;
v
}
}
impl
Clone
for
LiveNode
{
...
...
@@ -232,11 +232,11 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
impl
LiveNode
{
fn
is_valid
(
&
self
)
->
bool
{
self
.get
()
!=
u
int
::
MAX
self
.get
()
!=
u
size
::
MAX
}
}
fn
invalid_node
()
->
LiveNode
{
LiveNode
(
u
int
::
MAX
)
}
fn
invalid_node
()
->
LiveNode
{
LiveNode
(
u
size
::
MAX
)
}
struct
CaptureInfo
{
ln
:
LiveNode
,
...
...
@@ -260,8 +260,8 @@ enum VarKind {
struct
IrMaps
<
'a
,
'tcx
:
'a
>
{
tcx
:
&
'a
ty
::
ctxt
<
'tcx
>
,
num_live_nodes
:
u
int
,
num_vars
:
u
int
,
num_live_nodes
:
u
size
,
num_vars
:
u
size
,
live_node_map
:
NodeMap
<
LiveNode
>
,
variable_map
:
NodeMap
<
Variable
>
,
capture_info_map
:
NodeMap
<
Rc
<
Vec
<
CaptureInfo
>>>
,
...
...
@@ -540,9 +540,9 @@ struct Specials {
clean_exit_var
:
Variable
}
static
ACC_READ
:
u
int
=
1
;
static
ACC_WRITE
:
u
int
=
2
;
static
ACC_USE
:
u
int
=
4
;
static
ACC_READ
:
u
32
=
1
;
static
ACC_WRITE
:
u
32
=
2
;
static
ACC_USE
:
u
32
=
4
;
struct
Liveness
<
'a
,
'tcx
:
'a
>
{
ir
:
&
'a
mut
IrMaps
<
'a
,
'tcx
>
,
...
...
@@ -631,7 +631,7 @@ fn define_bindings_in_arm_pats(&mut self, pat: Option<&ast::Pat>, succ: LiveNode
succ
}
fn
idx
(
&
self
,
ln
:
LiveNode
,
var
:
Variable
)
->
u
int
{
fn
idx
(
&
self
,
ln
:
LiveNode
,
var
:
Variable
)
->
u
size
{
ln
.get
()
*
self
.ir.num_vars
+
var
.get
()
}
...
...
@@ -670,7 +670,7 @@ fn assigned_on_exit(&self, ln: LiveNode, var: Variable)
}
fn
indices2
<
F
>
(
&
mut
self
,
ln
:
LiveNode
,
succ_ln
:
LiveNode
,
mut
op
:
F
)
where
F
:
FnMut
(
&
mut
Liveness
<
'a
,
'tcx
>
,
u
int
,
uint
),
F
:
FnMut
(
&
mut
Liveness
<
'a
,
'tcx
>
,
u
size
,
usize
),
{
let
node_base_idx
=
self
.idx
(
ln
,
Variable
(
0
));
let
succ_base_idx
=
self
.idx
(
succ_ln
,
Variable
(
0
));
...
...
@@ -684,7 +684,7 @@ fn write_vars<F>(&self,
ln
:
LiveNode
,
mut
test
:
F
)
->
old_io
::
IoResult
<
()
>
where
F
:
FnMut
(
u
int
)
->
LiveNode
,
F
:
FnMut
(
u
size
)
->
LiveNode
,
{
let
node_base_idx
=
self
.idx
(
ln
,
Variable
(
0
));
for
var_idx
in
0
..
self
.ir.num_vars
{
...
...
@@ -807,7 +807,7 @@ fn define(&mut self, writer: LiveNode, var: Variable) {
}
// Either read, write, or both depending on the acc bitset
fn
acc
(
&
mut
self
,
ln
:
LiveNode
,
var
:
Variable
,
acc
:
u
int
)
{
fn
acc
(
&
mut
self
,
ln
:
LiveNode
,
var
:
Variable
,
acc
:
u
32
)
{
debug!
(
"{:?} accesses[{:x}] {:?}: {}"
,
ln
,
acc
,
var
,
self
.ln_str
(
ln
));
...
...
@@ -1283,7 +1283,7 @@ fn propagate_through_lvalue_components(&mut self,
}
// see comment on propagate_through_lvalue()
fn
write_lvalue
(
&
mut
self
,
expr
:
&
Expr
,
succ
:
LiveNode
,
acc
:
u
int
)
fn
write_lvalue
(
&
mut
self
,
expr
:
&
Expr
,
succ
:
LiveNode
,
acc
:
u
32
)
->
LiveNode
{
match
expr
.node
{
ast
::
ExprPath
(
..
)
=>
{
...
...
@@ -1298,7 +1298,7 @@ fn write_lvalue(&mut self, expr: &Expr, succ: LiveNode, acc: uint)
}
}
fn
access_path
(
&
mut
self
,
expr
:
&
Expr
,
succ
:
LiveNode
,
acc
:
u
int
)
fn
access_path
(
&
mut
self
,
expr
:
&
Expr
,
succ
:
LiveNode
,
acc
:
u
32
)
->
LiveNode
{
match
self
.ir.tcx.def_map
.borrow
()[
expr
.id
]
.full_def
()
{
DefLocal
(
nid
)
=>
{
...
...
src/librustc_trans/trans/_match.rs
浏览文件 @
df126589
...
...
@@ -789,7 +789,7 @@ fn pat_score(def_map: &DefMap, pat: &ast::Pat) -> uint {
// Irrefutable columns always go first, they'd only be duplicated in the branches.
if
total_score
==
0
{
std
::
u
int
::
MAX
std
::
u
size
::
MAX
}
else
{
total_score
}
...
...
src/libstd/lib.rs
浏览文件 @
df126589
...
...
@@ -221,14 +221,12 @@
mod
uint_macros
;
#[path
=
"num/isize.rs"
]
pub
mod
isize
;
pub
use
isize
as
int
;
#[path
=
"num/i8.rs"
]
pub
mod
i8
;
#[path
=
"num/i16.rs"
]
pub
mod
i16
;
#[path
=
"num/i32.rs"
]
pub
mod
i32
;
#[path
=
"num/i64.rs"
]
pub
mod
i64
;
#[path
=
"num/usize.rs"
]
pub
mod
usize
;
pub
use
usize
as
uint
;
#[path
=
"num/u8.rs"
]
pub
mod
u8
;
#[path
=
"num/u16.rs"
]
pub
mod
u16
;
#[path
=
"num/u32.rs"
]
pub
mod
u32
;
...
...
src/test/compile-fail/issue-8460-const.rs
浏览文件 @
df126589
...
...
@@ -8,11 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use
std
::{
i
nt
,
i8
,
i16
,
i32
,
i64
};
use
std
::{
i
size
,
i8
,
i16
,
i32
,
i64
};
use
std
::
thread
;
fn
main
()
{
assert
!
(
thread
::
spawn
(
move
||
{
i
nt
::
MIN
/
-
1
;
})
.join
()
.is_err
());
assert
!
(
thread
::
spawn
(
move
||
{
i
size
::
MIN
/
-
1
;
})
.join
()
.is_err
());
//~^ ERROR attempted to divide with overflow in a constant expression
assert
!
(
thread
::
spawn
(
move
||
{
i8
::
MIN
/
-
1
;
})
.join
()
.is_err
());
//~^ ERROR attempted to divide with overflow in a constant expression
...
...
@@ -32,7 +32,7 @@ fn main() {
//~^ ERROR attempted to divide by zero in a constant expression
assert
!
(
thread
::
spawn
(
move
||
{
1i64
/
0
;
})
.join
()
.is_err
());
//~^ ERROR attempted to divide by zero in a constant expression
assert
!
(
thread
::
spawn
(
move
||
{
i
nt
::
MIN
%
-
1
;
})
.join
()
.is_err
());
assert
!
(
thread
::
spawn
(
move
||
{
i
size
::
MIN
%
-
1
;
})
.join
()
.is_err
());
//~^ ERROR attempted remainder with overflow in a constant expression
assert
!
(
thread
::
spawn
(
move
||
{
i8
::
MIN
%
-
1
;
})
.join
()
.is_err
());
//~^ ERROR attempted remainder with overflow in a constant expression
...
...
src/test/compile-fail/unnecessary-private.rs
浏览文件 @
df126589
...
...
@@ -9,7 +9,7 @@
// except according to those terms.
fn
main
()
{
pub
use
std
::
u
int
;
//~ ERROR: visibility has no effect
pub
use
std
::
u
size
;
//~ ERROR: visibility has no effect
pub
struct
A
;
//~ ERROR: visibility has no effect
pub
enum
B
{}
//~ ERROR: visibility has no effect
pub
trait
C
{
//~ ERROR: visibility has no effect
...
...
src/test/run-fail/bounds-check-no-overflow.rs
浏览文件 @
df126589
...
...
@@ -10,10 +10,10 @@
// error-pattern:index out of bounds: the len is 3 but the index is
use
std
::
u
int
;
use
std
::
u
size
;
use
std
::
mem
::
size_of
;
fn
main
()
{
let
xs
=
[
1
,
2
,
3
];
xs
[
u
int
::
MAX
/
size_of
::
<
int
>
()
+
1
];
xs
[
u
size
::
MAX
/
size_of
::
<
isize
>
()
+
1
];
}
src/test/run-fail/hashmap-capacity-overflow.rs
浏览文件 @
df126589
...
...
@@ -11,11 +11,11 @@
// error-pattern:capacity overflow
use
std
::
collections
::
hash_map
::
HashMap
;
use
std
::
u
int
;
use
std
::
u
size
;
use
std
::
mem
::
size_of
;
fn
main
()
{
let
threshold
=
u
int
::
MAX
/
size_of
::
<
(
u64
,
u64
,
u64
)
>
();
let
threshold
=
u
size
::
MAX
/
size_of
::
<
(
u64
,
u64
,
u64
)
>
();
let
mut
h
=
HashMap
::
<
u64
,
u64
>
::
with_capacity
(
threshold
+
100
);
h
.insert
(
0
,
0
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录