Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
5aee3e01
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,发现更多精彩内容 >>
提交
5aee3e01
编写于
7月 19, 2013
作者:
M
Michael Woerister
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
De-spanned<T> and renamed ast::field (now ast::Field)
上级
4bd14246
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
52 addition
and
61 deletion
+52
-61
src/librustc/middle/cfg/construct.rs
src/librustc/middle/cfg/construct.rs
+1
-1
src/librustc/middle/const_eval.rs
src/librustc/middle/const_eval.rs
+1
-1
src/librustc/middle/dataflow.rs
src/librustc/middle/dataflow.rs
+1
-1
src/librustc/middle/liveness.rs
src/librustc/middle/liveness.rs
+1
-1
src/librustc/middle/moves.rs
src/librustc/middle/moves.rs
+2
-2
src/librustc/middle/privacy.rs
src/librustc/middle/privacy.rs
+5
-12
src/librustc/middle/trans/consts.rs
src/librustc/middle/trans/consts.rs
+2
-2
src/librustc/middle/trans/expr.rs
src/librustc/middle/trans/expr.rs
+3
-3
src/librustc/middle/typeck/check/mod.rs
src/librustc/middle/typeck/check/mod.rs
+8
-8
src/librustc/util/common.rs
src/librustc/util/common.rs
+3
-3
src/libsyntax/ast.rs
src/libsyntax/ast.rs
+3
-4
src/libsyntax/ext/build.rs
src/libsyntax/ext/build.rs
+7
-7
src/libsyntax/fold.rs
src/libsyntax/fold.rs
+4
-6
src/libsyntax/parse/parser.rs
src/libsyntax/parse/parser.rs
+6
-5
src/libsyntax/print/pprust.rs
src/libsyntax/print/pprust.rs
+4
-4
src/libsyntax/visit.rs
src/libsyntax/visit.rs
+1
-1
未找到文件。
src/librustc/middle/cfg/construct.rs
浏览文件 @
5aee3e01
...
...
@@ -374,7 +374,7 @@ fn expr(&mut self, expr: @ast::expr, pred: CFGIndex) -> CFGIndex {
ast
::
expr_struct
(
_
,
ref
fields
,
base
)
=>
{
let
base_exit
=
self
.opt_expr
(
base
,
pred
);
let
field_exprs
:
~
[
@
ast
::
expr
]
=
fields
.iter
()
.transform
(|
f
|
f
.
node.
expr
)
.collect
();
fields
.iter
()
.transform
(|
f
|
f
.expr
)
.collect
();
self
.straightline
(
expr
,
base_exit
,
field_exprs
)
}
...
...
src/librustc/middle/const_eval.rs
浏览文件 @
5aee3e01
...
...
@@ -117,7 +117,7 @@ pub fn classify(e: &expr,
ast
::
expr_struct
(
_
,
ref
fs
,
None
)
=>
{
let
cs
=
do
fs
.iter
()
.transform
|
f
|
{
classify
(
f
.
node.
expr
,
tcx
)
classify
(
f
.expr
,
tcx
)
};
join_all
(
cs
)
}
...
...
src/librustc/middle/dataflow.rs
浏览文件 @
5aee3e01
...
...
@@ -705,7 +705,7 @@ fn walk_expr(&mut self,
ast
::
expr_struct
(
_
,
ref
fields
,
with_expr
)
=>
{
for
fields
.iter
()
.advance
|
field
|
{
self
.walk_expr
(
field
.
node.
expr
,
in_out
,
loop_scopes
);
self
.walk_expr
(
field
.expr
,
in_out
,
loop_scopes
);
}
self
.walk_opt_expr
(
with_expr
,
in_out
,
loop_scopes
);
}
...
...
src/librustc/middle/liveness.rs
浏览文件 @
5aee3e01
...
...
@@ -1161,7 +1161,7 @@ pub fn propagate_through_expr(&self, expr: @expr, succ: LiveNode)
expr_struct
(
_
,
ref
fields
,
with_expr
)
=>
{
let
succ
=
self
.propagate_through_opt_expr
(
with_expr
,
succ
);
do
fields
.rev_iter
()
.fold
(
succ
)
|
succ
,
field
|
{
self
.propagate_through_expr
(
field
.
node.
expr
,
succ
)
self
.propagate_through_expr
(
field
.expr
,
succ
)
}
}
...
...
src/librustc/middle/moves.rs
浏览文件 @
5aee3e01
...
...
@@ -394,7 +394,7 @@ pub fn use_expr(&self,
expr_struct
(
_
,
ref
fields
,
opt_with
)
=>
{
for
fields
.iter
()
.advance
|
field
|
{
self
.consume_expr
(
field
.
node.
expr
,
visitor
);
self
.consume_expr
(
field
.expr
,
visitor
);
}
for
opt_with
.iter
()
.advance
|
with_expr
|
{
...
...
@@ -417,7 +417,7 @@ pub fn use_expr(&self,
// specified and (2) have a type that
// moves-by-default:
let
consume_with
=
with_fields
.iter
()
.any
(|
tf
|
{
!
fields
.iter
()
.any
(|
f
|
f
.
node.
ident
==
tf
.ident
)
&&
!
fields
.iter
()
.any
(|
f
|
f
.ident
==
tf
.ident
)
&&
ty
::
type_moves_by_default
(
self
.tcx
,
tf
.mt.ty
)
});
...
...
src/librustc/middle/privacy.rs
浏览文件 @
5aee3e01
...
...
@@ -413,9 +413,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
Some
(
ref
entry
)
=>
{
debug!
(
"(privacy checking) checking
\
impl method"
);
check_method
(
expr
.span
,
&
entry
.origin
,
ident
);
check_method
(
expr
.span
,
&
entry
.origin
,
ident
);
}
}
}
...
...
@@ -433,8 +431,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
for
(
*
fields
)
.iter
()
.advance
|
field
|
{
debug!
(
"(privacy checking) checking
\
field in struct literal"
);
check_field
(
expr
.span
,
id
,
field
.node.ident
);
check_field
(
expr
.span
,
id
,
field
.ident
);
}
}
}
...
...
@@ -448,8 +445,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
checking field in
\
struct variant
\
literal"
);
check_field
(
expr
.span
,
variant_id
,
field
.node.ident
);
check_field
(
expr
.span
,
variant_id
,
field
.ident
);
}
}
_
=>
{
...
...
@@ -499,8 +495,7 @@ struct variant \
for
fields
.iter
()
.advance
|
field
|
{
debug!
(
"(privacy checking) checking
\
struct pattern"
);
check_field
(
pattern
.span
,
id
,
field
.ident
);
check_field
(
pattern
.span
,
id
,
field
.ident
);
}
}
}
...
...
@@ -513,9 +508,7 @@ struct variant \
debug!
(
"(privacy checking)
\
checking field in
\
struct variant pattern"
);
check_field
(
pattern
.span
,
variant_id
,
field
.ident
);
check_field
(
pattern
.span
,
variant_id
,
field
.ident
);
}
}
_
=>
{
...
...
src/librustc/middle/trans/consts.rs
浏览文件 @
5aee3e01
...
...
@@ -488,8 +488,8 @@ fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef {
do
expr
::
with_field_tys
(
tcx
,
ety
,
Some
(
e
.id
))
|
discr
,
field_tys
|
{
let
cs
=
field_tys
.map
(|
field_ty
|
{
match
fs
.iter
()
.find_
(|
f
|
field_ty
.ident
==
f
.
node.
ident
)
{
Some
(
f
)
=>
const_expr
(
cx
,
(
*
f
)
.
node.
expr
),
match
fs
.iter
()
.find_
(|
f
|
field_ty
.ident
==
f
.ident
)
{
Some
(
f
)
=>
const_expr
(
cx
,
(
*
f
)
.expr
),
None
=>
{
cx
.tcx.sess
.span_bug
(
e
.span
,
"missing struct field"
);
}
...
...
src/librustc/middle/trans/expr.rs
浏览文件 @
5aee3e01
...
...
@@ -1124,7 +1124,7 @@ pub fn with_field_tys<R>(tcx: ty::ctxt,
}
fn
trans_rec_or_struct
(
bcx
:
block
,
fields
:
&
[
ast
::
f
ield
],
fields
:
&
[
ast
::
F
ield
],
base
:
Option
<@
ast
::
expr
>
,
expr_span
:
codemap
::
span
,
id
:
ast
::
node_id
,
...
...
@@ -1139,11 +1139,11 @@ fn trans_rec_or_struct(bcx: block,
let
mut
need_base
=
vec
::
from_elem
(
field_tys
.len
(),
true
);
let
numbered_fields
=
do
fields
.map
|
field
|
{
let
opt_pos
=
field_tys
.iter
()
.position
(|
field_ty
|
field_ty
.ident
==
field
.
node.
ident
);
let
opt_pos
=
field_tys
.iter
()
.position
(|
field_ty
|
field_ty
.ident
==
field
.ident
);
match
opt_pos
{
Some
(
i
)
=>
{
need_base
[
i
]
=
false
;
(
i
,
field
.
node.
expr
)
(
i
,
field
.expr
)
}
None
=>
{
tcx
.sess
.span_bug
(
field
.span
,
...
...
src/librustc/middle/typeck/check/mod.rs
浏览文件 @
5aee3e01
...
...
@@ -1872,7 +1872,7 @@ fn check_struct_or_variant_fields(fcx: @mut FnCtxt,
node_id
:
ast
::
node_id
,
substitutions
:
ty
::
substs
,
field_types
:
&
[
ty
::
field_ty
],
ast_fields
:
&
[
ast
::
f
ield
],
ast_fields
:
&
[
ast
::
F
ield
],
check_completeness
:
bool
)
{
let
tcx
=
fcx
.ccx.tcx
;
...
...
@@ -1888,21 +1888,21 @@ fn check_struct_or_variant_fields(fcx: @mut FnCtxt,
for
ast_fields
.iter
()
.advance
|
field
|
{
let
mut
expected_field_type
=
ty
::
mk_err
();
let
pair
=
class_field_map
.find
(
&
field
.
node.
ident
)
.
let
pair
=
class_field_map
.find
(
&
field
.ident
)
.
map_consume
(|
x
|
*
x
);
match
pair
{
None
=>
{
tcx
.sess
.span_err
(
field
.span
,
fmt!
(
"structure has no field named `%s`"
,
tcx
.sess
.str_of
(
field
.
node.
ident
)));
tcx
.sess
.str_of
(
field
.ident
)));
error_happened
=
true
;
}
Some
((
_
,
true
))
=>
{
tcx
.sess
.span_err
(
field
.span
,
fmt!
(
"field `%s` specified more than once"
,
tcx
.sess
.str_of
(
field
.
node.
ident
)));
tcx
.sess
.str_of
(
field
.ident
)));
error_happened
=
true
;
}
Some
((
field_id
,
false
))
=>
{
...
...
@@ -1910,7 +1910,7 @@ fn check_struct_or_variant_fields(fcx: @mut FnCtxt,
ty
::
lookup_field_type
(
tcx
,
class_id
,
field_id
,
&
substitutions
);
class_field_map
.insert
(
field
.
node.
ident
,
(
field_id
,
true
));
field
.ident
,
(
field_id
,
true
));
fields_found
+=
1
;
}
}
...
...
@@ -1918,7 +1918,7 @@ fn check_struct_or_variant_fields(fcx: @mut FnCtxt,
// an error, so we can continue typechecking
check_expr_coercable_to_type
(
fcx
,
field
.
node.
expr
,
field
.expr
,
expected_field_type
);
}
...
...
@@ -1961,7 +1961,7 @@ fn check_struct_constructor(fcx: @mut FnCtxt,
id
:
ast
::
node_id
,
span
:
codemap
::
span
,
class_id
:
ast
::
def_id
,
fields
:
&
[
ast
::
f
ield
],
fields
:
&
[
ast
::
F
ield
],
base_expr
:
Option
<@
ast
::
expr
>
)
{
let
tcx
=
fcx
.ccx.tcx
;
...
...
@@ -2051,7 +2051,7 @@ fn check_struct_enum_variant(fcx: @mut FnCtxt,
span
:
codemap
::
span
,
enum_id
:
ast
::
def_id
,
variant_id
:
ast
::
def_id
,
fields
:
&
[
ast
::
f
ield
])
{
fields
:
&
[
ast
::
F
ield
])
{
let
tcx
=
fcx
.ccx.tcx
;
// Look up the number of type parameters and the raw type, and
...
...
src/librustc/util/common.rs
浏览文件 @
5aee3e01
...
...
@@ -54,10 +54,10 @@ pub fn indenter() -> _indenter {
_
indenter
(())
}
pub
fn
field_expr
(
f
:
ast
::
field
)
->
@
ast
::
expr
{
return
f
.node
.expr
;
}
pub
fn
field_expr
(
f
:
ast
::
Field
)
->
@
ast
::
expr
{
return
f
.expr
;
}
pub
fn
field_exprs
(
fields
:
~
[
ast
::
f
ield
])
->
~
[
@
ast
::
expr
]
{
fields
.map
(|
f
|
f
.
node.
expr
)
pub
fn
field_exprs
(
fields
:
~
[
ast
::
F
ield
])
->
~
[
@
ast
::
expr
]
{
fields
.map
(|
f
|
f
.expr
)
}
// Takes a predicate p, returns true iff p is true for any subexpressions
...
...
src/libsyntax/ast.rs
浏览文件 @
5aee3e01
...
...
@@ -409,13 +409,12 @@ pub struct arm {
}
#[deriving(Clone,
Eq,
Encodable,
Decodable,
IterBytes)]
pub
struct
field_
{
pub
struct
Field
{
ident
:
ident
,
expr
:
@
expr
,
span
:
span
,
}
pub
type
field
=
spanned
<
field_
>
;
#[deriving(Clone,
Eq,
Encodable,
Decodable,
IterBytes)]
pub
enum
blk_check_mode
{
default_blk
,
...
...
@@ -495,7 +494,7 @@ pub enum expr_ {
expr_mac
(
mac
),
// A struct literal expression.
expr_struct
(
Path
,
~
[
f
ield
],
Option
<@
expr
>
),
expr_struct
(
Path
,
~
[
F
ield
],
Option
<@
expr
>
),
// A vector literal constructed from one repeated element.
expr_repeat
(
@
expr
/* element */
,
@
expr
/* count */
,
mutability
),
...
...
src/libsyntax/ext/build.rs
浏览文件 @
5aee3e01
...
...
@@ -107,9 +107,9 @@ fn expr_method_call(&self, span: span,
args
:
~
[
@
ast
::
expr
])
->
@
ast
::
expr
;
fn
expr_blk
(
&
self
,
b
:
ast
::
Block
)
->
@
ast
::
expr
;
fn
field_imm
(
&
self
,
span
:
span
,
name
:
ident
,
e
:
@
ast
::
expr
)
->
ast
::
f
ield
;
fn
expr_struct
(
&
self
,
span
:
span
,
path
:
ast
::
Path
,
fields
:
~
[
ast
::
f
ield
])
->
@
ast
::
expr
;
fn
expr_struct_ident
(
&
self
,
span
:
span
,
id
:
ast
::
ident
,
fields
:
~
[
ast
::
f
ield
])
->
@
ast
::
expr
;
fn
field_imm
(
&
self
,
span
:
span
,
name
:
ident
,
e
:
@
ast
::
expr
)
->
ast
::
F
ield
;
fn
expr_struct
(
&
self
,
span
:
span
,
path
:
ast
::
Path
,
fields
:
~
[
ast
::
F
ield
])
->
@
ast
::
expr
;
fn
expr_struct_ident
(
&
self
,
span
:
span
,
id
:
ast
::
ident
,
fields
:
~
[
ast
::
F
ield
])
->
@
ast
::
expr
;
fn
expr_lit
(
&
self
,
sp
:
span
,
lit
:
ast
::
lit_
)
->
@
ast
::
expr
;
...
...
@@ -477,14 +477,14 @@ fn expr_method_call(&self, span: span,
fn
expr_blk
(
&
self
,
b
:
ast
::
Block
)
->
@
ast
::
expr
{
self
.expr
(
b
.span
,
ast
::
expr_block
(
b
))
}
fn
field_imm
(
&
self
,
span
:
span
,
name
:
ident
,
e
:
@
ast
::
expr
)
->
ast
::
f
ield
{
respan
(
span
,
ast
::
field_
{
ident
:
name
,
expr
:
e
})
fn
field_imm
(
&
self
,
span
:
span
,
name
:
ident
,
e
:
@
ast
::
expr
)
->
ast
::
F
ield
{
ast
::
Field
{
ident
:
name
,
expr
:
e
,
span
:
span
}
}
fn
expr_struct
(
&
self
,
span
:
span
,
path
:
ast
::
Path
,
fields
:
~
[
ast
::
f
ield
])
->
@
ast
::
expr
{
fn
expr_struct
(
&
self
,
span
:
span
,
path
:
ast
::
Path
,
fields
:
~
[
ast
::
F
ield
])
->
@
ast
::
expr
{
self
.expr
(
span
,
ast
::
expr_struct
(
path
,
fields
,
None
))
}
fn
expr_struct_ident
(
&
self
,
span
:
span
,
id
:
ast
::
ident
,
fields
:
~
[
ast
::
f
ield
])
->
@
ast
::
expr
{
id
:
ast
::
ident
,
fields
:
~
[
ast
::
F
ield
])
->
@
ast
::
expr
{
self
.expr_struct
(
span
,
self
.path_ident
(
span
,
id
),
fields
)
}
...
...
src/libsyntax/fold.rs
浏览文件 @
5aee3e01
...
...
@@ -488,12 +488,10 @@ pub fn wrap<T>(f: @fn(&T, @ast_fold) -> T)
}
pub
fn
noop_fold_expr
(
e
:
&
expr_
,
fld
:
@
ast_fold
)
->
expr_
{
fn
fold_field_
(
field
:
field
,
fld
:
@
ast_fold
)
->
field
{
spanned
{
node
:
ast
::
field_
{
ident
:
fld
.fold_ident
(
field
.node.ident
),
expr
:
fld
.fold_expr
(
field
.node.expr
),
},
fn
fold_field_
(
field
:
Field
,
fld
:
@
ast_fold
)
->
Field
{
ast
::
Field
{
ident
:
fld
.fold_ident
(
field
.ident
),
expr
:
fld
.fold_expr
(
field
.expr
),
span
:
fld
.new_span
(
field
.span
),
}
}
...
...
src/libsyntax/parse/parser.rs
浏览文件 @
5aee3e01
...
...
@@ -29,7 +29,7 @@
use
ast
::{
expr_ret
,
expr_self
,
expr_struct
,
expr_tup
,
expr_unary
};
use
ast
::{
expr_vec
,
expr_vstore
,
expr_vstore_mut_box
};
use
ast
::{
expr_vstore_slice
,
expr_vstore_box
};
use
ast
::{
expr_vstore_mut_slice
,
expr_while
,
extern_fn
,
f
ield
,
fn_decl
};
use
ast
::{
expr_vstore_mut_slice
,
expr_while
,
extern_fn
,
F
ield
,
fn_decl
};
use
ast
::{
expr_vstore_uniq
,
Onceness
,
Once
,
Many
};
use
ast
::{
foreign_item
,
foreign_item_static
,
foreign_item_fn
,
foreign_mod
};
use
ast
::{
ident
,
impure_fn
,
inherited
,
item
,
item_
,
item_static
};
...
...
@@ -1498,15 +1498,16 @@ pub fn parse_mutability(&self) -> mutability {
}
// parse ident COLON expr
pub
fn
parse_field
(
&
self
)
->
f
ield
{
pub
fn
parse_field
(
&
self
)
->
F
ield
{
let
lo
=
self
.span.lo
;
let
i
=
self
.parse_ident
();
self
.expect
(
&
token
::
COLON
);
let
e
=
self
.parse_expr
();
spanned
(
lo
,
e
.span.hi
,
ast
::
field_
{
ast
::
Field
{
ident
:
i
,
expr
:
e
})
expr
:
e
,
span
:
mk_sp
(
lo
,
e
.span.hi
),
}
}
pub
fn
mk_expr
(
&
self
,
lo
:
BytePos
,
hi
:
BytePos
,
node
:
expr_
)
->
@
expr
{
...
...
src/libsyntax/print/pprust.rs
浏览文件 @
5aee3e01
...
...
@@ -1103,14 +1103,14 @@ pub fn print_call_post(s: @ps,
}
pub
fn
print_expr
(
s
:
@
ps
,
expr
:
&
ast
::
expr
)
{
fn
print_field
(
s
:
@
ps
,
field
:
&
ast
::
f
ield
)
{
fn
print_field
(
s
:
@
ps
,
field
:
&
ast
::
F
ield
)
{
ibox
(
s
,
indent_unit
);
print_ident
(
s
,
field
.
node.
ident
);
print_ident
(
s
,
field
.ident
);
word_space
(
s
,
":"
);
print_expr
(
s
,
field
.
node.
expr
);
print_expr
(
s
,
field
.expr
);
end
(
s
);
}
fn
get_span
(
field
:
&
ast
::
f
ield
)
->
codemap
::
span
{
return
field
.span
;
}
fn
get_span
(
field
:
&
ast
::
F
ield
)
->
codemap
::
span
{
return
field
.span
;
}
maybe_print_comment
(
s
,
expr
.span.lo
);
ibox
(
s
,
indent_unit
);
...
...
src/libsyntax/visit.rs
浏览文件 @
5aee3e01
...
...
@@ -474,7 +474,7 @@ pub fn visit_expr<E:Clone>(ex: @expr, (e, v): (E, vt<E>)) {
expr_struct
(
ref
p
,
ref
flds
,
base
)
=>
{
visit_path
(
p
,
(
e
.clone
(),
v
));
for
flds
.iter
()
.advance
|
f
|
{
(
v
.visit_expr
)(
f
.
node.
expr
,
(
e
.clone
(),
v
));
(
v
.visit_expr
)(
f
.expr
,
(
e
.clone
(),
v
));
}
visit_expr_opt
(
base
,
(
e
.clone
(),
v
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录