Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
71722b9c
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
71722b9c
编写于
8月 22, 2018
作者:
V
varkor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix rebase issues
上级
d0209c44
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
29 addition
and
29 deletion
+29
-29
src/librustc_mir/hair/pattern/_match.rs
src/librustc_mir/hair/pattern/_match.rs
+5
-5
src/librustc_mir/interpret/cast.rs
src/librustc_mir/interpret/cast.rs
+11
-11
src/librustc_mir/interpret/place.rs
src/librustc_mir/interpret/place.rs
+4
-4
src/librustc_mir/interpret/validity.rs
src/librustc_mir/interpret/validity.rs
+5
-5
src/test/ui/issues/issue-46332.rs
src/test/ui/issues/issue-46332.rs
+2
-2
src/test/ui/privacy/private-inferred-type-1.rs
src/test/ui/privacy/private-inferred-type-1.rs
+2
-2
未找到文件。
src/librustc_mir/hair/pattern/_match.rs
浏览文件 @
71722b9c
...
...
@@ -647,7 +647,7 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
.map
(|
v
|
Variant
(
v
.did
))
.collect
()
}
ty
::
Ty
Char
if
exhaustive_integer_patterns
=>
{
ty
::
Char
if
exhaustive_integer_patterns
=>
{
let
endpoint
=
|
c
:
char
|
{
let
ty
=
ty
::
ParamEnv
::
empty
()
.and
(
cx
.tcx.types.char
);
ty
::
Const
::
from_bits
(
cx
.tcx
,
c
as
u128
,
ty
)
...
...
@@ -658,7 +658,7 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
ConstantRange
(
endpoint
(
'\
u
{
E000
}
'
),
endpoint
(
'\
u
{
10
FFFF
}
'
),
RangeEnd
::
Included
),
]
}
ty
::
Ty
Int
(
ity
)
if
exhaustive_integer_patterns
=>
{
ty
::
Int
(
ity
)
if
exhaustive_integer_patterns
=>
{
// FIXME(49937): refactor these bit manipulations into interpret.
let
bits
=
Integer
::
from_attr
(
cx
.tcx
,
SignedInt
(
ity
))
.size
()
.bits
()
as
u128
;
let
min
=
1u128
<<
(
bits
-
1
);
...
...
@@ -668,7 +668,7 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
ty
::
Const
::
from_bits
(
cx
.tcx
,
max
as
u128
,
ty
),
RangeEnd
::
Included
)]
}
ty
::
Ty
Uint
(
uty
)
if
exhaustive_integer_patterns
=>
{
ty
::
Uint
(
uty
)
if
exhaustive_integer_patterns
=>
{
// FIXME(49937): refactor these bit manipulations into interpret.
let
bits
=
Integer
::
from_attr
(
cx
.tcx
,
UnsignedInt
(
uty
))
.size
()
.bits
()
as
u128
;
let
max
=
!
0u128
>>
(
128
-
bits
);
...
...
@@ -861,7 +861,7 @@ fn from_pat(tcx: TyCtxt<'_, 'tcx, 'tcx>,
// The return value of `signed_bias` should be XORed with an endpoint to encode/decode it.
fn
signed_bias
(
tcx
:
TyCtxt
<
'_
,
'tcx
,
'tcx
>
,
ty
:
Ty
<
'tcx
>
)
->
u128
{
match
ty
.sty
{
ty
::
Ty
Int
(
ity
)
=>
{
ty
::
Int
(
ity
)
=>
{
let
bits
=
Integer
::
from_attr
(
tcx
,
SignedInt
(
ity
))
.size
()
.bits
()
as
u128
;
1u128
<<
(
bits
-
1
)
}
...
...
@@ -1382,7 +1382,7 @@ fn slice_pat_covered_by_constructor<'tcx>(
fn
should_treat_range_exhaustively
(
tcx
:
TyCtxt
<
'_
,
'tcx
,
'tcx
>
,
ctor
:
&
Constructor
<
'tcx
>
)
->
bool
{
if
tcx
.features
()
.exhaustive_integer_patterns
{
if
let
ConstantValue
(
value
)
|
ConstantRange
(
value
,
_
,
_
)
=
ctor
{
if
let
ty
::
TyChar
|
ty
::
TyInt
(
_
)
|
ty
::
Ty
Uint
(
_
)
=
value
.ty.sty
{
if
let
ty
::
Char
|
ty
::
Int
(
_
)
|
ty
::
Uint
(
_
)
=
value
.ty.sty
{
return
true
;
}
}
...
...
src/librustc_mir/interpret/cast.rs
浏览文件 @
71722b9c
...
...
@@ -15,9 +15,9 @@
impl
<
'a
,
'mir
,
'tcx
,
M
:
Machine
<
'mir
,
'tcx
>>
EvalContext
<
'a
,
'mir
,
'tcx
,
M
>
{
fn
type_is_fat_ptr
(
&
self
,
ty
:
Ty
<
'tcx
>
)
->
bool
{
match
ty
.sty
{
ty
::
Ty
RawPtr
(
ty
::
TypeAndMut
{
ty
,
..
})
|
ty
::
Ty
Ref
(
_
,
ty
,
_
)
=>
!
self
.type_is_sized
(
ty
),
ty
::
Ty
Adt
(
def
,
_
)
if
def
.is_box
()
=>
!
self
.type_is_sized
(
ty
.boxed_ty
()),
ty
::
RawPtr
(
ty
::
TypeAndMut
{
ty
,
..
})
|
ty
::
Ref
(
_
,
ty
,
_
)
=>
!
self
.type_is_sized
(
ty
),
ty
::
Adt
(
def
,
_
)
if
def
.is_box
()
=>
!
self
.type_is_sized
(
ty
.boxed_ty
()),
_
=>
false
,
}
}
...
...
@@ -313,19 +313,19 @@ fn unsize_into_ptr(
let
(
src_pointee_ty
,
dest_pointee_ty
)
=
self
.tcx
.struct_lockstep_tails
(
sty
,
dty
);
match
(
&
src_pointee_ty
.sty
,
&
dest_pointee_ty
.sty
)
{
(
&
ty
::
TyArray
(
_
,
length
),
&
ty
::
Ty
Slice
(
_
))
=>
{
(
&
ty
::
Array
(
_
,
length
),
&
ty
::
Slice
(
_
))
=>
{
let
ptr
=
self
.read_value
(
src
)
?
.to_scalar_ptr
()
?
;
// u64 cast is from usize to u64, which is always good
let
val
=
Value
::
new_slice
(
ptr
,
length
.unwrap_usize
(
self
.tcx.tcx
),
self
.tcx.tcx
);
self
.write_value
(
val
,
dest
)
}
(
&
ty
::
TyDynamic
(
..
),
&
ty
::
Ty
Dynamic
(
..
))
=>
{
(
&
ty
::
Dynamic
(
..
),
&
ty
::
Dynamic
(
..
))
=>
{
// For now, upcasts are limited to changes in marker
// traits, and hence never actually require an actual
// change to the vtable.
self
.copy_op
(
src
,
dest
)
}
(
_
,
&
ty
::
Ty
Dynamic
(
ref
data
,
_
))
=>
{
(
_
,
&
ty
::
Dynamic
(
ref
data
,
_
))
=>
{
// Initial cast from sized to dyn trait
let
trait_ref
=
data
.principal
()
.unwrap
()
.with_self_ty
(
*
self
.tcx
,
...
...
@@ -348,13 +348,13 @@ fn unsize_into(
dest
:
PlaceTy
<
'tcx
>
,
)
->
EvalResult
<
'tcx
>
{
match
(
&
src
.layout.ty.sty
,
&
dest
.layout.ty.sty
)
{
(
&
ty
::
TyRef
(
_
,
s
,
_
),
&
ty
::
Ty
Ref
(
_
,
d
,
_
))
|
(
&
ty
::
TyRef
(
_
,
s
,
_
),
&
ty
::
Ty
RawPtr
(
TypeAndMut
{
ty
:
d
,
..
}))
|
(
&
ty
::
Ty
RawPtr
(
TypeAndMut
{
ty
:
s
,
..
}),
&
ty
::
Ty
RawPtr
(
TypeAndMut
{
ty
:
d
,
..
}))
=>
{
(
&
ty
::
Ref
(
_
,
s
,
_
),
&
ty
::
Ref
(
_
,
d
,
_
))
|
(
&
ty
::
Ref
(
_
,
s
,
_
),
&
ty
::
RawPtr
(
TypeAndMut
{
ty
:
d
,
..
}))
|
(
&
ty
::
RawPtr
(
TypeAndMut
{
ty
:
s
,
..
}),
&
ty
::
RawPtr
(
TypeAndMut
{
ty
:
d
,
..
}))
=>
{
self
.unsize_into_ptr
(
src
,
dest
,
s
,
d
)
}
(
&
ty
::
TyAdt
(
def_a
,
_
),
&
ty
::
Ty
Adt
(
def_b
,
_
))
=>
{
(
&
ty
::
Adt
(
def_a
,
_
),
&
ty
::
Adt
(
def_b
,
_
))
=>
{
assert_eq!
(
def_a
,
def_b
);
if
def_a
.is_box
()
||
def_b
.is_box
()
{
if
!
def_a
.is_box
()
||
!
def_b
.is_box
()
{
...
...
src/librustc_mir/interpret/place.rs
浏览文件 @
71722b9c
...
...
@@ -236,7 +236,7 @@ pub fn ref_to_mplace(
let
pointee_type
=
val
.layout.ty
.builtin_deref
(
true
)
.unwrap
()
.ty
;
let
layout
=
self
.layout_of
(
pointee_type
)
?
;
let
mplace
=
match
self
.tcx
.struct_tail
(
pointee_type
)
.sty
{
ty
::
Ty
Dynamic
(
..
)
=>
{
ty
::
Dynamic
(
..
)
=>
{
let
(
ptr
,
vtable
)
=
val
.to_scalar_dyn_trait
()
?
;
MemPlace
{
ptr
,
...
...
@@ -244,7 +244,7 @@ pub fn ref_to_mplace(
extra
:
PlaceExtra
::
Vtable
(
vtable
),
}
}
ty
::
TyStr
|
ty
::
Ty
Slice
(
_
)
=>
{
ty
::
Str
|
ty
::
Slice
(
_
)
=>
{
let
(
ptr
,
len
)
=
val
.to_scalar_slice
(
self
)
?
;
MemPlace
{
ptr
,
...
...
@@ -358,9 +358,9 @@ pub fn mplace_subslice(
// Compute extra and new layout
let
inner_len
=
len
-
to
-
from
;
let
(
extra
,
ty
)
=
match
base
.layout.ty.sty
{
ty
::
Ty
Array
(
inner
,
_
)
=>
ty
::
Array
(
inner
,
_
)
=>
(
PlaceExtra
::
None
,
self
.tcx
.mk_array
(
inner
,
inner_len
)),
ty
::
Ty
Slice
(
..
)
=>
ty
::
Slice
(
..
)
=>
(
PlaceExtra
::
Length
(
inner_len
),
base
.layout.ty
),
_
=>
bug!
(
"cannot subslice non-array type: `{:?}`"
,
base
.layout.ty
),
...
...
src/librustc_mir/interpret/validity.rs
浏览文件 @
71722b9c
...
...
@@ -139,7 +139,7 @@ fn validate_scalar(
// char gets a special treatment, because its number space is not contiguous so `TyLayout`
// has no special checks for chars
match
ty
.sty
{
ty
::
Ty
Char
=>
{
ty
::
Char
=>
{
debug_assert_eq!
(
size
.bytes
(),
4
);
if
::
std
::
char
::
from_u32
(
bits
as
u32
)
.is_none
()
{
return
validation_failure!
(
...
...
@@ -323,23 +323,23 @@ pub fn validate_mplace(
fn
aggregate_field_path_elem
(
&
self
,
ty
:
Ty
<
'tcx
>
,
variant
:
usize
,
field
:
usize
)
->
PathElem
{
match
ty
.sty
{
// generators and closures.
ty
::
TyClosure
(
def_id
,
_
)
|
ty
::
Ty
Generator
(
def_id
,
_
,
_
)
=>
{
ty
::
Closure
(
def_id
,
_
)
|
ty
::
Generator
(
def_id
,
_
,
_
)
=>
{
let
node_id
=
self
.tcx.hir
.as_local_node_id
(
def_id
)
.unwrap
();
let
freevar
=
self
.tcx
.with_freevars
(
node_id
,
|
fv
|
fv
[
field
]);
PathElem
::
ClosureVar
(
self
.tcx.hir
.name
(
freevar
.var_id
()))
}
// tuples
ty
::
T
yT
uple
(
_
)
=>
PathElem
::
TupleElem
(
field
),
ty
::
Tuple
(
_
)
=>
PathElem
::
TupleElem
(
field
),
// enums
ty
::
Ty
Adt
(
def
,
..
)
if
def
.is_enum
()
=>
{
ty
::
Adt
(
def
,
..
)
if
def
.is_enum
()
=>
{
let
variant
=
&
def
.variants
[
variant
];
PathElem
::
Field
(
variant
.fields
[
field
]
.ident.name
)
}
// other ADTs
ty
::
Ty
Adt
(
def
,
_
)
=>
PathElem
::
Field
(
def
.non_enum_variant
()
.fields
[
field
]
.ident.name
),
ty
::
Adt
(
def
,
_
)
=>
PathElem
::
Field
(
def
.non_enum_variant
()
.fields
[
field
]
.ident.name
),
// nothing else has an aggregate layout
_
=>
bug!
(
"aggregate_field_path_elem: got non-aggregate type {:?}"
,
ty
),
...
...
src/test/ui/issues/issue-46332.rs
浏览文件 @
71722b9c
...
...
@@ -11,9 +11,9 @@
// Original Levenshtein distance for both of this is 1. We improved accuracy with
// additional case insensitive comparison.
struct
Uint
{}
struct
Ty
Uint
{}
struct
Int
{}
struct
Ty
Int
{}
fn
main
()
{
TyUInt
{};
...
...
src/test/ui/privacy/private-inferred-type-1.rs
浏览文件 @
71722b9c
...
...
@@ -11,7 +11,7 @@
trait
Arr0
{
fn
arr0_secret
(
&
self
);
}
trait
Param
{
trait
Ty
Param
{
fn
ty_param_secret
(
&
self
);
}
...
...
@@ -19,7 +19,7 @@ mod m {
struct
Priv
;
impl
::
Arr0
for
[
Priv
;
0
]
{
fn
arr0_secret
(
&
self
)
{}
}
impl
::
Param
for
Option
<
Priv
>
{
fn
ty_param_secret
(
&
self
)
{}
}
impl
::
Ty
Param
for
Option
<
Priv
>
{
fn
ty_param_secret
(
&
self
)
{}
}
}
fn
main
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录