Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
94bcd353
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,发现更多精彩内容 >>
提交
94bcd353
编写于
9月 13, 2014
作者:
P
P1start
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Set the `non_uppercase_statics` lint to warn by default
上级
aa034cd3
变更
37
隐藏空白更改
内联
并排
Showing
37 changed file
with
234 addition
and
172 deletion
+234
-172
src/libnum/bigint.rs
src/libnum/bigint.rs
+33
-30
src/libnum/rational.rs
src/libnum/rational.rs
+3
-0
src/librand/reseeding.rs
src/librand/reseeding.rs
+3
-3
src/librustc/driver/config.rs
src/librustc/driver/config.rs
+2
-0
src/librustc/lint/builtin.rs
src/librustc/lint/builtin.rs
+1
-1
src/librustc/lint/mod.rs
src/librustc/lint/mod.rs
+1
-0
src/librustc/metadata/common.rs
src/librustc/metadata/common.rs
+1
-1
src/librustc/metadata/encoder.rs
src/librustc/metadata/encoder.rs
+1
-0
src/librustc/middle/borrowck/move_data.rs
src/librustc/middle/borrowck/move_data.rs
+2
-0
src/librustc/middle/graph.rs
src/librustc/middle/graph.rs
+4
-0
src/librustc/middle/trans/adt.rs
src/librustc/middle/trans/adt.rs
+2
-0
src/librustc/middle/trans/builder.rs
src/librustc/middle/trans/builder.rs
+2
-2
src/librustc/middle/trans/debuginfo.rs
src/librustc/middle/trans/debuginfo.rs
+7
-0
src/librustc/middle/ty.rs
src/librustc/middle/ty.rs
+5
-1
src/librustc/middle/typeck/infer/resolve.rs
src/librustc/middle/typeck/infer/resolve.rs
+2
-0
src/librustc_back/abi.rs
src/librustc_back/abi.rs
+2
-0
src/librustrt/c_str.rs
src/librustrt/c_str.rs
+15
-15
src/librustrt/libunwind.rs
src/librustrt/libunwind.rs
+1
-0
src/librustrt/local_data.rs
src/librustrt/local_data.rs
+107
-107
src/librustrt/mutex.rs
src/librustrt/mutex.rs
+4
-4
src/librustrt/util.rs
src/librustrt/util.rs
+2
-0
src/libserialize/json.rs
src/libserialize/json.rs
+2
-0
src/libstd/bitflags.rs
src/libstd/bitflags.rs
+8
-2
src/libstd/io/process.rs
src/libstd/io/process.rs
+1
-0
src/libstd/macros.rs
src/libstd/macros.rs
+2
-0
src/libstd/path/posix.rs
src/libstd/path/posix.rs
+2
-0
src/libstd/task.rs
src/libstd/task.rs
+2
-2
src/libsyntax/abi.rs
src/libsyntax/abi.rs
+3
-0
src/libsyntax/ast_util.rs
src/libsyntax/ast_util.rs
+1
-0
src/libsyntax/parse/token.rs
src/libsyntax/parse/token.rs
+5
-2
src/libsyntax/print/pprust.rs
src/libsyntax/print/pprust.rs
+2
-0
src/libuuid/lib.rs
src/libuuid/lib.rs
+1
-0
src/test/compile-fail-fulldeps/syntax-extension-regex-unused-static.rs
...ile-fail-fulldeps/syntax-extension-regex-unused-static.rs
+1
-0
src/test/compile-fail/asm-misplaced-option.rs
src/test/compile-fail/asm-misplaced-option.rs
+1
-1
src/test/compile-fail/issue-6804.rs
src/test/compile-fail/issue-6804.rs
+1
-1
src/test/compile-fail/lint-dead-code-1.rs
src/test/compile-fail/lint-dead-code-1.rs
+1
-0
src/test/compile-fail/lint-directives-on-use-items-issue-10534.rs
.../compile-fail/lint-directives-on-use-items-issue-10534.rs
+1
-0
未找到文件。
src/libnum/bigint.rs
浏览文件 @
94bcd353
...
...
@@ -86,9 +86,12 @@ pub mod BigDigit {
use
super
::
DoubleBigDigit
;
// `DoubleBigDigit` size dependent
#[allow(non_uppercase_statics)]
pub
static
bits
:
uint
=
32
;
#[allow(non_uppercase_statics)]
pub
static
base
:
DoubleBigDigit
=
1
<<
bits
;
#[allow(non_uppercase_statics)]
static
lo_mask
:
DoubleBigDigit
=
(
-
1
as
DoubleBigDigit
)
>>
bits
;
#[inline]
...
...
@@ -1841,7 +1844,7 @@ fn check(n: BigUint, ans: BigInt) {
BigInt
::
from_biguint
(
Plus
,
BigUint
::
new
(
vec!
(
1
,
2
,
3
))));
}
static
sum_triples
:
&
'static
[(
&
'static
[
BigDigit
],
static
SUM_TRIPLES
:
&
'static
[(
&
'static
[
BigDigit
],
&
'static
[
BigDigit
],
&
'static
[
BigDigit
])]
=
&
[
(
&
[],
&
[],
&
[]),
...
...
@@ -1857,7 +1860,7 @@ fn check(n: BigUint, ans: BigInt) {
#[test]
fn
test_add
()
{
for
elm
in
sum_triples
.iter
()
{
for
elm
in
SUM_TRIPLES
.iter
()
{
let
(
a_vec
,
b_vec
,
c_vec
)
=
*
elm
;
let
a
=
BigUint
::
from_slice
(
a_vec
);
let
b
=
BigUint
::
from_slice
(
b_vec
);
...
...
@@ -1870,7 +1873,7 @@ fn test_add() {
#[test]
fn
test_sub
()
{
for
elm
in
sum_triples
.iter
()
{
for
elm
in
SUM_TRIPLES
.iter
()
{
let
(
a_vec
,
b_vec
,
c_vec
)
=
*
elm
;
let
a
=
BigUint
::
from_slice
(
a_vec
);
let
b
=
BigUint
::
from_slice
(
b_vec
);
...
...
@@ -1888,7 +1891,7 @@ fn test_sub_fail_on_underflow() {
a
-
b
;
}
static
mul_triples
:
&
'static
[(
&
'static
[
BigDigit
],
static
MUL_TRIPLES
:
&
'static
[(
&
'static
[
BigDigit
],
&
'static
[
BigDigit
],
&
'static
[
BigDigit
])]
=
&
[
(
&
[],
&
[],
&
[]),
...
...
@@ -1914,7 +1917,7 @@ fn test_sub_fail_on_underflow() {
(
&
[
0
,
0
,
1
],
&
[
0
,
0
,
0
,
1
],
&
[
0
,
0
,
0
,
0
,
0
,
1
])
];
static
div_rem_quadruples
:
&
'static
[(
&
'static
[
BigDigit
],
static
DIV_REM_QUADRUPLES
:
&
'static
[(
&
'static
[
BigDigit
],
&
'static
[
BigDigit
],
&
'static
[
BigDigit
],
&
'static
[
BigDigit
])]
...
...
@@ -1928,7 +1931,7 @@ fn test_sub_fail_on_underflow() {
#[test]
fn
test_mul
()
{
for
elm
in
mul_triples
.iter
()
{
for
elm
in
MUL_TRIPLES
.iter
()
{
let
(
a_vec
,
b_vec
,
c_vec
)
=
*
elm
;
let
a
=
BigUint
::
from_slice
(
a_vec
);
let
b
=
BigUint
::
from_slice
(
b_vec
);
...
...
@@ -1938,7 +1941,7 @@ fn test_mul() {
assert
!
(
b
*
a
==
c
);
}
for
elm
in
div_rem_quadruples
.iter
()
{
for
elm
in
DIV_REM_QUADRUPLES
.iter
()
{
let
(
a_vec
,
b_vec
,
c_vec
,
d_vec
)
=
*
elm
;
let
a
=
BigUint
::
from_slice
(
a_vec
);
let
b
=
BigUint
::
from_slice
(
b_vec
);
...
...
@@ -1952,7 +1955,7 @@ fn test_mul() {
#[test]
fn
test_div_rem
()
{
for
elm
in
mul_triples
.iter
()
{
for
elm
in
MUL_TRIPLES
.iter
()
{
let
(
a_vec
,
b_vec
,
c_vec
)
=
*
elm
;
let
a
=
BigUint
::
from_slice
(
a_vec
);
let
b
=
BigUint
::
from_slice
(
b_vec
);
...
...
@@ -1966,7 +1969,7 @@ fn test_div_rem() {
}
}
for
elm
in
div_rem_quadruples
.iter
()
{
for
elm
in
DIV_REM_QUADRUPLES
.iter
()
{
let
(
a_vec
,
b_vec
,
c_vec
,
d_vec
)
=
*
elm
;
let
a
=
BigUint
::
from_slice
(
a_vec
);
let
b
=
BigUint
::
from_slice
(
b_vec
);
...
...
@@ -1979,7 +1982,7 @@ fn test_div_rem() {
#[test]
fn
test_checked_add
()
{
for
elm
in
sum_triples
.iter
()
{
for
elm
in
SUM_TRIPLES
.iter
()
{
let
(
a_vec
,
b_vec
,
c_vec
)
=
*
elm
;
let
a
=
BigUint
::
from_slice
(
a_vec
);
let
b
=
BigUint
::
from_slice
(
b_vec
);
...
...
@@ -1992,7 +1995,7 @@ fn test_checked_add() {
#[test]
fn
test_checked_sub
()
{
for
elm
in
sum_triples
.iter
()
{
for
elm
in
SUM_TRIPLES
.iter
()
{
let
(
a_vec
,
b_vec
,
c_vec
)
=
*
elm
;
let
a
=
BigUint
::
from_slice
(
a_vec
);
let
b
=
BigUint
::
from_slice
(
b_vec
);
...
...
@@ -2012,7 +2015,7 @@ fn test_checked_sub() {
#[test]
fn
test_checked_mul
()
{
for
elm
in
mul_triples
.iter
()
{
for
elm
in
MUL_TRIPLES
.iter
()
{
let
(
a_vec
,
b_vec
,
c_vec
)
=
*
elm
;
let
a
=
BigUint
::
from_slice
(
a_vec
);
let
b
=
BigUint
::
from_slice
(
b_vec
);
...
...
@@ -2022,7 +2025,7 @@ fn test_checked_mul() {
assert
!
(
b
.checked_mul
(
&
a
)
.unwrap
()
==
c
);
}
for
elm
in
div_rem_quadruples
.iter
()
{
for
elm
in
DIV_REM_QUADRUPLES
.iter
()
{
let
(
a_vec
,
b_vec
,
c_vec
,
d_vec
)
=
*
elm
;
let
a
=
BigUint
::
from_slice
(
a_vec
);
let
b
=
BigUint
::
from_slice
(
b_vec
);
...
...
@@ -2036,7 +2039,7 @@ fn test_checked_mul() {
#[test]
fn
test_checked_div
()
{
for
elm
in
mul_triples
.iter
()
{
for
elm
in
MUL_TRIPLES
.iter
()
{
let
(
a_vec
,
b_vec
,
c_vec
)
=
*
elm
;
let
a
=
BigUint
::
from_slice
(
a_vec
);
let
b
=
BigUint
::
from_slice
(
b_vec
);
...
...
@@ -2440,7 +2443,7 @@ fn check(n: BigInt, ans_1: BigUint) {
assert_eq!
(
negative
.to_biguint
(),
None
);
}
static
sum_triples
:
&
'static
[(
&
'static
[
BigDigit
],
static
SUM_TRIPLES
:
&
'static
[(
&
'static
[
BigDigit
],
&
'static
[
BigDigit
],
&
'static
[
BigDigit
])]
=
&
[
(
&
[],
&
[],
&
[]),
...
...
@@ -2456,7 +2459,7 @@ fn check(n: BigInt, ans_1: BigUint) {
#[test]
fn
test_add
()
{
for
elm
in
sum_triples
.iter
()
{
for
elm
in
SUM_TRIPLES
.iter
()
{
let
(
a_vec
,
b_vec
,
c_vec
)
=
*
elm
;
let
a
=
BigInt
::
from_slice
(
Plus
,
a_vec
);
let
b
=
BigInt
::
from_slice
(
Plus
,
b_vec
);
...
...
@@ -2475,7 +2478,7 @@ fn test_add() {
#[test]
fn
test_sub
()
{
for
elm
in
sum_triples
.iter
()
{
for
elm
in
SUM_TRIPLES
.iter
()
{
let
(
a_vec
,
b_vec
,
c_vec
)
=
*
elm
;
let
a
=
BigInt
::
from_slice
(
Plus
,
a_vec
);
let
b
=
BigInt
::
from_slice
(
Plus
,
b_vec
);
...
...
@@ -2492,7 +2495,7 @@ fn test_sub() {
}
}
static
mul_triples
:
&
'static
[(
&
'static
[
BigDigit
],
static
MUL_TRIPLES
:
&
'static
[(
&
'static
[
BigDigit
],
&
'static
[
BigDigit
],
&
'static
[
BigDigit
])]
=
&
[
(
&
[],
&
[],
&
[]),
...
...
@@ -2518,7 +2521,7 @@ fn test_sub() {
(
&
[
0
,
0
,
1
],
&
[
0
,
0
,
0
,
1
],
&
[
0
,
0
,
0
,
0
,
0
,
1
])
];
static
div_rem_quadruples
:
&
'static
[(
&
'static
[
BigDigit
],
static
DIV_REM_QUADRUPLES
:
&
'static
[(
&
'static
[
BigDigit
],
&
'static
[
BigDigit
],
&
'static
[
BigDigit
],
&
'static
[
BigDigit
])]
...
...
@@ -2532,7 +2535,7 @@ fn test_sub() {
#[test]
fn
test_mul
()
{
for
elm
in
mul_triples
.iter
()
{
for
elm
in
MUL_TRIPLES
.iter
()
{
let
(
a_vec
,
b_vec
,
c_vec
)
=
*
elm
;
let
a
=
BigInt
::
from_slice
(
Plus
,
a_vec
);
let
b
=
BigInt
::
from_slice
(
Plus
,
b_vec
);
...
...
@@ -2545,7 +2548,7 @@ fn test_mul() {
assert
!
((
-
b
)
*
a
==
-
c
);
}
for
elm
in
div_rem_quadruples
.iter
()
{
for
elm
in
DIV_REM_QUADRUPLES
.iter
()
{
let
(
a_vec
,
b_vec
,
c_vec
,
d_vec
)
=
*
elm
;
let
a
=
BigInt
::
from_slice
(
Plus
,
a_vec
);
let
b
=
BigInt
::
from_slice
(
Plus
,
b_vec
);
...
...
@@ -2584,7 +2587,7 @@ fn check(a: &BigInt, b: &BigInt, d: &BigInt, m: &BigInt) {
}
}
for
elm
in
mul_triples
.iter
()
{
for
elm
in
MUL_TRIPLES
.iter
()
{
let
(
a_vec
,
b_vec
,
c_vec
)
=
*
elm
;
let
a
=
BigInt
::
from_slice
(
Plus
,
a_vec
);
let
b
=
BigInt
::
from_slice
(
Plus
,
b_vec
);
...
...
@@ -2594,7 +2597,7 @@ fn check(a: &BigInt, b: &BigInt, d: &BigInt, m: &BigInt) {
if
!
b
.is_zero
()
{
check
(
&
c
,
&
b
,
&
a
,
&
Zero
::
zero
());
}
}
for
elm
in
div_rem_quadruples
.iter
()
{
for
elm
in
DIV_REM_QUADRUPLES
.iter
()
{
let
(
a_vec
,
b_vec
,
c_vec
,
d_vec
)
=
*
elm
;
let
a
=
BigInt
::
from_slice
(
Plus
,
a_vec
);
let
b
=
BigInt
::
from_slice
(
Plus
,
b_vec
);
...
...
@@ -2627,7 +2630,7 @@ fn check(a: &BigInt, b: &BigInt, q: &BigInt, r: &BigInt) {
check_sub
(
&
a
.neg
(),
b
,
&
q
.neg
(),
&
r
.neg
());
check_sub
(
&
a
.neg
(),
&
b
.neg
(),
q
,
&
r
.neg
());
}
for
elm
in
mul_triples
.iter
()
{
for
elm
in
MUL_TRIPLES
.iter
()
{
let
(
a_vec
,
b_vec
,
c_vec
)
=
*
elm
;
let
a
=
BigInt
::
from_slice
(
Plus
,
a_vec
);
let
b
=
BigInt
::
from_slice
(
Plus
,
b_vec
);
...
...
@@ -2637,7 +2640,7 @@ fn check(a: &BigInt, b: &BigInt, q: &BigInt, r: &BigInt) {
if
!
b
.is_zero
()
{
check
(
&
c
,
&
b
,
&
a
,
&
Zero
::
zero
());
}
}
for
elm
in
div_rem_quadruples
.iter
()
{
for
elm
in
DIV_REM_QUADRUPLES
.iter
()
{
let
(
a_vec
,
b_vec
,
c_vec
,
d_vec
)
=
*
elm
;
let
a
=
BigInt
::
from_slice
(
Plus
,
a_vec
);
let
b
=
BigInt
::
from_slice
(
Plus
,
b_vec
);
...
...
@@ -2652,7 +2655,7 @@ fn check(a: &BigInt, b: &BigInt, q: &BigInt, r: &BigInt) {
#[test]
fn
test_checked_add
()
{
for
elm
in
sum_triples
.iter
()
{
for
elm
in
SUM_TRIPLES
.iter
()
{
let
(
a_vec
,
b_vec
,
c_vec
)
=
*
elm
;
let
a
=
BigInt
::
from_slice
(
Plus
,
a_vec
);
let
b
=
BigInt
::
from_slice
(
Plus
,
b_vec
);
...
...
@@ -2671,7 +2674,7 @@ fn test_checked_add() {
#[test]
fn
test_checked_sub
()
{
for
elm
in
sum_triples
.iter
()
{
for
elm
in
SUM_TRIPLES
.iter
()
{
let
(
a_vec
,
b_vec
,
c_vec
)
=
*
elm
;
let
a
=
BigInt
::
from_slice
(
Plus
,
a_vec
);
let
b
=
BigInt
::
from_slice
(
Plus
,
b_vec
);
...
...
@@ -2690,7 +2693,7 @@ fn test_checked_sub() {
#[test]
fn
test_checked_mul
()
{
for
elm
in
mul_triples
.iter
()
{
for
elm
in
MUL_TRIPLES
.iter
()
{
let
(
a_vec
,
b_vec
,
c_vec
)
=
*
elm
;
let
a
=
BigInt
::
from_slice
(
Plus
,
a_vec
);
let
b
=
BigInt
::
from_slice
(
Plus
,
b_vec
);
...
...
@@ -2703,7 +2706,7 @@ fn test_checked_mul() {
assert
!
((
-
b
)
.checked_mul
(
&
a
)
.unwrap
()
==
-
c
);
}
for
elm
in
div_rem_quadruples
.iter
()
{
for
elm
in
DIV_REM_QUADRUPLES
.iter
()
{
let
(
a_vec
,
b_vec
,
c_vec
,
d_vec
)
=
*
elm
;
let
a
=
BigInt
::
from_slice
(
Plus
,
a_vec
);
let
b
=
BigInt
::
from_slice
(
Plus
,
b_vec
);
...
...
@@ -2716,7 +2719,7 @@ fn test_checked_mul() {
}
#[test]
fn
test_checked_div
()
{
for
elm
in
mul_triples
.iter
()
{
for
elm
in
MUL_TRIPLES
.iter
()
{
let
(
a_vec
,
b_vec
,
c_vec
)
=
*
elm
;
let
a
=
BigInt
::
from_slice
(
Plus
,
a_vec
);
let
b
=
BigInt
::
from_slice
(
Plus
,
b_vec
);
...
...
src/libnum/rational.rs
浏览文件 @
94bcd353
...
...
@@ -406,10 +406,13 @@ mod test {
pub
static
_2
:
Rational
=
Ratio
{
numer
:
2
,
denom
:
1
};
pub
static
_1_2
:
Rational
=
Ratio
{
numer
:
1
,
denom
:
2
};
pub
static
_3_2
:
Rational
=
Ratio
{
numer
:
3
,
denom
:
2
};
#[allow(non_uppercase_statics)]
pub
static
_
neg1_2
:
Rational
=
Ratio
{
numer
:
-
1
,
denom
:
2
};
pub
static
_1_3
:
Rational
=
Ratio
{
numer
:
1
,
denom
:
3
};
#[allow(non_uppercase_statics)]
pub
static
_
neg1_3
:
Rational
=
Ratio
{
numer
:
-
1
,
denom
:
3
};
pub
static
_2_3
:
Rational
=
Ratio
{
numer
:
2
,
denom
:
3
};
#[allow(non_uppercase_statics)]
pub
static
_
neg2_3
:
Rational
=
Ratio
{
numer
:
-
2
,
denom
:
3
};
pub
fn
to_big
(
n
:
Rational
)
->
BigRational
{
...
...
src/librand/reseeding.rs
浏览文件 @
94bcd353
...
...
@@ -209,15 +209,15 @@ fn test_rng_reseed() {
assert_eq!
(
string1
,
string2
);
}
static
fill_bytes_v_len
:
uint
=
13579
;
static
FILL_BYTES_V_LEN
:
uint
=
13579
;
#[test]
fn
test_rng_fill_bytes
()
{
let
mut
v
=
Vec
::
from_elem
(
fill_bytes_v_len
,
0u8
);
let
mut
v
=
Vec
::
from_elem
(
FILL_BYTES_V_LEN
,
0u8
);
::
test
::
rng
()
.fill_bytes
(
v
.as_mut_slice
());
// Sanity test: if we've gotten here, `fill_bytes` has not infinitely
// recursed.
assert_eq!
(
v
.len
(),
fill_bytes_v_len
);
assert_eq!
(
v
.len
(),
FILL_BYTES_V_LEN
);
// To test that `fill_bytes` actually did something, check that the
// average of `v` is not 0.
...
...
src/librustc/driver/config.rs
浏览文件 @
94bcd353
...
...
@@ -494,6 +494,7 @@ pub fn get_os(triple: &str) -> Option<abi::Os> {
}
None
}
#[allow(non_uppercase_statics)]
static
os_names
:
&
'static
[(
&
'static
str
,
abi
::
Os
)]
=
&
[
(
"mingw32"
,
abi
::
OsWindows
),
(
"win32"
,
abi
::
OsWindows
),
...
...
@@ -511,6 +512,7 @@ pub fn get_arch(triple: &str) -> Option<abi::Architecture> {
}
None
}
#[allow(non_uppercase_statics)]
static
architecture_abis
:
&
'static
[(
&
'static
str
,
abi
::
Architecture
)]
=
&
[
(
"i386"
,
abi
::
X86
),
(
"i486"
,
abi
::
X86
),
...
...
src/librustc/lint/builtin.rs
浏览文件 @
94bcd353
...
...
@@ -961,7 +961,7 @@ fn check_struct_def(&mut self, cx: &Context, s: &ast::StructDef,
}
}
declare_lint!
(
pub
NON_UPPERCASE_STATICS
,
Allow
,
declare_lint!
(
pub
NON_UPPERCASE_STATICS
,
Warn
,
"static constants should have uppercase identifiers"
)
pub
struct
NonUppercaseStatics
;
...
...
src/librustc/lint/mod.rs
浏览文件 @
94bcd353
...
...
@@ -98,6 +98,7 @@ pub fn name_lower(&self) -> String {
#[macro_export]
macro_rules!
lint_array
(
(
$
(
$lint:expr
),
*
)
=>
(
{
#[allow(non_uppercase_statics)]
static
array
:
LintArray
=
&
[
$
(
$lint
),
*
];
array
}
...
...
src/librustc/metadata/common.rs
浏览文件 @
94bcd353
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(non_camel_case_types)]
#![allow(non_camel_case_types
,
non_uppercase_statics
)]
use
std
::
mem
;
use
back
::
svh
::
Svh
;
...
...
src/librustc/metadata/encoder.rs
浏览文件 @
94bcd353
...
...
@@ -2028,6 +2028,7 @@ fn encode_dylib_dependency_formats(rbml_w: &mut Encoder, ecx: &EncodeContext) {
}
// NB: Increment this as you change the metadata encoding version.
#[allow(non_uppercase_statics)]
pub
static
metadata_encoding_version
:
&
'static
[
u8
]
=
&
[
b
'r'
,
b
'u'
,
b
's'
,
b
't'
,
0
,
0
,
0
,
1
];
pub
fn
encode_metadata
(
parms
:
EncodeParams
,
krate
:
&
Crate
)
->
Vec
<
u8
>
{
...
...
src/librustc/middle/borrowck/move_data.rs
浏览文件 @
94bcd353
...
...
@@ -83,6 +83,7 @@ fn clone(&self) -> MovePathIndex {
}
}
#[allow(non_uppercase_statics)]
static
InvalidMovePathIndex
:
MovePathIndex
=
MovePathIndex
(
uint
::
MAX
);
...
...
@@ -96,6 +97,7 @@ fn get(&self) -> uint {
}
}
#[allow(non_uppercase_statics)]
static
InvalidMoveIndex
:
MoveIndex
=
MoveIndex
(
uint
::
MAX
);
...
...
src/librustc/middle/graph.rs
浏览文件 @
94bcd353
...
...
@@ -57,16 +57,20 @@ pub struct Edge<E> {
#[deriving(Clone,
PartialEq,
Show)]
pub
struct
NodeIndex
(
pub
uint
);
#[allow(non_uppercase_statics)]
pub
static
InvalidNodeIndex
:
NodeIndex
=
NodeIndex
(
uint
::
MAX
);
#[deriving(PartialEq)]
pub
struct
EdgeIndex
(
pub
uint
);
#[allow(non_uppercase_statics)]
pub
static
InvalidEdgeIndex
:
EdgeIndex
=
EdgeIndex
(
uint
::
MAX
);
// Use a private field here to guarantee no more instances are created:
#[deriving(Show)]
pub
struct
Direction
{
repr
:
uint
}
#[allow(non_uppercase_statics)]
pub
static
Outgoing
:
Direction
=
Direction
{
repr
:
0
};
#[allow(non_uppercase_statics)]
pub
static
Incoming
:
Direction
=
Direction
{
repr
:
1
};
impl
NodeIndex
{
...
...
src/librustc/middle/trans/adt.rs
浏览文件 @
94bcd353
...
...
@@ -389,10 +389,12 @@ fn mk_cenum(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> Repr {
fn
range_to_inttype
(
cx
:
&
CrateContext
,
hint
:
Hint
,
bounds
:
&
IntBounds
)
->
IntType
{
debug!
(
"range_to_inttype: {:?} {:?}"
,
hint
,
bounds
);
// Lists of sizes to try. u64 is always allowed as a fallback.
#[allow(non_uppercase_statics)]
static
choose_shortest
:
&
'static
[
IntType
]
=
&
[
attr
::
UnsignedInt
(
ast
::
TyU8
),
attr
::
SignedInt
(
ast
::
TyI8
),
attr
::
UnsignedInt
(
ast
::
TyU16
),
attr
::
SignedInt
(
ast
::
TyI16
),
attr
::
UnsignedInt
(
ast
::
TyU32
),
attr
::
SignedInt
(
ast
::
TyI32
)];
#[allow(non_uppercase_statics)]
static
at_least_32
:
&
'static
[
IntType
]
=
&
[
attr
::
UnsignedInt
(
ast
::
TyU32
),
attr
::
SignedInt
(
ast
::
TyI32
)];
...
...
src/librustc/middle/trans/builder.rs
浏览文件 @
94bcd353
...
...
@@ -31,8 +31,8 @@ pub struct Builder<'a, 'tcx: 'a> {
// This is a really awful way to get a zero-length c-string, but better (and a
// lot more efficient) than doing str::as_c_str("", ...) every time.
pub
fn
noname
()
->
*
const
c_char
{
static
cnull
:
c_char
=
0
;
&
cnull
as
*
const
c_char
static
CNULL
:
c_char
=
0
;
&
CNULL
as
*
const
c_char
}
impl
<
'a
,
'tcx
>
Builder
<
'a
,
'tcx
>
{
...
...
src/librustc/middle/trans/debuginfo.rs
浏览文件 @
94bcd353
...
...
@@ -218,13 +218,20 @@ struct List {
static
DW_LANG_RUST
:
c_uint
=
0x9000
;
#[allow(non_uppercase_statics)]
static
DW_TAG_auto_variable
:
c_uint
=
0x100
;
#[allow(non_uppercase_statics)]
static
DW_TAG_arg_variable
:
c_uint
=
0x101
;
#[allow(non_uppercase_statics)]
static
DW_ATE_boolean
:
c_uint
=
0x02
;
#[allow(non_uppercase_statics)]
static
DW_ATE_float
:
c_uint
=
0x04
;
#[allow(non_uppercase_statics)]
static
DW_ATE_signed
:
c_uint
=
0x05
;
#[allow(non_uppercase_statics)]
static
DW_ATE_unsigned
:
c_uint
=
0x07
;
#[allow(non_uppercase_statics)]
static
DW_ATE_unsigned_char
:
c_uint
=
0x08
;
static
UNKNOWN_LINE_NUMBER
:
c_uint
=
0
;
...
...
src/librustc/middle/ty.rs
浏览文件 @
94bcd353
...
...
@@ -2197,7 +2197,10 @@ pub struct TypeContents {
#[allow(non_snake_case)]
mod
$mname
{
use
middle
::
ty
::
TypeContents
;
$
(
pub
static
$name
:
TypeContents
=
TypeContents
{
bits
:
$bits
};)
+
$
(
#[allow(non_uppercase_statics)]
pub
static
$name
:
TypeContents
=
TypeContents
{
bits
:
$bits
};
)
+
}
}
)
...
...
@@ -4650,6 +4653,7 @@ pub fn unboxed_closure_upvars(tcx: &ctxt, closure_id: ast::DefId)
}
pub
fn
is_binopable
(
cx
:
&
ctxt
,
ty
:
t
,
op
:
ast
::
BinOp
)
->
bool
{
#![allow(non_uppercase_statics)]
static
tycat_other
:
int
=
0
;
static
tycat_bool
:
int
=
1
;
static
tycat_char
:
int
=
2
;
...
...
src/librustc/middle/typeck/infer/resolve.rs
浏览文件 @
94bcd353
...
...
@@ -46,6 +46,8 @@
// future). If you want to resolve everything but one type, you are
// probably better off writing `resolve_all - resolve_ivar`.
#![allow(non_uppercase_statics)]
use
middle
::
ty
::{
FloatVar
,
FloatVid
,
IntVar
,
IntVid
,
RegionVid
,
TyVar
,
TyVid
};
use
middle
::
ty
::{
IntType
,
UintType
};
use
middle
::
ty
;
...
...
src/librustc_back/abi.rs
浏览文件 @
94bcd353
...
...
@@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(non_uppercase_statics)]
pub
static
box_field_refcnt
:
uint
=
0u
;
pub
static
box_field_drop_glue
:
uint
=
1u
;
pub
static
box_field_body
:
uint
=
4u
;
...
...
src/librustrt/c_str.rs
浏览文件 @
94bcd353
...
...
@@ -733,9 +733,9 @@ fn check(s: &str, c_str: *const libc::c_char) {
}
}
static
s_short
:
&
'static
str
=
"Mary"
;
static
s_medium
:
&
'static
str
=
"Mary had a little lamb"
;
static
s_long
:
&
'static
str
=
"
\
static
S_SHORT
:
&
'static
str
=
"Mary"
;
static
S_MEDIUM
:
&
'static
str
=
"Mary had a little lamb"
;
static
S_LONG
:
&
'static
str
=
"
\
Mary had a little lamb, Little lamb
Mary had a little lamb, Little lamb
Mary had a little lamb, Little lamb
...
...
@@ -752,17 +752,17 @@ fn bench_to_string(b: &mut Bencher, s: &str) {
#[bench]
fn
bench_to_c_str_short
(
b
:
&
mut
Bencher
)
{
bench_to_string
(
b
,
s_short
)
bench_to_string
(
b
,
S_SHORT
)
}
#[bench]
fn
bench_to_c_str_medium
(
b
:
&
mut
Bencher
)
{
bench_to_string
(
b
,
s_medium
)
bench_to_string
(
b
,
S_MEDIUM
)
}
#[bench]
fn
bench_to_c_str_long
(
b
:
&
mut
Bencher
)
{
bench_to_string
(
b
,
s_long
)
bench_to_string
(
b
,
S_LONG
)
}
fn
bench_to_c_str_unchecked
(
b
:
&
mut
Bencher
,
s
:
&
str
)
{
...
...
@@ -774,17 +774,17 @@ fn bench_to_c_str_unchecked(b: &mut Bencher, s: &str) {
#[bench]
fn
bench_to_c_str_unchecked_short
(
b
:
&
mut
Bencher
)
{
bench_to_c_str_unchecked
(
b
,
s_short
)
bench_to_c_str_unchecked
(
b
,
S_SHORT
)
}
#[bench]
fn
bench_to_c_str_unchecked_medium
(
b
:
&
mut
Bencher
)
{
bench_to_c_str_unchecked
(
b
,
s_medium
)
bench_to_c_str_unchecked
(
b
,
S_MEDIUM
)
}
#[bench]
fn
bench_to_c_str_unchecked_long
(
b
:
&
mut
Bencher
)
{
bench_to_c_str_unchecked
(
b
,
s_long
)
bench_to_c_str_unchecked
(
b
,
S_LONG
)
}
fn
bench_with_c_str
(
b
:
&
mut
Bencher
,
s
:
&
str
)
{
...
...
@@ -795,17 +795,17 @@ fn bench_with_c_str(b: &mut Bencher, s: &str) {
#[bench]
fn
bench_with_c_str_short
(
b
:
&
mut
Bencher
)
{
bench_with_c_str
(
b
,
s_short
)
bench_with_c_str
(
b
,
S_SHORT
)
}
#[bench]
fn
bench_with_c_str_medium
(
b
:
&
mut
Bencher
)
{
bench_with_c_str
(
b
,
s_medium
)
bench_with_c_str
(
b
,
S_MEDIUM
)
}
#[bench]
fn
bench_with_c_str_long
(
b
:
&
mut
Bencher
)
{
bench_with_c_str
(
b
,
s_long
)
bench_with_c_str
(
b
,
S_LONG
)
}
fn
bench_with_c_str_unchecked
(
b
:
&
mut
Bencher
,
s
:
&
str
)
{
...
...
@@ -818,16 +818,16 @@ fn bench_with_c_str_unchecked(b: &mut Bencher, s: &str) {
#[bench]
fn
bench_with_c_str_unchecked_short
(
b
:
&
mut
Bencher
)
{
bench_with_c_str_unchecked
(
b
,
s_short
)
bench_with_c_str_unchecked
(
b
,
S_SHORT
)
}
#[bench]
fn
bench_with_c_str_unchecked_medium
(
b
:
&
mut
Bencher
)
{
bench_with_c_str_unchecked
(
b
,
s_medium
)
bench_with_c_str_unchecked
(
b
,
S_MEDIUM
)
}
#[bench]
fn
bench_with_c_str_unchecked_long
(
b
:
&
mut
Bencher
)
{
bench_with_c_str_unchecked
(
b
,
s_long
)
bench_with_c_str_unchecked
(
b
,
S_LONG
)
}
}
src/librustrt/libunwind.rs
浏览文件 @
94bcd353
...
...
@@ -10,6 +10,7 @@
//! Unwind library interface
#![allow(non_uppercase_statics)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(dead_code)]
// these are just bindings
...
...
src/librustrt/local_data.rs
浏览文件 @
94bcd353
...
...
@@ -416,37 +416,37 @@ mod tests {
#[test]
fn
test_tls_multitask
()
{
static
my_key
:
Key
<
String
>
=
&
KeyValueKey
;
my_key
.replace
(
Some
(
"parent data"
.to_string
()));
static
MY_KEY
:
Key
<
String
>
=
&
KeyValueKey
;
MY_KEY
.replace
(
Some
(
"parent data"
.to_string
()));
task
::
spawn
(
proc
()
{
// TLD shouldn't carry over.
assert
!
(
my_key
.get
()
.is_none
());
my_key
.replace
(
Some
(
"child data"
.to_string
()));
assert
!
(
my_key
.get
()
.as_ref
()
.unwrap
()
.as_slice
()
==
"child data"
);
assert
!
(
MY_KEY
.get
()
.is_none
());
MY_KEY
.replace
(
Some
(
"child data"
.to_string
()));
assert
!
(
MY_KEY
.get
()
.as_ref
()
.unwrap
()
.as_slice
()
==
"child data"
);
// should be cleaned up for us
});
// Must work multiple times
assert
!
(
my_key
.get
()
.unwrap
()
.as_slice
()
==
"parent data"
);
assert
!
(
my_key
.get
()
.unwrap
()
.as_slice
()
==
"parent data"
);
assert
!
(
my_key
.get
()
.unwrap
()
.as_slice
()
==
"parent data"
);
assert
!
(
MY_KEY
.get
()
.unwrap
()
.as_slice
()
==
"parent data"
);
assert
!
(
MY_KEY
.get
()
.unwrap
()
.as_slice
()
==
"parent data"
);
assert
!
(
MY_KEY
.get
()
.unwrap
()
.as_slice
()
==
"parent data"
);
}
#[test]
fn
test_tls_overwrite
()
{
static
my_key
:
Key
<
String
>
=
&
KeyValueKey
;
my_key
.replace
(
Some
(
"first data"
.to_string
()));
my_key
.replace
(
Some
(
"next data"
.to_string
()));
// Shouldn't leak.
assert
!
(
my_key
.get
()
.unwrap
()
.as_slice
()
==
"next data"
);
static
MY_KEY
:
Key
<
String
>
=
&
KeyValueKey
;
MY_KEY
.replace
(
Some
(
"first data"
.to_string
()));
MY_KEY
.replace
(
Some
(
"next data"
.to_string
()));
// Shouldn't leak.
assert
!
(
MY_KEY
.get
()
.unwrap
()
.as_slice
()
==
"next data"
);
}
#[test]
fn
test_tls_pop
()
{
static
my_key
:
Key
<
String
>
=
&
KeyValueKey
;
my_key
.replace
(
Some
(
"weasel"
.to_string
()));
assert
!
(
my_key
.replace
(
None
)
.unwrap
()
==
"weasel"
.to_string
());
static
MY_KEY
:
Key
<
String
>
=
&
KeyValueKey
;
MY_KEY
.replace
(
Some
(
"weasel"
.to_string
()));
assert
!
(
MY_KEY
.replace
(
None
)
.unwrap
()
==
"weasel"
.to_string
());
// Pop must remove the data from the map.
assert
!
(
my_key
.replace
(
None
)
.is_none
());
assert
!
(
MY_KEY
.replace
(
None
)
.is_none
());
}
#[test]
...
...
@@ -457,58 +457,58 @@ fn test_tls_crust_automorestack_memorial_bug() {
// to get recorded as something within a rust stack segment. Then a
// subsequent upcall (esp. for logging, think vsnprintf) would run on
// a stack smaller than 1 MB.
static
my_key
:
Key
<
String
>
=
&
KeyValueKey
;
static
MY_KEY
:
Key
<
String
>
=
&
KeyValueKey
;
task
::
spawn
(
proc
()
{
my_key
.replace
(
Some
(
"hax"
.to_string
()));
MY_KEY
.replace
(
Some
(
"hax"
.to_string
()));
});
}
#[test]
fn
test_tls_multiple_types
()
{
static
str_key
:
Key
<
String
>
=
&
KeyValueKey
;
static
box_key
:
Key
<
Box
<
int
>>
=
&
KeyValueKey
;
static
int_key
:
Key
<
int
>
=
&
KeyValueKey
;
static
STR_KEY
:
Key
<
String
>
=
&
KeyValueKey
;
static
BOX_KEY
:
Key
<
Box
<
int
>>
=
&
KeyValueKey
;
static
INT_KEY
:
Key
<
int
>
=
&
KeyValueKey
;
task
::
spawn
(
proc
()
{
str_key
.replace
(
Some
(
"string data"
.to_string
()));
box_key
.replace
(
Some
(
box
0
));
int_key
.replace
(
Some
(
42
));
STR_KEY
.replace
(
Some
(
"string data"
.to_string
()));
BOX_KEY
.replace
(
Some
(
box
0
));
INT_KEY
.replace
(
Some
(
42
));
});
}
#[test]
fn
test_tls_overwrite_multiple_types
()
{
static
str_key
:
Key
<
String
>
=
&
KeyValueKey
;
static
box_key
:
Key
<
Box
<
int
>>
=
&
KeyValueKey
;
static
int_key
:
Key
<
int
>
=
&
KeyValueKey
;
static
STR_KEY
:
Key
<
String
>
=
&
KeyValueKey
;
static
BOX_KEY
:
Key
<
Box
<
int
>>
=
&
KeyValueKey
;
static
INT_KEY
:
Key
<
int
>
=
&
KeyValueKey
;
task
::
spawn
(
proc
()
{
str_key
.replace
(
Some
(
"string data"
.to_string
()));
str_key
.replace
(
Some
(
"string data 2"
.to_string
()));
box_key
.replace
(
Some
(
box
0
));
box_key
.replace
(
Some
(
box
1
));
int_key
.replace
(
Some
(
42
));
STR_KEY
.replace
(
Some
(
"string data"
.to_string
()));
STR_KEY
.replace
(
Some
(
"string data 2"
.to_string
()));
BOX_KEY
.replace
(
Some
(
box
0
));
BOX_KEY
.replace
(
Some
(
box
1
));
INT_KEY
.replace
(
Some
(
42
));
// This could cause a segfault if overwriting-destruction is done
// with the crazy polymorphic transmute rather than the provided
// finaliser.
int_key
.replace
(
Some
(
31337
));
INT_KEY
.replace
(
Some
(
31337
));
});
}
#[test]
#[should_fail]
fn
test_tls_cleanup_on_failure
()
{
static
str_key
:
Key
<
String
>
=
&
KeyValueKey
;
static
box_key
:
Key
<
Box
<
int
>>
=
&
KeyValueKey
;
static
int_key
:
Key
<
int
>
=
&
KeyValueKey
;
str_key
.replace
(
Some
(
"parent data"
.to_string
()));
box_key
.replace
(
Some
(
box
0
));
static
STR_KEY
:
Key
<
String
>
=
&
KeyValueKey
;
static
BOX_KEY
:
Key
<
Box
<
int
>>
=
&
KeyValueKey
;
static
INT_KEY
:
Key
<
int
>
=
&
KeyValueKey
;
STR_KEY
.replace
(
Some
(
"parent data"
.to_string
()));
BOX_KEY
.replace
(
Some
(
box
0
));
task
::
spawn
(
proc
()
{
str_key
.replace
(
Some
(
"string data"
.to_string
()));
box_key
.replace
(
Some
(
box
2
));
int_key
.replace
(
Some
(
42
));
STR_KEY
.replace
(
Some
(
"string data"
.to_string
()));
BOX_KEY
.replace
(
Some
(
box
2
));
INT_KEY
.replace
(
Some
(
42
));
fail
!
();
});
// Not quite nondeterministic.
int_key
.replace
(
Some
(
31337
));
INT_KEY
.replace
(
Some
(
31337
));
fail
!
();
}
...
...
@@ -523,9 +523,9 @@ fn drop(&mut self) {
self
.tx
.send
(());
}
}
static
key
:
Key
<
Dropper
>
=
&
KeyValueKey
;
static
KEY
:
Key
<
Dropper
>
=
&
KeyValueKey
;
let
_
=
task
::
try
(
proc
()
{
key
.replace
(
Some
(
Dropper
{
tx
:
tx
}));
KEY
.replace
(
Some
(
Dropper
{
tx
:
tx
}));
});
// At this point the task has been cleaned up and the TLD dropped.
// If the channel doesn't have a value now, then the Sender was leaked.
...
...
@@ -534,56 +534,56 @@ fn drop(&mut self) {
#[test]
fn
test_static_pointer
()
{
static
key
:
Key
<&
'static
int
>
=
&
KeyValueKey
;
static
KEY
:
Key
<&
'static
int
>
=
&
KeyValueKey
;
static
VALUE
:
int
=
0
;
key
.replace
(
Some
(
&
VALUE
));
KEY
.replace
(
Some
(
&
VALUE
));
}
#[test]
fn
test_owned
()
{
static
key
:
Key
<
Box
<
int
>>
=
&
KeyValueKey
;
key
.replace
(
Some
(
box
1
));
static
KEY
:
Key
<
Box
<
int
>>
=
&
KeyValueKey
;
KEY
.replace
(
Some
(
box
1
));
{
let
k1
=
key
.get
()
.unwrap
();
let
k2
=
key
.get
()
.unwrap
();
let
k3
=
key
.get
()
.unwrap
();
let
k1
=
KEY
.get
()
.unwrap
();
let
k2
=
KEY
.get
()
.unwrap
();
let
k3
=
KEY
.get
()
.unwrap
();
assert_eq!
(
**
k1
,
1
);
assert_eq!
(
**
k2
,
1
);
assert_eq!
(
**
k3
,
1
);
}
key
.replace
(
Some
(
box
2
));
assert_eq!
(
**
key
.get
()
.unwrap
(),
2
);
KEY
.replace
(
Some
(
box
2
));
assert_eq!
(
**
KEY
.get
()
.unwrap
(),
2
);
}
#[test]
fn
test_same_key_type
()
{
static
key
1
:
Key
<
int
>
=
&
KeyValueKey
;
static
key
2
:
Key
<
int
>
=
&
KeyValueKey
;
static
key
3
:
Key
<
int
>
=
&
KeyValueKey
;
static
key
4
:
Key
<
int
>
=
&
KeyValueKey
;
static
key
5
:
Key
<
int
>
=
&
KeyValueKey
;
key
1
.replace
(
Some
(
1
));
key
2
.replace
(
Some
(
2
));
key
3
.replace
(
Some
(
3
));
key
4
.replace
(
Some
(
4
));
key
5
.replace
(
Some
(
5
));
assert_eq!
(
*
key
1
.get
()
.unwrap
(),
1
);
assert_eq!
(
*
key
2
.get
()
.unwrap
(),
2
);
assert_eq!
(
*
key
3
.get
()
.unwrap
(),
3
);
assert_eq!
(
*
key
4
.get
()
.unwrap
(),
4
);
assert_eq!
(
*
key
5
.get
()
.unwrap
(),
5
);
static
KEY
1
:
Key
<
int
>
=
&
KeyValueKey
;
static
KEY
2
:
Key
<
int
>
=
&
KeyValueKey
;
static
KEY
3
:
Key
<
int
>
=
&
KeyValueKey
;
static
KEY
4
:
Key
<
int
>
=
&
KeyValueKey
;
static
KEY
5
:
Key
<
int
>
=
&
KeyValueKey
;
KEY
1
.replace
(
Some
(
1
));
KEY
2
.replace
(
Some
(
2
));
KEY
3
.replace
(
Some
(
3
));
KEY
4
.replace
(
Some
(
4
));
KEY
5
.replace
(
Some
(
5
));
assert_eq!
(
*
KEY
1
.get
()
.unwrap
(),
1
);
assert_eq!
(
*
KEY
2
.get
()
.unwrap
(),
2
);
assert_eq!
(
*
KEY
3
.get
()
.unwrap
(),
3
);
assert_eq!
(
*
KEY
4
.get
()
.unwrap
(),
4
);
assert_eq!
(
*
KEY
5
.get
()
.unwrap
(),
5
);
}
#[test]
#[should_fail]
fn
test_nested_get_set1
()
{
static
key
:
Key
<
int
>
=
&
KeyValueKey
;
assert_eq!
(
key
.replace
(
Some
(
4
)),
None
);
static
KEY
:
Key
<
int
>
=
&
KeyValueKey
;
assert_eq!
(
KEY
.replace
(
Some
(
4
)),
None
);
let
_
k
=
key
.get
();
key
.replace
(
Some
(
4
));
let
_
k
=
KEY
.get
();
KEY
.replace
(
Some
(
4
));
}
// ClearKey is a RAII class that ensures the keys are cleared from the map.
...
...
@@ -601,95 +601,95 @@ fn drop(&mut self) {
#[bench]
fn
bench_replace_none
(
b
:
&
mut
test
::
Bencher
)
{
static
key
:
Key
<
uint
>
=
&
KeyValueKey
;
let
_
clear
=
ClearKey
(
key
);
key
.replace
(
None
);
static
KEY
:
Key
<
uint
>
=
&
KeyValueKey
;
let
_
clear
=
ClearKey
(
KEY
);
KEY
.replace
(
None
);
b
.iter
(||
{
key
.replace
(
None
)
KEY
.replace
(
None
)
});
}
#[bench]
fn
bench_replace_some
(
b
:
&
mut
test
::
Bencher
)
{
static
key
:
Key
<
uint
>
=
&
KeyValueKey
;
let
_
clear
=
ClearKey
(
key
);
key
.replace
(
Some
(
1u
));
static
KEY
:
Key
<
uint
>
=
&
KeyValueKey
;
let
_
clear
=
ClearKey
(
KEY
);
KEY
.replace
(
Some
(
1u
));
b
.iter
(||
{
key
.replace
(
Some
(
2
))
KEY
.replace
(
Some
(
2
))
});
}
#[bench]
fn
bench_replace_none_some
(
b
:
&
mut
test
::
Bencher
)
{
static
key
:
Key
<
uint
>
=
&
KeyValueKey
;
let
_
clear
=
ClearKey
(
key
);
key
.replace
(
Some
(
0u
));
static
KEY
:
Key
<
uint
>
=
&
KeyValueKey
;
let
_
clear
=
ClearKey
(
KEY
);
KEY
.replace
(
Some
(
0u
));
b
.iter
(||
{
let
old
=
key
.replace
(
None
)
.unwrap
();
let
old
=
KEY
.replace
(
None
)
.unwrap
();
let
new
=
old
+
1
;
key
.replace
(
Some
(
new
))
KEY
.replace
(
Some
(
new
))
});
}
#[bench]
fn
bench_100_keys_replace_last
(
b
:
&
mut
test
::
Bencher
)
{
static
keys
:
[
KeyValue
<
uint
>
,
..
100
]
=
[
KeyValueKey
,
..
100
];
let
_
clear
=
keys
.iter
()
.map
(
ClearKey
)
.collect
::
<
Vec
<
ClearKey
<
uint
>>>
();
for
(
i
,
key
)
in
keys
.iter
()
.enumerate
()
{
static
KEYS
:
[
KeyValue
<
uint
>
,
..
100
]
=
[
KeyValueKey
,
..
100
];
let
_
clear
=
KEYS
.iter
()
.map
(
ClearKey
)
.collect
::
<
Vec
<
ClearKey
<
uint
>>>
();
for
(
i
,
key
)
in
KEYS
.iter
()
.enumerate
()
{
key
.replace
(
Some
(
i
));
}
b
.iter
(||
{
let
key
:
Key
<
uint
>
=
&
keys
[
99
];
let
key
:
Key
<
uint
>
=
&
KEYS
[
99
];
key
.replace
(
Some
(
42
))
});
}
#[bench]
fn
bench_1000_keys_replace_last
(
b
:
&
mut
test
::
Bencher
)
{
static
keys
:
[
KeyValue
<
uint
>
,
..
1000
]
=
[
KeyValueKey
,
..
1000
];
let
_
clear
=
keys
.iter
()
.map
(
ClearKey
)
.collect
::
<
Vec
<
ClearKey
<
uint
>>>
();
for
(
i
,
key
)
in
keys
.iter
()
.enumerate
()
{
static
KEYS
:
[
KeyValue
<
uint
>
,
..
1000
]
=
[
KeyValueKey
,
..
1000
];
let
_
clear
=
KEYS
.iter
()
.map
(
ClearKey
)
.collect
::
<
Vec
<
ClearKey
<
uint
>>>
();
for
(
i
,
key
)
in
KEYS
.iter
()
.enumerate
()
{
key
.replace
(
Some
(
i
));
}
b
.iter
(||
{
let
key
:
Key
<
uint
>
=
&
keys
[
999
];
let
key
:
Key
<
uint
>
=
&
KEYS
[
999
];
key
.replace
(
Some
(
42
))
});
for
key
in
keys
.iter
()
{
key
.clear
();
}
for
key
in
KEYS
.iter
()
{
key
.clear
();
}
}
#[bench]
fn
bench_get
(
b
:
&
mut
test
::
Bencher
)
{
static
key
:
Key
<
uint
>
=
&
KeyValueKey
;
let
_
clear
=
ClearKey
(
key
);
key
.replace
(
Some
(
42
));
static
KEY
:
Key
<
uint
>
=
&
KeyValueKey
;
let
_
clear
=
ClearKey
(
KEY
);
KEY
.replace
(
Some
(
42
));
b
.iter
(||
{
key
.get
()
KEY
.get
()
});
}
#[bench]
fn
bench_100_keys_get_last
(
b
:
&
mut
test
::
Bencher
)
{
static
keys
:
[
KeyValue
<
uint
>
,
..
100
]
=
[
KeyValueKey
,
..
100
];
let
_
clear
=
keys
.iter
()
.map
(
ClearKey
)
.collect
::
<
Vec
<
ClearKey
<
uint
>>>
();
for
(
i
,
key
)
in
keys
.iter
()
.enumerate
()
{
static
KEYS
:
[
KeyValue
<
uint
>
,
..
100
]
=
[
KeyValueKey
,
..
100
];
let
_
clear
=
KEYS
.iter
()
.map
(
ClearKey
)
.collect
::
<
Vec
<
ClearKey
<
uint
>>>
();
for
(
i
,
key
)
in
KEYS
.iter
()
.enumerate
()
{
key
.replace
(
Some
(
i
));
}
b
.iter
(||
{
let
key
:
Key
<
uint
>
=
&
keys
[
99
];
let
key
:
Key
<
uint
>
=
&
KEYS
[
99
];
key
.get
()
});
}
#[bench]
fn
bench_1000_keys_get_last
(
b
:
&
mut
test
::
Bencher
)
{
static
keys
:
[
KeyValue
<
uint
>
,
..
1000
]
=
[
KeyValueKey
,
..
1000
];
let
_
clear
=
keys
.iter
()
.map
(
ClearKey
)
.collect
::
<
Vec
<
ClearKey
<
uint
>>>
();
for
(
i
,
key
)
in
keys
.iter
()
.enumerate
()
{
static
KEYS
:
[
KeyValue
<
uint
>
,
..
1000
]
=
[
KeyValueKey
,
..
1000
];
let
_
clear
=
KEYS
.iter
()
.map
(
ClearKey
)
.collect
::
<
Vec
<
ClearKey
<
uint
>>>
();
for
(
i
,
key
)
in
KEYS
.iter
()
.enumerate
()
{
key
.replace
(
Some
(
i
));
}
b
.iter
(||
{
let
key
:
Key
<
uint
>
=
&
keys
[
999
];
let
key
:
Key
<
uint
>
=
&
KEYS
[
999
];
key
.get
()
});
}
...
...
src/librustrt/mutex.rs
浏览文件 @
94bcd353
...
...
@@ -376,8 +376,8 @@ mod os {
#[cfg(target_arch
=
"arm"
)]
static
__
PTHREAD_COND_SIZE__
:
uint
=
24
;
static
_
PTHREAD_MUTEX_SIG_
init
:
libc
::
c_long
=
0x32AAABA7
;
static
_
PTHREAD_COND_SIG_
init
:
libc
::
c_long
=
0x3CB0B1BB
;
static
_
PTHREAD_MUTEX_SIG_
INIT
:
libc
::
c_long
=
0x32AAABA7
;
static
_
PTHREAD_COND_SIG_
INIT
:
libc
::
c_long
=
0x3CB0B1BB
;
#[repr(C)]
pub
struct
pthread_mutex_t
{
...
...
@@ -391,11 +391,11 @@ pub struct pthread_cond_t {
}
pub
static
PTHREAD_MUTEX_INITIALIZER
:
pthread_mutex_t
=
pthread_mutex_t
{
__
sig
:
_
PTHREAD_MUTEX_SIG_
init
,
__
sig
:
_
PTHREAD_MUTEX_SIG_
INIT
,
__
opaque
:
[
0
,
..
__
PTHREAD_MUTEX_SIZE__
],
};
pub
static
PTHREAD_COND_INITIALIZER
:
pthread_cond_t
=
pthread_cond_t
{
__
sig
:
_
PTHREAD_COND_SIG_
init
,
__
sig
:
_
PTHREAD_COND_SIG_
INIT
,
__
opaque
:
[
0
,
..
__
PTHREAD_COND_SIZE__
],
};
}
...
...
src/librustrt/util.rs
浏览文件 @
94bcd353
...
...
@@ -28,7 +28,9 @@
pub
struct
Stdio
(
libc
::
c_int
);
#[allow(non_uppercase_statics)]
pub
static
Stdout
:
Stdio
=
Stdio
(
libc
::
STDOUT_FILENO
);
#[allow(non_uppercase_statics)]
pub
static
Stderr
:
Stdio
=
Stdio
(
libc
::
STDERR_FILENO
);
impl
fmt
::
FormatWriter
for
Stdio
{
...
...
src/libserialize/json.rs
浏览文件 @
94bcd353
...
...
@@ -360,7 +360,9 @@ fn escape_char(writer: &mut io::Writer, v: char) -> Result<(), io::IoError> {
}
fn
spaces
(
wr
:
&
mut
io
::
Writer
,
mut
n
:
uint
)
->
Result
<
(),
io
::
IoError
>
{
#[allow(non_uppercase_statics)]
static
len
:
uint
=
16
;
#[allow(non_uppercase_statics)]
static
buf
:
[
u8
,
..
len
]
=
[
b
' '
,
..
len
];
while
n
>=
len
{
...
...
src/libstd/bitflags.rs
浏览文件 @
94bcd353
...
...
@@ -123,7 +123,10 @@ pub struct $BitFlags {
bits
:
$T
,
}
$
(
$
(
#[
$
Flag_attr]
)
*
pub
static
$Flag
:
$BitFlags
=
$BitFlags
{
bits
:
$value
};)
+
$
(
#[allow(non_uppercase_statics)]
$
(
#[
$
Flag_attr]
)
*
pub
static
$Flag
:
$BitFlags
=
$BitFlags
{
bits
:
$value
};
)
+
impl
$BitFlags
{
/// Returns an empty set of flags.
...
...
@@ -240,7 +243,10 @@ fn not(&self) -> $BitFlags {
bitflags!
{
$
(
#[
$
attr]
)
*
flags
$BitFlags
:
$T
{
$
(
$
(
#[
$
Flag_attr]
)
*
static
$Flag
=
$value
),
+
$
(
#[allow(non_uppercase_statics)]
$
(
#[
$
Flag_attr]
)
*
static
$Flag
=
$value
),
+
}
}
};
...
...
src/libstd/io/process.rs
浏览文件 @
94bcd353
...
...
@@ -11,6 +11,7 @@
//! Bindings for executing child processes
#![allow(experimental)]
#![allow(non_uppercase_statics)]
use
prelude
::
*
;
...
...
src/libstd/macros.rs
浏览文件 @
94bcd353
...
...
@@ -304,9 +304,11 @@ fn _run_fmt(fmt: &::std::fmt::Arguments) -> ! {
#[macro_export]
macro_rules!
local_data_key
(
(
$name:ident
:
$ty:ty
)
=>
(
#[allow(non_uppercase_statics)]
static
$name
:
::
std
::
local_data
::
Key
<
$ty
>
=
&
::
std
::
local_data
::
KeyValueKey
;
);
(
pub
$name:ident
:
$ty:ty
)
=>
(
#[allow(non_uppercase_statics)]
pub
static
$name
:
::
std
::
local_data
::
Key
<
$ty
>
=
&
::
std
::
local_data
::
KeyValueKey
;
);
)
...
...
src/libstd/path/posix.rs
浏览文件 @
94bcd353
...
...
@@ -457,7 +457,9 @@ fn normalize_helper<'a>(v: &'a [u8], is_abs: bool) -> Option<Vec<&'a [u8]>> {
}
}
#[allow(non_uppercase_statics)]
static
dot_static
:
&
'static
[
u8
]
=
b
"."
;
#[allow(non_uppercase_statics)]
static
dot_dot_static
:
&
'static
[
u8
]
=
b
".."
;
#[cfg(test)]
...
...
src/libstd/task.rs
浏览文件 @
94bcd353
...
...
@@ -569,10 +569,10 @@ fn test_child_doesnt_ref_parent() {
// climbing the task tree to dereference each ancestor. (See #1789)
// (well, it would if the constant were 8000+ - I lowered it to be more
// valgrind-friendly. try this at home, instead..!)
static
generations
:
uint
=
16
;
static
GENERATIONS
:
uint
=
16
;
fn
child_no
(
x
:
uint
)
->
proc
():
Send
{
return
proc
()
{
if
x
<
generations
{
if
x
<
GENERATIONS
{
TaskBuilder
::
new
()
.spawn
(
child_no
(
x
+
1
));
}
}
...
...
src/libsyntax/abi.rs
浏览文件 @
94bcd353
...
...
@@ -47,7 +47,9 @@ pub enum Architecture {
Mipsel
}
#[allow(non_uppercase_statics)]
static
IntelBits
:
u32
=
(
1
<<
(
X86
as
uint
))
|
(
1
<<
(
X86_64
as
uint
));
#[allow(non_uppercase_statics)]
static
ArmBits
:
u32
=
(
1
<<
(
Arm
as
uint
));
pub
struct
AbiData
{
...
...
@@ -70,6 +72,7 @@ pub enum AbiArchitecture {
Archs
(
u32
)
}
#[allow(non_uppercase_statics)]
static
AbiDatas
:
&
'static
[
AbiData
]
=
&
[
// Platform-specific ABIs
AbiData
{
abi
:
Cdecl
,
name
:
"cdecl"
,
abi_arch
:
Archs
(
IntelBits
)},
...
...
src/libsyntax/ast_util.rs
浏览文件 @
94bcd353
...
...
@@ -293,6 +293,7 @@ pub fn operator_prec(op: ast::BinOp) -> uint {
/// Precedence of the `as` operator, which is a binary operator
/// not appearing in the prior table.
#[allow(non_uppercase_statics)]
pub
static
as_prec
:
uint
=
12u
;
pub
fn
empty_generics
()
->
Generics
{
...
...
src/libsyntax/parse/token.rs
浏览文件 @
94bcd353
...
...
@@ -383,12 +383,15 @@ pub mod keywords {
pub
mod
special_idents
{
use
ast
::{
Ident
,
Name
};
$
(
pub
static
$si_static
:
Ident
=
Ident
{
name
:
Name
(
$si_name
),
ctxt
:
0
};
)
*
$
(
#[allow(non_uppercase_statics)]
pub
static
$si_static
:
Ident
=
Ident
{
name
:
Name
(
$si_name
),
ctxt
:
0
};
)
*
}
pub
mod
special_names
{
use
ast
::
Name
;
$
(
pub
static
$si_static
:
Name
=
Name
(
$si_name
);
)
*
$
(
#[allow(non_uppercase_statics)]
pub
static
$si_static
:
Name
=
Name
(
$si_name
);
)
*
}
/**
...
...
src/libsyntax/print/pprust.rs
浏览文件 @
94bcd353
...
...
@@ -89,8 +89,10 @@ pub fn rust_printer_annotated<'a>(writer: Box<io::Writer+'static>,
}
}
#[allow(non_uppercase_statics)]
pub
static
indent_unit
:
uint
=
4u
;
#[allow(non_uppercase_statics)]
pub
static
default_columns
:
uint
=
78u
;
/// Requires you to pass an input filename and reader so that
...
...
src/libuuid/lib.rs
浏览文件 @
94bcd353
...
...
@@ -173,6 +173,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
}
// Length of each hyphenated group in hex digits
#[allow(non_uppercase_statics)]
static
UuidGroupLens
:
[
uint
,
..
5
]
=
[
8u
,
4u
,
4u
,
4u
,
12u
];
/// UUID support
...
...
src/test/compile-fail-fulldeps/syntax-extension-regex-unused-static.rs
浏览文件 @
94bcd353
...
...
@@ -17,6 +17,7 @@
#[deny(unused_variable)]
#[deny(dead_code)]
#[allow(non_uppercase_statics)]
// Tests to make sure that extraneous dead code warnings aren't emitted from
// the code generated by regex!.
...
...
src/test/compile-fail/asm-misplaced-option.rs
浏览文件 @
94bcd353
...
...
@@ -12,7 +12,7 @@
#![feature(asm)]
#![allow(dead_code)]
#![allow(dead_code
,
non_uppercase_statics
)]
#[cfg(any(target_arch
=
"x86"
,
target_arch
=
"x86_64"
))]
...
...
src/test/compile-fail/issue-6804.rs
浏览文件 @
94bcd353
...
...
@@ -30,4 +30,4 @@ fn main() {
// At least one error is needed so that compilation fails
#[static_assert]
static
b
:
bool
=
false
;
//~ ERROR static assertion failed
static
B
:
bool
=
false
;
//~ ERROR static assertion failed
src/test/compile-fail/lint-dead-code-1.rs
浏览文件 @
94bcd353
...
...
@@ -11,6 +11,7 @@
#![no_std]
#![allow(unused_variable)]
#![allow(non_camel_case_types)]
#![allow(non_uppercase_statics)]
#![deny(dead_code)]
#![feature(lang_items)]
...
...
src/test/compile-fail/lint-directives-on-use-items-issue-10534.rs
浏览文件 @
94bcd353
...
...
@@ -9,6 +9,7 @@
// except according to those terms.
#![deny(unused_imports)]
#![allow(non_uppercase_statics)]
// The aim of this test is to ensure that deny/allow/warn directives
// are applied to individual "use" statements instead of silently
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录