Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
9047b201
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,发现更多精彩内容 >>
提交
9047b201
编写于
2月 27, 2016
作者:
V
Vadim Petrochenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move span into `StructField`
+ some cleanup in rustdoc
上级
8b026a6e
变更
18
显示空白变更内容
内联
并排
Showing
18 changed file
with
79 addition
and
98 deletion
+79
-98
src/librustc/front/map/collector.rs
src/librustc/front/map/collector.rs
+3
-3
src/librustc/lint/context.rs
src/librustc/lint/context.rs
+1
-1
src/librustc/middle/dead.rs
src/librustc/middle/dead.rs
+10
-10
src/librustc/middle/stability.rs
src/librustc/middle/stability.rs
+1
-1
src/librustc_front/fold.rs
src/librustc_front/fold.rs
+7
-10
src/librustc_front/hir.rs
src/librustc_front/hir.rs
+3
-4
src/librustc_front/intravisit.rs
src/librustc_front/intravisit.rs
+3
-3
src/librustc_front/lowering.rs
src/librustc_front/lowering.rs
+7
-9
src/librustc_front/print/pprust.rs
src/librustc_front/print/pprust.rs
+6
-6
src/librustc_front/util.rs
src/librustc_front/util.rs
+1
-1
src/librustc_lint/bad_style.rs
src/librustc_lint/bad_style.rs
+1
-1
src/librustc_lint/builtin.rs
src/librustc_lint/builtin.rs
+4
-4
src/librustc_metadata/encoder.rs
src/librustc_metadata/encoder.rs
+2
-2
src/librustc_privacy/lib.rs
src/librustc_privacy/lib.rs
+7
-7
src/librustc_resolve/build_reduced_graph.rs
src/librustc_resolve/build_reduced_graph.rs
+1
-1
src/librustc_typeck/check/wfcheck.rs
src/librustc_typeck/check/wfcheck.rs
+1
-1
src/librustc_typeck/collect.rs
src/librustc_typeck/collect.rs
+10
-10
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+11
-24
未找到文件。
src/librustc/front/map/collector.rs
浏览文件 @
9047b201
...
...
@@ -150,8 +150,8 @@ fn visit_item(&mut self, i: &'ast Item) {
for
field
in
v
.node.data
.fields
()
{
self
.create_def_with_parent
(
Some
(
variant_def_index
),
field
.
node.
id
,
DefPathData
::
Field
(
field
.n
ode.n
ame
));
field
.id
,
DefPathData
::
Field
(
field
.name
));
}
}
}
...
...
@@ -166,7 +166,7 @@ fn visit_item(&mut self, i: &'ast Item) {
}
for
field
in
struct_def
.fields
()
{
self
.create_def
(
field
.
node.id
,
DefPathData
::
Field
(
field
.node
.name
));
self
.create_def
(
field
.
id
,
DefPathData
::
Field
(
field
.name
));
}
}
ItemTrait
(
_
,
_
,
ref
bounds
,
_
)
=>
{
...
...
src/librustc/lint/context.rs
浏览文件 @
9047b201
...
...
@@ -811,7 +811,7 @@ fn visit_variant_data(&mut self,
}
fn
visit_struct_field
(
&
mut
self
,
s
:
&
hir
::
StructField
)
{
self
.with_lint_attrs
(
&
s
.
node.
attrs
,
|
cx
|
{
self
.with_lint_attrs
(
&
s
.attrs
,
|
cx
|
{
run_lints!
(
cx
,
check_struct_field
,
late_passes
,
s
);
hir_visit
::
walk_struct_field
(
cx
,
s
);
})
...
...
src/librustc/middle/dead.rs
浏览文件 @
9047b201
...
...
@@ -221,9 +221,9 @@ fn visit_variant_data(&mut self, def: &hir::VariantData, _: ast::Name,
let
has_extern_repr
=
self
.struct_has_extern_repr
;
let
inherited_pub_visibility
=
self
.inherited_pub_visibility
;
let
live_fields
=
def
.fields
()
.iter
()
.filter
(|
f
|
{
has_extern_repr
||
inherited_pub_visibility
||
f
.
node.
vis
==
hir
::
Public
has_extern_repr
||
inherited_pub_visibility
||
f
.vis
==
hir
::
Public
});
self
.live_symbols
.extend
(
live_fields
.map
(|
f
|
f
.
node.
id
));
self
.live_symbols
.extend
(
live_fields
.map
(|
f
|
f
.id
));
intravisit
::
walk_struct_def
(
self
,
def
);
}
...
...
@@ -428,16 +428,16 @@ fn should_warn_about_item(&mut self, item: &hir::Item) -> bool {
should_warn
&&
!
self
.symbol_is_live
(
item
.id
,
ctor_id
)
}
fn
should_warn_about_field
(
&
mut
self
,
node
:
&
hir
::
StructField_
)
->
bool
{
let
field_type
=
self
.tcx
.node_id_to_type
(
node
.id
);
fn
should_warn_about_field
(
&
mut
self
,
field
:
&
hir
::
StructField
)
->
bool
{
let
field_type
=
self
.tcx
.node_id_to_type
(
field
.id
);
let
is_marker_field
=
match
field_type
.ty_to_def_id
()
{
Some
(
def_id
)
=>
self
.tcx.lang_items
.items
()
.iter
()
.any
(|
item
|
*
item
==
Some
(
def_id
)),
_
=>
false
};
!
node
.is_positional
()
&&
!
self
.symbol_is_live
(
node
.id
,
None
)
!
field
.is_positional
()
&&
!
self
.symbol_is_live
(
field
.id
,
None
)
&&
!
is_marker_field
&&
!
has_allow_dead_code_or_lang_attr
(
&
node
.attrs
)
&&
!
has_allow_dead_code_or_lang_attr
(
&
field
.attrs
)
}
fn
should_warn_about_variant
(
&
mut
self
,
variant
:
&
hir
::
Variant_
)
->
bool
{
...
...
@@ -543,9 +543,9 @@ fn visit_foreign_item(&mut self, fi: &hir::ForeignItem) {
}
fn
visit_struct_field
(
&
mut
self
,
field
:
&
hir
::
StructField
)
{
if
self
.should_warn_about_field
(
&
field
.node
)
{
self
.warn_dead_code
(
field
.
node.
id
,
field
.span
,
field
.n
ode.n
ame
,
"struct field"
);
if
self
.should_warn_about_field
(
&
field
)
{
self
.warn_dead_code
(
field
.id
,
field
.span
,
field
.name
,
"struct field"
);
}
intravisit
::
walk_struct_field
(
self
,
field
);
...
...
src/librustc/middle/stability.rs
浏览文件 @
9047b201
...
...
@@ -259,7 +259,7 @@ fn visit_variant(&mut self, var: &Variant, g: &'v Generics, item_id: NodeId) {
}
fn
visit_struct_field
(
&
mut
self
,
s
:
&
StructField
)
{
self
.annotate
(
s
.
node.id
,
&
s
.node
.attrs
,
s
.span
,
AnnotationKind
::
Required
,
|
v
|
{
self
.annotate
(
s
.
id
,
&
s
.attrs
,
s
.span
,
AnnotationKind
::
Required
,
|
v
|
{
intravisit
::
walk_struct_field
(
v
,
s
);
});
}
...
...
src/librustc_front/fold.rs
浏览文件 @
9047b201
...
...
@@ -700,16 +700,13 @@ pub fn noop_fold_poly_trait_ref<T: Folder>(p: PolyTraitRef, fld: &mut T) -> Poly
}
pub
fn
noop_fold_struct_field
<
T
:
Folder
>
(
f
:
StructField
,
fld
:
&
mut
T
)
->
StructField
{
let
StructField
{
node
:
StructField_
{
id
,
name
,
vis
,
ty
,
attrs
},
span
}
=
f
;
Spanned
{
node
:
StructField_
{
id
:
fld
.new_id
(
id
),
name
:
name
,
vis
:
vis
,
ty
:
fld
.fold_ty
(
ty
),
attrs
:
fold_attrs
(
attrs
,
fld
),
},
span
:
fld
.new_span
(
span
),
StructField
{
span
:
fld
.new_span
(
f
.span
),
id
:
fld
.new_id
(
f
.id
),
name
:
f
.name
,
vis
:
f
.vis
,
ty
:
fld
.fold_ty
(
f
.ty
),
attrs
:
fold_attrs
(
f
.attrs
,
fld
),
}
}
...
...
src/librustc_front/hir.rs
浏览文件 @
9047b201
...
...
@@ -1241,7 +1241,8 @@ pub fn inherit_from(&self, parent_visibility: Visibility) -> Visibility {
}
#[derive(Clone,
PartialEq,
Eq,
RustcEncodable,
RustcDecodable,
Hash,
Debug)]
pub
struct
StructField_
{
pub
struct
StructField
{
pub
span
:
Span
,
pub
name
:
Name
,
pub
vis
:
Visibility
,
pub
id
:
NodeId
,
...
...
@@ -1249,9 +1250,7 @@ pub struct StructField_ {
pub
attrs
:
HirVec
<
Attribute
>
,
}
pub
type
StructField
=
Spanned
<
StructField_
>
;
impl
StructField_
{
impl
StructField
{
// Still necessary in couple of places
pub
fn
is_positional
(
&
self
)
->
bool
{
let
first
=
self
.name
.as_str
()
.as_bytes
()[
0
];
...
...
src/librustc_front/intravisit.rs
浏览文件 @
9047b201
...
...
@@ -669,9 +669,9 @@ pub fn walk_struct_def<'v, V: Visitor<'v>>(visitor: &mut V, struct_definition: &
}
pub
fn
walk_struct_field
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
struct_field
:
&
'v
StructField
)
{
visitor
.visit_name
(
struct_field
.span
,
struct_field
.n
ode.n
ame
);
visitor
.visit_ty
(
&
struct_field
.
node.
ty
);
walk_list!
(
visitor
,
visit_attribute
,
&
struct_field
.
node.
attrs
);
visitor
.visit_name
(
struct_field
.span
,
struct_field
.name
);
visitor
.visit_ty
(
&
struct_field
.ty
);
walk_list!
(
visitor
,
visit_attribute
,
&
struct_field
.attrs
);
}
pub
fn
walk_block
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
block
:
&
'v
Block
)
{
...
...
src/librustc_front/lowering.rs
浏览文件 @
9047b201
...
...
@@ -612,16 +612,14 @@ pub fn lower_poly_trait_ref(lctx: &LoweringContext, p: &PolyTraitRef) -> hir::Po
pub
fn
lower_struct_field
(
lctx
:
&
LoweringContext
,
(
index
,
f
):
(
usize
,
&
StructField
))
->
hir
::
StructField
{
Spanne
d
{
node
:
hir
::
StructField_
{
hir
::
StructFiel
d
{
span
:
f
.span
,
id
:
f
.node.id
,
name
:
f
.node
.ident
()
.map
(|
ident
|
ident
.name
)
.unwrap_or
(
token
::
intern
(
&
index
.to_string
())),
vis
:
lower_visibility
(
lctx
,
f
.node.kind
.visibility
()),
ty
:
lower_ty
(
lctx
,
&
f
.node.ty
),
attrs
:
lower_attrs
(
lctx
,
&
f
.node.attrs
),
},
span
:
f
.span
,
}
}
...
...
src/librustc_front/print/pprust.rs
浏览文件 @
9047b201
...
...
@@ -915,9 +915,9 @@ pub fn print_struct(&mut self,
if
struct_def
.is_tuple
()
{
try!
(
self
.popen
());
try!
(
self
.commasep
(
Inconsistent
,
struct_def
.fields
(),
|
s
,
field
|
{
try!
(
s
.print_visibility
(
field
.
node.
vis
));
try!
(
s
.print_visibility
(
field
.vis
));
try!
(
s
.maybe_print_comment
(
field
.span.lo
));
s
.print_type
(
&
field
.
node.
ty
)
s
.print_type
(
&
field
.ty
)
}));
try!
(
self
.pclose
());
}
...
...
@@ -936,11 +936,11 @@ pub fn print_struct(&mut self,
for
field
in
struct_def
.fields
()
{
try!
(
self
.hardbreak_if_not_bol
());
try!
(
self
.maybe_print_comment
(
field
.span.lo
));
try!
(
self
.print_outer_attributes
(
&
field
.
node.
attrs
));
try!
(
self
.print_visibility
(
field
.
node.
vis
));
try!
(
self
.print_name
(
field
.n
ode.n
ame
));
try!
(
self
.print_outer_attributes
(
&
field
.attrs
));
try!
(
self
.print_visibility
(
field
.vis
));
try!
(
self
.print_name
(
field
.name
));
try!
(
self
.word_nbsp
(
":"
));
try!
(
self
.print_type
(
&
field
.
node.
ty
));
try!
(
self
.print_type
(
&
field
.ty
));
try!
(
word
(
&
mut
self
.s
,
","
));
}
...
...
src/librustc_front/util.rs
浏览文件 @
9047b201
...
...
@@ -271,7 +271,7 @@ fn visit_fn(&mut self,
}
fn
visit_struct_field
(
&
mut
self
,
struct_field
:
&
StructField
)
{
self
.operation
.visit_id
(
struct_field
.
node.
id
);
self
.operation
.visit_id
(
struct_field
.id
);
intravisit
::
walk_struct_field
(
self
,
struct_field
)
}
...
...
src/librustc_lint/bad_style.rs
浏览文件 @
9047b201
...
...
@@ -283,7 +283,7 @@ fn check_pat(&mut self, cx: &LateContext, p: &hir::Pat) {
fn
check_struct_def
(
&
mut
self
,
cx
:
&
LateContext
,
s
:
&
hir
::
VariantData
,
_
:
ast
::
Name
,
_
:
&
hir
::
Generics
,
_
:
ast
::
NodeId
)
{
for
sf
in
s
.fields
()
{
self
.check_snake_case
(
cx
,
"structure field"
,
&
sf
.n
ode.n
ame
.as_str
(),
Some
(
sf
.span
));
self
.check_snake_case
(
cx
,
"structure field"
,
&
sf
.name
.as_str
(),
Some
(
sf
.span
));
}
}
}
...
...
src/librustc_lint/builtin.rs
浏览文件 @
9047b201
...
...
@@ -126,7 +126,7 @@ fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
hir
::
ItemStruct
(
ref
struct_def
,
_
)
=>
{
for
struct_field
in
struct_def
.fields
()
{
self
.check_heap_type
(
cx
,
struct_field
.span
,
cx
.tcx
.node_id_to_type
(
struct_field
.
node.
id
));
cx
.tcx
.node_id_to_type
(
struct_field
.id
));
}
}
_
=>
()
...
...
@@ -428,12 +428,12 @@ fn check_impl_item(&mut self, cx: &LateContext, impl_item: &hir::ImplItem) {
}
fn
check_struct_field
(
&
mut
self
,
cx
:
&
LateContext
,
sf
:
&
hir
::
StructField
)
{
if
!
sf
.
node
.
is_positional
()
{
if
sf
.
node.
vis
==
hir
::
Public
||
self
.in_variant
{
if
!
sf
.is_positional
()
{
if
sf
.vis
==
hir
::
Public
||
self
.in_variant
{
let
cur_struct_def
=
*
self
.struct_def_stack
.last
()
.expect
(
"empty struct_def_stack"
);
self
.check_missing_docs_attrs
(
cx
,
Some
(
cur_struct_def
),
&
sf
.
node.
attrs
,
sf
.span
,
&
sf
.attrs
,
sf
.span
,
"a struct field"
)
}
}
...
...
src/librustc_metadata/encoder.rs
浏览文件 @
9047b201
...
...
@@ -1751,9 +1751,9 @@ struct StructFieldVisitor<'a, 'b:'a, 'c:'a, 'tcx:'b> {
impl
<
'a
,
'b
,
'c
,
'tcx
,
'v
>
Visitor
<
'v
>
for
StructFieldVisitor
<
'a
,
'b
,
'c
,
'tcx
>
{
fn
visit_struct_field
(
&
mut
self
,
field
:
&
hir
::
StructField
)
{
self
.rbml_w
.start_tag
(
tag_struct_field
);
let
def_id
=
self
.ecx.tcx.map
.local_def_id
(
field
.
node.
id
);
let
def_id
=
self
.ecx.tcx.map
.local_def_id
(
field
.id
);
encode_def_id
(
self
.rbml_w
,
def_id
);
encode_attributes
(
self
.rbml_w
,
&
field
.
node.
attrs
);
encode_attributes
(
self
.rbml_w
,
&
field
.attrs
);
self
.rbml_w
.end_tag
();
}
}
...
...
src/librustc_privacy/lib.rs
浏览文件 @
9047b201
...
...
@@ -147,7 +147,7 @@ fn visit_variant_data(&mut self, s: &hir::VariantData, _: ast::Name,
// While we have the id of the struct definition, go ahead and parent
// all the fields.
for
field
in
s
.fields
()
{
self
.parents
.insert
(
field
.
node.
id
,
self
.curparent
);
self
.parents
.insert
(
field
.id
,
self
.curparent
);
}
intravisit
::
walk_struct_def
(
self
,
s
)
}
...
...
@@ -262,7 +262,7 @@ fn visit_item(&mut self, item: &hir::Item) {
for
variant
in
&
def
.variants
{
let
variant_level
=
self
.update
(
variant
.node.data
.id
(),
item_level
);
for
field
in
variant
.node.data
.fields
()
{
self
.update
(
field
.
node.
id
,
variant_level
);
self
.update
(
field
.id
,
variant_level
);
}
}
}
...
...
@@ -288,8 +288,8 @@ fn visit_item(&mut self, item: &hir::Item) {
self
.update
(
def
.id
(),
item_level
);
}
for
field
in
def
.fields
()
{
if
field
.
node.
vis
==
hir
::
Public
{
self
.update
(
field
.
node.
id
,
item_level
);
if
field
.vis
==
hir
::
Public
{
self
.update
(
field
.id
,
item_level
);
}
}
}
...
...
@@ -347,7 +347,7 @@ fn visit_item(&mut self, item: &hir::Item) {
if
item_level
.is_some
()
{
self
.reach
()
.visit_generics
(
generics
);
for
field
in
struct_def
.fields
()
{
if
self
.get
(
field
.
node.
id
)
.is_some
()
{
if
self
.get
(
field
.id
)
.is_some
()
{
self
.reach
()
.visit_struct_field
(
field
);
}
}
...
...
@@ -1514,7 +1514,7 @@ fn visit_variant(&mut self, v: &hir::Variant, g: &hir::Generics, item_id: ast::N
}
fn
visit_struct_field
(
&
mut
self
,
s
:
&
hir
::
StructField
)
{
if
s
.
node.
vis
==
hir
::
Public
||
self
.in_variant
{
if
s
.vis
==
hir
::
Public
||
self
.in_variant
{
intravisit
::
walk_struct_field
(
self
,
s
);
}
}
...
...
@@ -1725,7 +1725,7 @@ fn visit_item(&mut self, item: &hir::Item) {
if
item
.vis
==
hir
::
Public
{
check
.visit_generics
(
generics
);
for
field
in
struct_def
.fields
()
{
if
field
.
node.
vis
==
hir
::
Public
{
if
field
.vis
==
hir
::
Public
{
check
.visit_struct_field
(
field
);
}
}
...
...
src/librustc_resolve/build_reduced_graph.rs
浏览文件 @
9047b201
...
...
@@ -382,7 +382,7 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent: Module<'b>) -> M
// Record the def ID and fields of this struct.
let
field_names
=
struct_def
.fields
()
.iter
()
.map
(|
f
|
f
.n
ode.n
ame
)
.map
(|
f
|
f
.name
)
.collect
();
let
item_def_id
=
self
.ast_map
.local_def_id
(
item
.id
);
self
.structs
.insert
(
item_def_id
,
field_names
);
...
...
src/librustc_typeck/check/wfcheck.rs
浏览文件 @
9047b201
...
...
@@ -567,7 +567,7 @@ fn struct_variant<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
let
fields
=
struct_def
.fields
()
.iter
()
.map
(|
field
|
{
let
field_ty
=
fcx
.tcx
()
.node_id_to_type
(
field
.
node.
id
);
let
field_ty
=
fcx
.tcx
()
.node_id_to_type
(
field
.id
);
let
field_ty
=
fcx
.instantiate_type_scheme
(
field
.span
,
&
fcx
.inh
.infcx
...
...
src/librustc_typeck/collect.rs
浏览文件 @
9047b201
...
...
@@ -574,20 +574,20 @@ fn convert_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
fn
convert_field
<
'a
,
'tcx
>
(
ccx
:
&
CrateCtxt
<
'a
,
'tcx
>
,
struct_generics
:
&
ty
::
Generics
<
'tcx
>
,
struct_predicates
:
&
ty
::
GenericPredicates
<
'tcx
>
,
v
:
&
hir
::
StructField
,
field
:
&
hir
::
StructField
,
ty_f
:
ty
::
FieldDefMaster
<
'tcx
>
)
{
let
tt
=
ccx
.icx
(
struct_predicates
)
.to_ty
(
&
ExplicitRscope
,
&
v
.node
.ty
);
let
tt
=
ccx
.icx
(
struct_predicates
)
.to_ty
(
&
ExplicitRscope
,
&
field
.ty
);
ty_f
.fulfill_ty
(
tt
);
write_ty_to_tcx
(
ccx
.tcx
,
v
.node
.id
,
tt
);
write_ty_to_tcx
(
ccx
.tcx
,
field
.id
,
tt
);
/* add the field to the tcache */
ccx
.tcx
.register_item_type
(
ccx
.tcx.map
.local_def_id
(
v
.node
.id
),
ccx
.tcx
.register_item_type
(
ccx
.tcx.map
.local_def_id
(
field
.id
),
ty
::
TypeScheme
{
generics
:
struct_generics
.clone
(),
ty
:
tt
});
ccx
.tcx.predicates
.borrow_mut
()
.insert
(
ccx
.tcx.map
.local_def_id
(
v
.node
.id
),
ccx
.tcx.predicates
.borrow_mut
()
.insert
(
ccx
.tcx.map
.local_def_id
(
field
.id
),
struct_predicates
.clone
());
}
...
...
@@ -977,19 +977,19 @@ fn convert_struct_variant<'tcx>(tcx: &ty::ctxt<'tcx>,
def
:
&
hir
::
VariantData
)
->
ty
::
VariantDefData
<
'tcx
,
'tcx
>
{
let
mut
seen_fields
:
FnvHashMap
<
ast
::
Name
,
Span
>
=
FnvHashMap
();
let
fields
=
def
.fields
()
.iter
()
.map
(|
f
|
{
let
fid
=
tcx
.map
.local_def_id
(
f
.
node.
id
);
let
dup_span
=
seen_fields
.get
(
&
f
.n
ode.n
ame
)
.cloned
();
let
fid
=
tcx
.map
.local_def_id
(
f
.id
);
let
dup_span
=
seen_fields
.get
(
&
f
.name
)
.cloned
();
if
let
Some
(
prev_span
)
=
dup_span
{
let
mut
err
=
struct_span_err!
(
tcx
.sess
,
f
.span
,
E0124
,
"field `{}` is already declared"
,
f
.n
ode.n
ame
);
f
.name
);
span_note!
(
&
mut
err
,
prev_span
,
"previously declared here"
);
err
.emit
();
}
else
{
seen_fields
.insert
(
f
.n
ode.n
ame
,
f
.span
);
seen_fields
.insert
(
f
.name
,
f
.span
);
}
ty
::
FieldDefData
::
new
(
fid
,
f
.n
ode.name
,
f
.node
.vis
)
ty
::
FieldDefData
::
new
(
fid
,
f
.n
ame
,
f
.vis
)
})
.collect
();
ty
::
VariantDefData
{
did
:
did
,
...
...
src/librustdoc/clean/mod.rs
浏览文件 @
9047b201
...
...
@@ -1735,16 +1735,15 @@ pub enum StructField {
impl
Clean
<
Item
>
for
hir
::
StructField
{
fn
clean
(
&
self
,
cx
:
&
DocContext
)
->
Item
{
let
name
=
if
self
.node
.is_positional
()
{
None
}
else
{
Some
(
self
.node.name
)
};
Item
{
name
:
name
.clean
(
cx
),
attrs
:
self
.
node.
attrs
.clean
(
cx
),
name
:
Some
(
self
.name
)
.clean
(
cx
),
attrs
:
self
.attrs
.clean
(
cx
),
source
:
self
.span
.clean
(
cx
),
visibility
:
Some
(
self
.
node.
vis
),
stability
:
get_stability
(
cx
,
cx
.map
.local_def_id
(
self
.
node.
id
)),
deprecation
:
get_deprecation
(
cx
,
cx
.map
.local_def_id
(
self
.
node.
id
)),
def_id
:
cx
.map
.local_def_id
(
self
.
node.
id
),
inner
:
StructFieldItem
(
TypedStructField
(
self
.
node.
ty
.clean
(
cx
))),
visibility
:
Some
(
self
.vis
),
stability
:
get_stability
(
cx
,
cx
.map
.local_def_id
(
self
.id
)),
deprecation
:
get_deprecation
(
cx
,
cx
.map
.local_def_id
(
self
.id
)),
def_id
:
cx
.map
.local_def_id
(
self
.id
),
inner
:
StructFieldItem
(
TypedStructField
(
self
.ty
.clean
(
cx
))),
}
}
}
...
...
@@ -1752,22 +1751,10 @@ fn clean(&self, cx: &DocContext) -> Item {
impl
<
'tcx
>
Clean
<
Item
>
for
ty
::
FieldDefData
<
'tcx
,
'static
>
{
fn
clean
(
&
self
,
cx
:
&
DocContext
)
->
Item
{
// FIXME: possible O(n^2)-ness! Not my fault.
let
attr_map
=
cx
.tcx
()
.sess.cstore
.crate_struct_field_attrs
(
self
.did.krate
);
let
is_positional
=
{
let
first
=
self
.name
.as_str
()
.as_bytes
()[
0
];
first
>=
b
'0'
&&
first
<=
b
'9'
};
let
(
name
,
attrs
)
=
if
is_positional
{
(
None
,
None
)
}
else
{
(
Some
(
self
.name
),
Some
(
attr_map
.get
(
&
self
.did
)
.unwrap
()))
};
let
attr_map
=
cx
.tcx
()
.sess.cstore
.crate_struct_field_attrs
(
self
.did.krate
);
Item
{
name
:
name
.clean
(
cx
),
attrs
:
attr
s
.unwrap_or
(
&
Vec
::
new
())
.clean
(
cx
),
name
:
Some
(
self
.name
)
.clean
(
cx
),
attrs
:
attr
_map
.get
(
&
self
.did
)
.unwrap_or
(
&
Vec
::
new
())
.clean
(
cx
),
source
:
Span
::
empty
(),
visibility
:
Some
(
self
.vis
),
stability
:
get_stability
(
cx
,
self
.did
),
...
...
@@ -1945,7 +1932,7 @@ fn struct_def_to_variant_kind(struct_def: &hir::VariantData, cx: &DocContext) ->
}
else
if
struct_def
.is_unit
()
{
CLikeVariant
}
else
{
TupleVariant
(
struct_def
.fields
()
.iter
()
.map
(|
x
|
x
.
node.
ty
.clean
(
cx
))
.collect
())
TupleVariant
(
struct_def
.fields
()
.iter
()
.map
(|
x
|
x
.ty
.clean
(
cx
))
.collect
())
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录