Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
f2aa8c41
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,发现更多精彩内容 >>
提交
f2aa8c41
编写于
11月 03, 2014
作者:
A
Alex Crichton
浏览文件
操作
浏览文件
下载
差异文件
rollup merge of #18593 : hirschenberger/issue-18587
Conflicts: src/test/compile-fail/lint-exceeding-bitshifts.rs
上级
5d6cd770
e7f31097
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
11 addition
and
7 deletion
+11
-7
src/librustc/lint/builtin.rs
src/librustc/lint/builtin.rs
+7
-7
src/test/compile-fail/lint-exceeding-bitshifts.rs
src/test/compile-fail/lint-exceeding-bitshifts.rs
+4
-0
未找到文件。
src/librustc/lint/builtin.rs
浏览文件 @
f2aa8c41
...
...
@@ -39,7 +39,7 @@
use
std
::
collections
::
HashMap
;
use
std
::
collections
::
hash_map
::{
Occupied
,
Vacant
};
use
std
::
slice
;
use
std
::{
i
nt
,
i8
,
i16
,
i32
,
i64
,
uint
,
u8
,
u16
,
u32
,
u64
,
f32
,
f64
};
use
std
::{
i
8
,
i16
,
i32
,
i64
,
u8
,
u16
,
u32
,
u64
,
f32
,
f64
};
use
syntax
::
abi
;
use
syntax
::
ast_map
;
use
syntax
::
ast_util
::
is_shift_binop
;
...
...
@@ -180,8 +180,8 @@ fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
if
is_shift_binop
(
binop
)
{
let
opt_ty_bits
=
match
ty
::
get
(
ty
::
expr_ty
(
cx
.tcx
,
&**
l
))
.sty
{
ty
::
ty_int
(
t
)
=>
Some
(
int_ty_bits
(
t
)),
ty
::
ty_uint
(
t
)
=>
Some
(
uint_ty_bits
(
t
)),
ty
::
ty_int
(
t
)
=>
Some
(
int_ty_bits
(
t
,
cx
.sess
()
.targ_cfg.int_type
)),
ty
::
ty_uint
(
t
)
=>
Some
(
uint_ty_bits
(
t
,
cx
.sess
()
.targ_cfg.uint_type
)),
_
=>
None
};
...
...
@@ -312,9 +312,9 @@ fn float_ty_range(float_ty: ast::FloatTy) -> (f64, f64) {
}
}
fn
int_ty_bits
(
int_ty
:
ast
::
IntTy
)
->
u64
{
fn
int_ty_bits
(
int_ty
:
ast
::
IntTy
,
target_int_ty
:
ast
::
IntTy
)
->
u64
{
match
int_ty
{
ast
::
TyI
=>
int
::
BITS
as
u64
,
ast
::
TyI
=>
int
_ty_bits
(
target_int_ty
,
target_int_ty
)
,
ast
::
TyI8
=>
i8
::
BITS
as
u64
,
ast
::
TyI16
=>
i16
::
BITS
as
u64
,
ast
::
TyI32
=>
i32
::
BITS
as
u64
,
...
...
@@ -322,9 +322,9 @@ fn int_ty_bits(int_ty: ast::IntTy) -> u64 {
}
}
fn
uint_ty_bits
(
uint_ty
:
ast
::
UintTy
)
->
u64
{
fn
uint_ty_bits
(
uint_ty
:
ast
::
UintTy
,
target_uint_ty
:
ast
::
UintTy
)
->
u64
{
match
uint_ty
{
ast
::
TyU
=>
uint
::
BITS
as
u64
,
ast
::
TyU
=>
uint
_ty_bits
(
target_uint_ty
,
target_uint_ty
)
,
ast
::
TyU8
=>
u8
::
BITS
as
u64
,
ast
::
TyU16
=>
u16
::
BITS
as
u64
,
ast
::
TyU32
=>
u32
::
BITS
as
u64
,
...
...
src/test/compile-fail/lint-exceeding-bitshifts.rs
浏览文件 @
f2aa8c41
...
...
@@ -10,6 +10,7 @@
#![deny(exceeding_bitshifts)]
#![allow(unused_variables)]
#![allow(dead_code)]
fn
main
()
{
let
n
=
1u8
<<
7
;
...
...
@@ -54,5 +55,8 @@ fn main() {
let
n
=
1u8
<<
(
4
+
3
);
let
n
=
1u8
<<
(
4
+
4
);
//~ ERROR: bitshift exceeds the type's number of bits
let
n
=
1
i
<<
std
::
int
::
BITS
;
//~ ERROR: bitshift exceeds the type's number of bits
let
n
=
1u
<<
std
::
uint
::
BITS
;
//~ ERROR: bitshift exceeds the type's number of bits
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录