Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
8fe4290f
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,发现更多精彩内容 >>
提交
8fe4290f
编写于
4月 06, 2016
作者:
V
Vadim Petrochenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move span into `StructField`
上级
7f3744f0
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
50 addition
and
49 deletion
+50
-49
src/librustc/lint/context.rs
src/librustc/lint/context.rs
+1
-1
src/librustc_front/lowering.rs
src/librustc_front/lowering.rs
+5
-5
src/librustc_save_analysis/dump_visitor.rs
src/librustc_save_analysis/dump_visitor.rs
+2
-2
src/librustc_save_analysis/lib.rs
src/librustc_save_analysis/lib.rs
+3
-3
src/libsyntax/ast.rs
src/libsyntax/ast.rs
+2
-3
src/libsyntax/ast_util.rs
src/libsyntax/ast_util.rs
+1
-1
src/libsyntax/config.rs
src/libsyntax/config.rs
+3
-3
src/libsyntax/ext/build.rs
src/libsyntax/ext/build.rs
+3
-2
src/libsyntax/fold.rs
src/libsyntax/fold.rs
+7
-9
src/libsyntax/parse/parser.rs
src/libsyntax/parse/parser.rs
+10
-7
src/libsyntax/print/pprust.rs
src/libsyntax/print/pprust.rs
+6
-6
src/libsyntax/visit.rs
src/libsyntax/visit.rs
+3
-3
src/libsyntax_ext/deriving/generic/mod.rs
src/libsyntax_ext/deriving/generic/mod.rs
+4
-4
未找到文件。
src/librustc/lint/context.rs
浏览文件 @
8fe4290f
...
...
@@ -978,7 +978,7 @@ fn visit_variant_data(&mut self,
}
fn
visit_struct_field
(
&
mut
self
,
s
:
&
ast
::
StructField
)
{
self
.with_lint_attrs
(
&
s
.
node.
attrs
,
|
cx
|
{
self
.with_lint_attrs
(
&
s
.attrs
,
|
cx
|
{
run_lints!
(
cx
,
check_struct_field
,
early_passes
,
s
);
ast_visit
::
walk_struct_field
(
cx
,
s
);
})
...
...
src/librustc_front/lowering.rs
浏览文件 @
8fe4290f
...
...
@@ -621,11 +621,11 @@ pub fn lower_struct_field(lctx: &LoweringContext,
->
hir
::
StructField
{
hir
::
StructField
{
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
.vis
),
ty
:
lower_ty
(
lctx
,
&
f
.
node.
ty
),
attrs
:
lower_attrs
(
lctx
,
&
f
.
node.
attrs
),
id
:
f
.id
,
name
:
f
.ident
.map
(|
ident
|
ident
.name
)
.unwrap_or
(
token
::
intern
(
&
index
.to_string
())),
vis
:
lower_visibility
(
lctx
,
&
f
.vis
),
ty
:
lower_ty
(
lctx
,
&
f
.ty
),
attrs
:
lower_attrs
(
lctx
,
&
f
.attrs
),
}
}
...
...
src/librustc_save_analysis/dump_visitor.rs
浏览文件 @
8fe4290f
...
...
@@ -563,7 +563,7 @@ fn process_struct(&mut self,
// fields
for
field
in
def
.fields
()
{
self
.process_struct_field_def
(
field
,
item
.id
);
self
.visit_ty
(
&
field
.
node.
ty
);
self
.visit_ty
(
&
field
.ty
);
}
self
.process_generic_params
(
ty_params
,
item
.span
,
&
qualname
,
item
.id
);
...
...
@@ -624,7 +624,7 @@ fn process_enum(&mut self,
for
field
in
variant
.node.data
.fields
()
{
self
.process_struct_field_def
(
field
,
variant
.node.data
.id
());
self
.visit_ty
(
&
field
.
node.
ty
);
self
.visit_ty
(
&
field
.ty
);
}
}
self
.process_generic_params
(
ty_params
,
item
.span
,
&
enum_data
.qualname
,
enum_data
.id
);
...
...
src/librustc_save_analysis/lib.rs
浏览文件 @
8fe4290f
...
...
@@ -246,13 +246,13 @@ pub fn get_item_data(&self, item: &ast::Item) -> Option<Data> {
pub
fn
get_field_data
(
&
self
,
field
:
&
ast
::
StructField
,
scope
:
NodeId
)
->
Option
<
VariableData
>
{
if
let
Some
(
ident
)
=
field
.
node.
ident
{
if
let
Some
(
ident
)
=
field
.ident
{
let
qualname
=
format!
(
"::{}::{}"
,
self
.tcx.map
.path_to_string
(
scope
),
ident
);
let
typ
=
self
.tcx
.node_types
()
.get
(
&
field
.
node.
id
)
.unwrap
()
.to_string
();
let
typ
=
self
.tcx
.node_types
()
.get
(
&
field
.id
)
.unwrap
()
.to_string
();
let
sub_span
=
self
.span_utils
.sub_span_before_token
(
field
.span
,
token
::
Colon
);
filter!
(
self
.span_utils
,
sub_span
,
field
.span
,
None
);
Some
(
VariableData
{
id
:
field
.
node.
id
,
id
:
field
.id
,
name
:
ident
.to_string
(),
qualname
:
qualname
,
span
:
sub_span
.unwrap
(),
...
...
src/libsyntax/ast.rs
浏览文件 @
8fe4290f
...
...
@@ -1876,7 +1876,8 @@ pub enum Visibility {
}
#[derive(Clone,
PartialEq,
Eq,
RustcEncodable,
RustcDecodable,
Hash,
Debug)]
pub
struct
StructField_
{
pub
struct
StructField
{
pub
span
:
Span
,
pub
ident
:
Option
<
Ident
>
,
pub
vis
:
Visibility
,
pub
id
:
NodeId
,
...
...
@@ -1884,8 +1885,6 @@ pub struct StructField_ {
pub
attrs
:
Vec
<
Attribute
>
,
}
pub
type
StructField
=
Spanned
<
StructField_
>
;
/// Fields and Ids of enum variants and structs
///
/// For enum variants: `NodeId` represents both an Id of the variant itself (relevant for all
...
...
src/libsyntax/ast_util.rs
浏览文件 @
8fe4290f
...
...
@@ -263,7 +263,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
);
visit
::
walk_struct_field
(
self
,
struct_field
)
}
...
...
src/libsyntax/config.rs
浏览文件 @
8fe4290f
...
...
@@ -180,12 +180,12 @@ fn fold_struct<F>(cx: &mut Context<F>, vdata: ast::VariantData) -> ast::VariantD
match
vdata
{
ast
::
VariantData
::
Struct
(
fields
,
id
)
=>
{
ast
::
VariantData
::
Struct
(
fields
.into_iter
()
.filter
(|
m
|
{
(
cx
.in_cfg
)(
&
m
.
node.
attrs
)
(
cx
.in_cfg
)(
&
m
.attrs
)
})
.collect
(),
id
)
}
ast
::
VariantData
::
Tuple
(
fields
,
id
)
=>
{
ast
::
VariantData
::
Tuple
(
fields
.into_iter
()
.filter
(|
m
|
{
(
cx
.in_cfg
)(
&
m
.
node.
attrs
)
(
cx
.in_cfg
)(
&
m
.attrs
)
})
.collect
(),
id
)
}
ast
::
VariantData
::
Unit
(
id
)
=>
ast
::
VariantData
::
Unit
(
id
)
...
...
@@ -434,7 +434,7 @@ fn visit_trait_item(&mut self, ti: &'v ast::TraitItem) {
}
fn
visit_struct_field
(
&
mut
self
,
s
:
&
'v
ast
::
StructField
)
{
if
node_survives_cfg
(
&
s
.
node.
attrs
,
self
.config
)
{
if
node_survives_cfg
(
&
s
.attrs
,
self
.config
)
{
visit
::
walk_struct_field
(
self
,
s
);
}
}
...
...
src/libsyntax/ext/build.rs
浏览文件 @
8fe4290f
...
...
@@ -1007,13 +1007,14 @@ fn item_fn(&self,
fn
variant
(
&
self
,
span
:
Span
,
name
:
Ident
,
tys
:
Vec
<
P
<
ast
::
Ty
>>
)
->
ast
::
Variant
{
let
fields
:
Vec
<
_
>
=
tys
.into_iter
()
.map
(|
ty
|
{
Spanned
{
span
:
ty
.span
,
node
:
ast
::
StructField_
{
ast
::
StructField
{
span
:
ty
.span
,
ty
:
ty
,
ident
:
None
,
vis
:
ast
::
Visibility
::
Inherited
,
attrs
:
Vec
::
new
(),
id
:
ast
::
DUMMY_NODE_ID
,
}
}
}
})
.collect
();
let
vdata
=
if
fields
.is_empty
()
{
...
...
src/libsyntax/fold.rs
浏览文件 @
8fe4290f
...
...
@@ -847,15 +847,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
{
Spanned
{
node
:
StructField_
{
id
:
fld
.new_id
(
f
.node.id
),
ident
:
f
.node.ident
.map
(|
ident
|
fld
.fold_ident
(
ident
)),
vis
:
f
.node.vis
,
ty
:
fld
.fold_ty
(
f
.node.ty
),
attrs
:
fold_attrs
(
f
.node.attrs
,
fld
),
},
span
:
fld
.new_span
(
f
.span
)
StructField
{
span
:
fld
.new_span
(
f
.span
),
id
:
fld
.new_id
(
f
.id
),
ident
:
f
.ident
.map
(|
ident
|
fld
.fold_ident
(
ident
)),
vis
:
f
.vis
,
ty
:
fld
.fold_ty
(
f
.ty
),
attrs
:
fold_attrs
(
f
.attrs
,
fld
),
}
}
...
...
src/libsyntax/parse/parser.rs
浏览文件 @
8fe4290f
...
...
@@ -3845,13 +3845,14 @@ fn parse_name_and_ty(&mut self, pr: Visibility,
let
name
=
self
.parse_ident
()
?
;
self
.expect
(
&
token
::
Colon
)
?
;
let
ty
=
self
.parse_ty_sum
()
?
;
Ok
(
spanned
(
lo
,
self
.last_span.hi
,
ast
::
StructField_
{
Ok
(
StructField
{
span
:
mk_sp
(
lo
,
self
.last_span.hi
),
ident
:
Some
(
name
),
vis
:
pr
,
id
:
ast
::
DUMMY_NODE_ID
,
ty
:
ty
,
attrs
:
attrs
,
})
)
})
}
/// Emit an expected item after attributes error.
...
...
@@ -5245,14 +5246,16 @@ pub fn parse_tuple_struct_body(&mut self) -> PResult<'a, Vec<StructField>> {
|
p
|
{
let
attrs
=
p
.parse_outer_attributes
()
?
;
let
lo
=
p
.span.lo
;
let
struct_field_
=
ast
::
StructField_
{
vis
:
p
.parse_visibility
()
?
,
let
vis
=
p
.parse_visibility
()
?
;
let
ty
=
p
.parse_ty_sum
()
?
;
Ok
(
StructField
{
span
:
mk_sp
(
lo
,
p
.span.hi
),
vis
:
vis
,
ident
:
None
,
id
:
ast
::
DUMMY_NODE_ID
,
ty
:
p
.parse_ty_sum
()
?
,
ty
:
ty
,
attrs
:
attrs
,
};
Ok
(
spanned
(
lo
,
p
.span.hi
,
struct_field_
))
})
})
?
;
Ok
(
fields
)
...
...
src/libsyntax/print/pprust.rs
浏览文件 @
8fe4290f
...
...
@@ -1407,9 +1407,9 @@ pub fn print_struct(&mut self,
self
.commasep
(
Inconsistent
,
struct_def
.fields
(),
|
s
,
field
|
{
s
.print_visibility
(
field
.node
.vis
)
?
;
s
.print_visibility
(
&
field
.vis
)
?
;
s
.maybe_print_comment
(
field
.span.lo
)
?
;
s
.print_type
(
&
field
.
node.
ty
)
s
.print_type
(
&
field
.ty
)
}
)
?
;
self
.pclose
()
?
;
...
...
@@ -1429,11 +1429,11 @@ pub fn print_struct(&mut self,
for
field
in
struct_def
.fields
()
{
self
.hardbreak_if_not_bol
()
?
;
self
.maybe_print_comment
(
field
.span.lo
)
?
;
self
.print_outer_attributes
(
&
field
.
node.
attrs
)
?
;
self
.print_visibility
(
field
.node
.vis
)
?
;
self
.print_ident
(
field
.
node.
ident
.unwrap
())
?
;
self
.print_outer_attributes
(
&
field
.attrs
)
?
;
self
.print_visibility
(
&
field
.vis
)
?
;
self
.print_ident
(
field
.ident
.unwrap
())
?
;
self
.word_nbsp
(
":"
)
?
;
self
.print_type
(
&
field
.
node.
ty
)
?
;
self
.print_type
(
&
field
.ty
)
?
;
word
(
&
mut
self
.s
,
","
)
?
;
}
...
...
src/libsyntax/visit.rs
浏览文件 @
8fe4290f
...
...
@@ -619,9 +619,9 @@ pub fn walk_struct_def<'v, V: Visitor<'v>>(visitor: &mut V,
pub
fn
walk_struct_field
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
struct_field
:
&
'v
StructField
)
{
walk_opt_ident
(
visitor
,
struct_field
.span
,
struct_field
.
node.
ident
);
visitor
.visit_ty
(
&
struct_field
.
node.
ty
);
walk_list!
(
visitor
,
visit_attribute
,
&
struct_field
.
node.
attrs
);
walk_opt_ident
(
visitor
,
struct_field
.span
,
struct_field
.ident
);
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/libsyntax_ext/deriving/generic/mod.rs
浏览文件 @
8fe4290f
...
...
@@ -653,7 +653,7 @@ fn expand_struct_def(&self,
type_ident
:
Ident
,
generics
:
&
Generics
)
->
P
<
ast
::
Item
>
{
let
field_tys
:
Vec
<
P
<
ast
::
Ty
>>
=
struct_def
.fields
()
.iter
()
.map
(|
field
|
field
.
node.
ty
.clone
())
.map
(|
field
|
field
.ty
.clone
())
.collect
();
let
methods
=
self
.methods
.iter
()
.map
(|
method_def
|
{
...
...
@@ -701,7 +701,7 @@ fn expand_enum_def(&self,
for
variant
in
&
enum_def
.variants
{
field_tys
.extend
(
variant
.node.data
.fields
()
.iter
()
.map
(|
field
|
field
.
node.
ty
.clone
()));
.map
(|
field
|
field
.ty
.clone
()));
}
let
methods
=
self
.methods
.iter
()
.map
(|
method_def
|
{
...
...
@@ -1435,7 +1435,7 @@ fn summarise_struct(&self,
let
mut
just_spans
=
Vec
::
new
();
for
field
in
struct_def
.fields
(){
let
sp
=
self
.set_expn_info
(
cx
,
field
.span
);
match
field
.
node.
ident
{
match
field
.ident
{
Some
(
ident
)
=>
named_idents
.push
((
ident
,
sp
)),
_
=>
just_spans
.push
(
sp
),
}
...
...
@@ -1481,7 +1481,7 @@ fn create_struct_pattern(&self,
paths
.push
(
codemap
::
Spanned
{
span
:
sp
,
node
:
ident
});
let
val
=
cx
.expr_deref
(
sp
,
cx
.expr_path
(
cx
.path_ident
(
sp
,
ident
)));
let
val
=
cx
.expr
(
sp
,
ast
::
ExprKind
::
Paren
(
val
));
ident_exprs
.push
((
sp
,
struct_field
.
node.ident
,
val
,
&
struct_field
.node
.attrs
[
..
]));
ident_exprs
.push
((
sp
,
struct_field
.
ident
,
val
,
&
struct_field
.attrs
[
..
]));
}
let
subpats
=
self
.create_subpatterns
(
cx
,
paths
,
mutbl
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录