Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
49ea3d48
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,发现更多精彩内容 >>
提交
49ea3d48
编写于
6月 11, 2016
作者:
V
Vadim Petrochenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove unnecessary accessor function VariantDefData::kind
上级
2cdd9f1c
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
21 addition
and
31 deletion
+21
-31
src/librustc/mir/repr.rs
src/librustc/mir/repr.rs
+1
-1
src/librustc/ty/mod.rs
src/librustc/ty/mod.rs
+0
-8
src/librustc_const_eval/check_match.rs
src/librustc_const_eval/check_match.rs
+4
-4
src/librustc_metadata/decoder.rs
src/librustc_metadata/decoder.rs
+1
-1
src/librustc_metadata/encoder.rs
src/librustc_metadata/encoder.rs
+2
-2
src/librustc_trans/consts.rs
src/librustc_trans/consts.rs
+1
-1
src/librustc_trans/debuginfo/metadata.rs
src/librustc_trans/debuginfo/metadata.rs
+4
-4
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+6
-8
src/librustc_typeck/collect.rs
src/librustc_typeck/collect.rs
+1
-1
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+1
-1
未找到文件。
src/librustc/mir/repr.rs
浏览文件 @
49ea3d48
...
...
@@ -1063,7 +1063,7 @@ fn fmt_tuple(fmt: &mut Formatter, lvs: &[Operand]) -> fmt::Result {
Some
(
tcx
.lookup_item_type
(
variant_def
.did
)
.generics
)
})
?
;
match
variant_def
.kind
()
{
match
variant_def
.kind
{
ty
::
VariantKind
::
Unit
=>
Ok
(()),
ty
::
VariantKind
::
Tuple
=>
fmt_tuple
(
fmt
,
lvs
),
ty
::
VariantKind
::
Struct
=>
{
...
...
src/librustc/ty/mod.rs
浏览文件 @
49ea3d48
...
...
@@ -1925,14 +1925,6 @@ fn fields_iter(&self) -> slice::Iter<FieldDefData<'tcx, 'container>> {
self
.fields
.iter
()
}
pub
fn
kind
(
&
self
)
->
VariantKind
{
self
.kind
}
pub
fn
is_tuple_struct
(
&
self
)
->
bool
{
self
.kind
()
==
VariantKind
::
Tuple
}
#[inline]
pub
fn
find_field_named
(
&
self
,
name
:
ast
::
Name
)
...
...
src/librustc_const_eval/check_match.rs
浏览文件 @
49ea3d48
...
...
@@ -246,9 +246,9 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat)
let
pat_ty
=
cx
.tcx
.pat_ty
(
p
);
if
let
ty
::
TyEnum
(
edef
,
_
)
=
pat_ty
.sty
{
if
let
Def
::
Local
(
..
)
=
cx
.tcx
.expect_def
(
p
.id
)
{
if
edef
.variants
.iter
()
.any
(|
variant
|
variant
.name
==
name
.node
&&
variant
.kind
()
==
VariantKind
::
Unit
)
{
if
edef
.variants
.iter
()
.any
(|
variant
|
{
variant
.name
==
name
.node
&&
variant
.kind
==
VariantKind
::
Unit
}
)
{
let
ty_path
=
cx
.tcx
.item_path_str
(
edef
.did
);
let
mut
err
=
struct_span_warn!
(
cx
.tcx.sess
,
p
.span
,
E0170
,
"pattern binding `{}` is named the same as one
\
...
...
@@ -563,7 +563,7 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
ty
::
TyEnum
(
adt
,
_
)
|
ty
::
TyStruct
(
adt
,
_
)
=>
{
let
v
=
ctor
.variant_for_adt
(
adt
);
match
v
.kind
()
{
match
v
.kind
{
VariantKind
::
Struct
=>
{
let
field_pats
:
hir
::
HirVec
<
_
>
=
v
.fields
.iter
()
.zip
(
pats
)
...
...
src/librustc_metadata/decoder.rs
浏览文件 @
49ea3d48
...
...
@@ -498,7 +498,7 @@ fn get_struct_variant<'tcx>(intr: &IdentInterner,
// this needs to be done *after* the variant is interned,
// to support recursive structures
for
variant
in
&
adt
.variants
{
if
variant
.kind
()
==
ty
::
VariantKind
::
Tuple
&&
if
variant
.kind
==
ty
::
VariantKind
::
Tuple
&&
adt
.adt_kind
()
==
ty
::
AdtKind
::
Enum
{
// tuple-like enum variant fields aren't real items - get the types
// from the ctor.
...
...
src/librustc_metadata/encoder.rs
浏览文件 @
49ea3d48
...
...
@@ -217,7 +217,7 @@ fn encode_parent_item(rbml_w: &mut Encoder, id: DefId) {
fn
encode_struct_fields
(
rbml_w
:
&
mut
Encoder
,
variant
:
ty
::
VariantDef
)
{
for
f
in
&
variant
.fields
{
if
variant
.
is_tuple_struct
()
{
if
variant
.
kind
==
ty
::
VariantKind
::
Tuple
{
rbml_w
.start_tag
(
tag_item_unnamed_field
);
}
else
{
rbml_w
.start_tag
(
tag_item_field
);
...
...
@@ -250,7 +250,7 @@ fn encode_enum_variant_info<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
let
_
task
=
index
.record
(
vid
,
rbml_w
);
rbml_w
.start_tag
(
tag_items_data_item
);
encode_def_id_and_key
(
ecx
,
rbml_w
,
vid
);
encode_family
(
rbml_w
,
match
variant
.kind
()
{
encode_family
(
rbml_w
,
match
variant
.kind
{
ty
::
VariantKind
::
Struct
=>
'V'
,
ty
::
VariantKind
::
Tuple
=>
'v'
,
ty
::
VariantKind
::
Unit
=>
'w'
,
...
...
src/librustc_trans/consts.rs
浏览文件 @
49ea3d48
...
...
@@ -901,7 +901,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
}
Def
::
Variant
(
enum_did
,
variant_did
)
=>
{
let
vinfo
=
cx
.tcx
()
.lookup_adt_def
(
enum_did
)
.variant_with_id
(
variant_did
);
match
vinfo
.kind
()
{
match
vinfo
.kind
{
ty
::
VariantKind
::
Unit
=>
{
let
repr
=
adt
::
represent_type
(
cx
,
ety
);
adt
::
trans_const
(
cx
,
&
repr
,
Disr
::
from
(
vinfo
.disr_val
),
&
[])
...
...
src/librustc_trans/debuginfo/metadata.rs
浏览文件 @
49ea3d48
...
...
@@ -1109,7 +1109,7 @@ struct StructMemberDescriptionFactory<'tcx> {
impl
<
'tcx
>
StructMemberDescriptionFactory
<
'tcx
>
{
fn
create_member_descriptions
<
'a
>
(
&
self
,
cx
:
&
CrateContext
<
'a
,
'tcx
>
)
->
Vec
<
MemberDescription
>
{
if
let
ty
::
VariantKind
::
Unit
=
self
.variant
.kind
()
{
if
self
.variant.kind
==
ty
::
VariantKind
::
Unit
{
return
Vec
::
new
();
}
...
...
@@ -1126,7 +1126,7 @@ fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
};
self
.variant.fields
.iter
()
.enumerate
()
.map
(|(
i
,
f
)|
{
let
name
=
if
let
ty
::
VariantKind
::
Tuple
=
self
.variant
.kind
()
{
let
name
=
if
self
.variant.kind
==
ty
::
VariantKind
::
Tuple
{
format!
(
"__{}"
,
i
)
}
else
{
f
.name
.to_string
()
...
...
@@ -1356,7 +1356,7 @@ fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
// For the metadata of the wrapper struct, we need to create a
// MemberDescription of the struct's single field.
let
sole_struct_member_description
=
MemberDescription
{
name
:
match
non_null_variant
.kind
()
{
name
:
match
non_null_variant
.kind
{
ty
::
VariantKind
::
Tuple
=>
"__0"
.to_string
(),
ty
::
VariantKind
::
Struct
=>
{
non_null_variant
.fields
[
0
]
.name
.to_string
()
...
...
@@ -1524,7 +1524,7 @@ fn describe_enum_variant<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
containing_scope
);
// Get the argument names from the enum variant info
let
mut
arg_names
:
Vec
<
_
>
=
match
variant
.kind
()
{
let
mut
arg_names
:
Vec
<
_
>
=
match
variant
.kind
{
ty
::
VariantKind
::
Unit
=>
vec!
[],
ty
::
VariantKind
::
Tuple
=>
{
variant
.fields
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
49ea3d48
...
...
@@ -1671,10 +1671,8 @@ pub fn def_struct_variant(&self,
_
=>
return
None
};
let
var_kind
=
variant
.kind
();
if
var_kind
==
ty
::
VariantKind
::
Struct
{
Some
((
adt
,
variant
))
}
else
if
var_kind
==
ty
::
VariantKind
::
Unit
{
if
variant
.kind
==
ty
::
VariantKind
::
Struct
||
variant
.kind
==
ty
::
VariantKind
::
Unit
{
Some
((
adt
,
variant
))
}
else
{
None
...
...
@@ -2998,7 +2996,7 @@ fn check_tup_field(&self,
while
let
Some
((
base_t
,
autoderefs
))
=
autoderef
.next
()
{
let
field
=
match
base_t
.sty
{
ty
::
TyStruct
(
base_def
,
substs
)
=>
{
tuple_like
=
base_def
.struct_variant
()
.
is_tuple_struct
()
;
tuple_like
=
base_def
.struct_variant
()
.
kind
==
ty
::
VariantKind
::
Tuple
;
if
!
tuple_like
{
continue
}
debug!
(
"tuple struct named {:?}"
,
base_t
);
...
...
src/librustc_typeck/collect.rs
浏览文件 @
49ea3d48
...
...
@@ -949,7 +949,7 @@ fn convert_variant_ctor<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
scheme
:
ty
::
TypeScheme
<
'tcx
>
,
predicates
:
ty
::
GenericPredicates
<
'tcx
>
)
{
let
tcx
=
ccx
.tcx
;
let
ctor_ty
=
match
variant
.kind
()
{
let
ctor_ty
=
match
variant
.kind
{
VariantKind
::
Unit
|
VariantKind
::
Struct
=>
scheme
.ty
,
VariantKind
::
Tuple
=>
{
let
inputs
:
Vec
<
_
>
=
...
...
src/librustdoc/clean/mod.rs
浏览文件 @
49ea3d48
...
...
@@ -1904,7 +1904,7 @@ fn clean(&self, cx: &DocContext) -> Item {
impl
<
'tcx
>
Clean
<
Item
>
for
ty
::
VariantDefData
<
'tcx
,
'static
>
{
fn
clean
(
&
self
,
cx
:
&
DocContext
)
->
Item
{
let
kind
=
match
self
.kind
()
{
let
kind
=
match
self
.kind
{
ty
::
VariantKind
::
Unit
=>
CLikeVariant
,
ty
::
VariantKind
::
Tuple
=>
{
TupleVariant
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录