Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
b53020a5
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,发现更多精彩内容 >>
提交
b53020a5
编写于
11月 11, 2015
作者:
B
bors
浏览文件
操作
浏览文件
下载
差异文件
Auto merge of #29744 - sanxiyn:modernize, r=nrc
上级
7e82b397
dfc314d1
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
30 addition
and
30 deletion
+30
-30
src/libsyntax/attr.rs
src/libsyntax/attr.rs
+6
-6
src/libsyntax/config.rs
src/libsyntax/config.rs
+5
-5
src/libsyntax/ext/base.rs
src/libsyntax/ext/base.rs
+2
-2
src/libsyntax/ext/cfg.rs
src/libsyntax/ext/cfg.rs
+1
-1
src/libsyntax/ext/expand.rs
src/libsyntax/ext/expand.rs
+6
-6
src/libsyntax/ext/tt/macro_rules.rs
src/libsyntax/ext/tt/macro_rules.rs
+1
-1
src/libsyntax/fold.rs
src/libsyntax/fold.rs
+1
-1
src/libsyntax/parse/classify.rs
src/libsyntax/parse/classify.rs
+1
-1
src/libsyntax/parse/mod.rs
src/libsyntax/parse/mod.rs
+5
-5
src/libsyntax/util/small_vector.rs
src/libsyntax/util/small_vector.rs
+2
-2
未找到文件。
src/libsyntax/attr.rs
浏览文件 @
b53020a5
...
...
@@ -67,7 +67,7 @@ fn check_name(&self, name: &str) -> bool {
/// containing a string, otherwise None.
fn
value_str
(
&
self
)
->
Option
<
InternedString
>
;
/// Gets a list of inner meta items from a list MetaItem type.
fn
meta_item_list
<
'a
>
(
&
'a
self
)
->
Option
<&
'a
[
P
<
MetaItem
>
]
>
;
fn
meta_item_list
(
&
self
)
->
Option
<&
[
P
<
MetaItem
>
]
>
;
fn
span
(
&
self
)
->
Span
;
}
...
...
@@ -84,7 +84,7 @@ fn name(&self) -> InternedString { self.meta().name() }
fn
value_str
(
&
self
)
->
Option
<
InternedString
>
{
self
.meta
()
.value_str
()
}
fn
meta_item_list
<
'a
>
(
&
'a
self
)
->
Option
<&
'a
[
P
<
MetaItem
>
]
>
{
fn
meta_item_list
(
&
self
)
->
Option
<&
[
P
<
MetaItem
>
]
>
{
self
.node.value
.meta_item_list
()
}
fn
span
(
&
self
)
->
Span
{
self
.meta
()
.span
}
...
...
@@ -111,7 +111,7 @@ fn value_str(&self) -> Option<InternedString> {
}
}
fn
meta_item_list
<
'a
>
(
&
'a
self
)
->
Option
<&
'a
[
P
<
MetaItem
>
]
>
{
fn
meta_item_list
(
&
self
)
->
Option
<&
[
P
<
MetaItem
>
]
>
{
match
self
.node
{
MetaList
(
_
,
ref
l
)
=>
Some
(
&
l
[
..
]),
_
=>
None
...
...
@@ -124,7 +124,7 @@ fn span(&self) -> Span { self.span }
impl
AttrMetaMethods
for
P
<
MetaItem
>
{
fn
name
(
&
self
)
->
InternedString
{
(
**
self
)
.name
()
}
fn
value_str
(
&
self
)
->
Option
<
InternedString
>
{
(
**
self
)
.value_str
()
}
fn
meta_item_list
<
'a
>
(
&
'a
self
)
->
Option
<&
'a
[
P
<
MetaItem
>
]
>
{
fn
meta_item_list
(
&
self
)
->
Option
<&
[
P
<
MetaItem
>
]
>
{
(
**
self
)
.meta_item_list
()
}
fn
span
(
&
self
)
->
Span
{
(
**
self
)
.span
()
}
...
...
@@ -132,14 +132,14 @@ fn span(&self) -> Span { (**self).span() }
pub
trait
AttributeMethods
{
fn
meta
<
'a
>
(
&
'a
self
)
->
&
'a
MetaItem
;
fn
meta
(
&
self
)
->
&
MetaItem
;
fn
with_desugared_doc
<
T
,
F
>
(
&
self
,
f
:
F
)
->
T
where
F
:
FnOnce
(
&
Attribute
)
->
T
;
}
impl
AttributeMethods
for
Attribute
{
/// Extract the MetaItem from inside this Attribute.
fn
meta
<
'a
>
(
&
'a
self
)
->
&
'a
MetaItem
{
fn
meta
(
&
self
)
->
&
MetaItem
{
&*
self
.node.value
}
...
...
src/libsyntax/config.rs
浏览文件 @
b53020a5
...
...
@@ -86,7 +86,7 @@ fn filter_foreign_item<F>(cx: &mut Context<F>,
->
Option
<
P
<
ast
::
ForeignItem
>>
where
F
:
FnMut
(
&
[
ast
::
Attribute
])
->
bool
{
if
foreign_item_in_cfg
(
cx
,
&
*
item
)
{
if
foreign_item_in_cfg
(
cx
,
&
item
)
{
Some
(
item
)
}
else
{
None
...
...
@@ -109,7 +109,7 @@ fn fold_foreign_mod<F>(cx: &mut Context<F>,
fn
fold_item
<
F
>
(
cx
:
&
mut
Context
<
F
>
,
item
:
P
<
ast
::
Item
>
)
->
SmallVector
<
P
<
ast
::
Item
>>
where
F
:
FnMut
(
&
[
ast
::
Attribute
])
->
bool
{
if
item_in_cfg
(
cx
,
&
*
item
)
{
if
item_in_cfg
(
cx
,
&
item
)
{
SmallVector
::
one
(
item
.map
(|
i
|
cx
.fold_item_simple
(
i
)))
}
else
{
SmallVector
::
zero
()
...
...
@@ -189,7 +189,7 @@ fn retain_stmt<F>(cx: &mut Context<F>, stmt: &ast::Stmt) -> bool where
ast
::
StmtDecl
(
ref
decl
,
_
)
=>
{
match
decl
.node
{
ast
::
DeclItem
(
ref
item
)
=>
{
item_in_cfg
(
cx
,
&**
item
)
item_in_cfg
(
cx
,
item
)
}
_
=>
true
}
...
...
@@ -203,7 +203,7 @@ fn fold_block<F>(cx: &mut Context<F>, b: P<ast::Block>) -> P<ast::Block> where
{
b
.map
(|
ast
::
Block
{
id
,
stmts
,
expr
,
rules
,
span
}|
{
let
resulting_stmts
:
Vec
<
P
<
ast
::
Stmt
>>
=
stmts
.into_iter
()
.filter
(|
a
|
retain_stmt
(
cx
,
&**
a
))
.collect
();
stmts
.into_iter
()
.filter
(|
a
|
retain_stmt
(
cx
,
a
))
.collect
();
let
resulting_stmts
=
resulting_stmts
.into_iter
()
.flat_map
(|
stmt
|
cx
.fold_stmt
(
stmt
)
.into_iter
())
.collect
();
...
...
@@ -263,7 +263,7 @@ fn in_cfg(diagnostic: &SpanHandler, cfg: &[P<ast::MetaItem>], attrs: &[ast::Attr
return
true
;
}
attr
::
cfg_matches
(
diagnostic
,
cfg
,
&
*
mis
[
0
],
attr
::
cfg_matches
(
diagnostic
,
cfg
,
&
mis
[
0
],
feature_gated_cfgs
)
})
}
...
...
src/libsyntax/ext/base.rs
浏览文件 @
b53020a5
...
...
@@ -881,7 +881,7 @@ pub fn pop_frame(&mut self) {
self
.chain
.pop
();
}
fn
find_escape_frame
<
'a
>
(
&
'a
mut
self
)
->
&
'a
mut
MapChainFrame
{
fn
find_escape_frame
(
&
mut
self
)
->
&
mut
MapChainFrame
{
for
(
i
,
frame
)
in
self
.chain
.iter_mut
()
.enumerate
()
.rev
()
{
if
!
frame
.info.macros_escape
||
i
==
0
{
return
frame
...
...
@@ -904,7 +904,7 @@ pub fn insert(&mut self, k: Name, v: SyntaxExtension) {
self
.find_escape_frame
()
.map
.insert
(
k
,
Rc
::
new
(
v
));
}
pub
fn
info
<
'a
>
(
&
'a
mut
self
)
->
&
'a
mut
BlockInfo
{
pub
fn
info
(
&
mut
self
)
->
&
mut
BlockInfo
{
let
last_chain_index
=
self
.chain
.len
()
-
1
;
&
mut
self
.chain
[
last_chain_index
]
.info
}
...
...
src/libsyntax/ext/cfg.rs
浏览文件 @
b53020a5
...
...
@@ -33,7 +33,7 @@ pub fn expand_cfg<'cx>(cx: &mut ExtCtxt,
return
DummyResult
::
expr
(
sp
);
}
let
matches_cfg
=
attr
::
cfg_matches
(
&
cx
.parse_sess.span_diagnostic
,
&
cx
.cfg
,
&
*
cfg
,
let
matches_cfg
=
attr
::
cfg_matches
(
&
cx
.parse_sess.span_diagnostic
,
&
cx
.cfg
,
&
cfg
,
cx
.feature_gated_cfgs
);
MacEager
::
expr
(
cx
.expr_bool
(
sp
,
matches_cfg
))
}
src/libsyntax/ext/expand.rs
浏览文件 @
b53020a5
...
...
@@ -547,7 +547,7 @@ fn expand_non_macro_stmt(Spanned {node, span: stmt_span}: Stmt, fld: &mut MacroE
// names, as well... but that should be okay, as long as
// the new names are gensyms for the old ones.
// generate fresh names, push them to a new pending list
let
idents
=
pattern_bindings
(
&
*
expanded_pat
);
let
idents
=
pattern_bindings
(
&
expanded_pat
);
let
mut
new_pending_renames
=
idents
.iter
()
.map
(|
ident
|
(
*
ident
,
fresh_name
(
*
ident
)))
.collect
();
// rewrite the pattern using the new names (the old
...
...
@@ -634,7 +634,7 @@ fn rename_in_scope<X, F>(pats: Vec<P<ast::Pat>>,
{
// all of the pats must have the same set of bindings, so use the
// first one to extract them and generate new names:
let
idents
=
pattern_bindings
(
&
*
pats
[
0
]);
let
idents
=
pattern_bindings
(
&
pats
[
0
]);
let
new_renames
=
idents
.into_iter
()
.map
(|
id
|
(
id
,
fresh_name
(
id
)))
.collect
();
// apply the renaming, but only to the PatIdents:
let
mut
rename_pats_fld
=
PatIdentRenamer
{
renames
:
&
new_renames
};
...
...
@@ -659,7 +659,7 @@ fn visit_pat(&mut self, pattern: &ast::Pat) {
self
.ident_accumulator
.push
(
path1
.node
);
// visit optional subpattern of PatIdent:
if
let
Some
(
ref
subpat
)
=
*
inner
{
self
.visit_pat
(
&**
subpat
)
self
.visit_pat
(
subpat
)
}
}
// use the default traversal for non-PatIdents
...
...
@@ -679,7 +679,7 @@ fn pattern_bindings(pat: &ast::Pat) -> Vec<ast::Ident> {
fn
fn_decl_arg_bindings
(
fn_decl
:
&
ast
::
FnDecl
)
->
Vec
<
ast
::
Ident
>
{
let
mut
pat_idents
=
PatIdentFinder
{
ident_accumulator
:
Vec
::
new
()};
for
arg
in
&
fn_decl
.inputs
{
pat_idents
.visit_pat
(
&
*
arg
.pat
);
pat_idents
.visit_pat
(
&
arg
.pat
);
}
pat_idents
.ident_accumulator
}
...
...
@@ -1078,7 +1078,7 @@ fn expand_and_rename_fn_decl_and_block(fn_decl: P<ast::FnDecl>, block: P<ast::Bl
fld
:
&
mut
MacroExpander
)
->
(
P
<
ast
::
FnDecl
>
,
P
<
ast
::
Block
>
)
{
let
expanded_decl
=
fld
.fold_fn_decl
(
fn_decl
);
let
idents
=
fn_decl_arg_bindings
(
&
*
expanded_decl
);
let
idents
=
fn_decl_arg_bindings
(
&
expanded_decl
);
let
renames
=
idents
.iter
()
.map
(|
id
|
(
*
id
,
fresh_name
(
*
id
)))
.collect
();
// first, a renamer for the PatIdents, for the fn_decl:
...
...
@@ -1807,7 +1807,7 @@ fn fmt_in_macro_used_inside_module_macro() {
fn
pat_idents
(){
let
pat
=
string_to_pat
(
"(a,Foo{x:c @ (b,9),y:Bar(4,d)})"
.to_string
());
let
idents
=
pattern_bindings
(
&
*
pat
);
let
idents
=
pattern_bindings
(
&
pat
);
assert_eq!
(
idents
,
strs_to_idents
(
vec!
(
"a"
,
"c"
,
"b"
,
"d"
)));
}
...
...
src/libsyntax/ext/tt/macro_rules.rs
浏览文件 @
b53020a5
...
...
@@ -289,7 +289,7 @@ pub fn compile<'cx>(cx: &'cx mut ExtCtxt,
};
for
lhs
in
&
lhses
{
check_lhs_nt_follows
(
cx
,
&**
lhs
,
def
.span
);
check_lhs_nt_follows
(
cx
,
lhs
,
def
.span
);
}
let
rhses
=
match
**
argument_map
.get
(
&
rhs_nm
.name
)
.unwrap
()
{
...
...
src/libsyntax/fold.rs
浏览文件 @
b53020a5
...
...
@@ -673,7 +673,7 @@ pub fn noop_fold_interpolated<T: Folder>(nt: token::Nonterminal, fld: &mut T)
token
::
NtIdent
(
Box
::
new
(
fld
.fold_ident
(
*
id
)),
is_mod_name
),
token
::
NtMeta
(
meta_item
)
=>
token
::
NtMeta
(
fld
.fold_meta_item
(
meta_item
)),
token
::
NtPath
(
path
)
=>
token
::
NtPath
(
Box
::
new
(
fld
.fold_path
(
*
path
))),
token
::
NtTT
(
tt
)
=>
token
::
NtTT
(
P
(
fld
.fold_tt
(
&
*
tt
))),
token
::
NtTT
(
tt
)
=>
token
::
NtTT
(
P
(
fld
.fold_tt
(
&
tt
))),
token
::
NtArm
(
arm
)
=>
token
::
NtArm
(
fld
.fold_arm
(
arm
)),
token
::
NtImplItem
(
arm
)
=>
token
::
NtImplItem
(
fld
.fold_impl_item
(
arm
)
...
...
src/libsyntax/parse/classify.rs
浏览文件 @
b53020a5
...
...
@@ -53,7 +53,7 @@ pub fn stmt_ends_with_semi(stmt: &ast::Stmt_) -> bool {
ast
::
DeclItem
(
_
)
=>
false
}
}
ast
::
StmtExpr
(
ref
e
,
_
)
=>
{
expr_requires_semi_to_be_stmt
(
&**
e
)
}
ast
::
StmtExpr
(
ref
e
,
_
)
=>
{
expr_requires_semi_to_be_stmt
(
e
)
}
ast
::
StmtSemi
(
..
)
=>
{
false
}
ast
::
StmtMac
(
..
)
=>
{
false
}
}
...
...
src/libsyntax/parse/mod.rs
浏览文件 @
b53020a5
...
...
@@ -446,10 +446,10 @@ fn filtered_float_lit(data: token::InternedString, suffix: Option<&str>,
Some
(
suf
)
=>
{
if
suf
.len
()
>=
2
&&
looks_like_width_suffix
(
&
[
'f'
],
suf
)
{
// if it looks like a width, lets try to be helpful.
sd
.span_err
(
sp
,
&
*
format!
(
"invalid width `{}` for float literal"
,
&
suf
[
1
..
]));
sd
.span_err
(
sp
,
&
format!
(
"invalid width `{}` for float literal"
,
&
suf
[
1
..
]));
sd
.fileline_help
(
sp
,
"valid widths are 32 and 64"
);
}
else
{
sd
.span_err
(
sp
,
&
*
format!
(
"invalid suffix `{}` for float literal"
,
suf
));
sd
.span_err
(
sp
,
&
format!
(
"invalid suffix `{}` for float literal"
,
suf
));
sd
.fileline_help
(
sp
,
"valid suffixes are `f32` and `f64`"
);
}
...
...
@@ -619,11 +619,11 @@ pub fn integer_lit(s: &str,
// i<digits> and u<digits> look like widths, so lets
// give an error message along those lines
if
looks_like_width_suffix
(
&
[
'i'
,
'u'
],
suf
)
{
sd
.span_err
(
sp
,
&
*
format!
(
"invalid width `{}` for integer literal"
,
sd
.span_err
(
sp
,
&
format!
(
"invalid width `{}` for integer literal"
,
&
suf
[
1
..
]));
sd
.fileline_help
(
sp
,
"valid widths are 8, 16, 32 and 64"
);
}
else
{
sd
.span_err
(
sp
,
&
*
format!
(
"invalid suffix `{}` for numeric literal"
,
suf
));
sd
.span_err
(
sp
,
&
format!
(
"invalid suffix `{}` for numeric literal"
,
suf
));
sd
.fileline_help
(
sp
,
"the suffix must be one of the integral types
\
(`u32`, `isize`, etc)"
);
}
...
...
src/libsyntax/util/small_vector.rs
浏览文件 @
b53020a5
...
...
@@ -58,7 +58,7 @@ pub fn many(vs: Vec<T>) -> SmallVector<T> {
SmallVector
{
repr
:
Many
(
vs
)
}
}
pub
fn
as_slice
<
'a
>
(
&
'a
self
)
->
&
'a
[
T
]
{
pub
fn
as_slice
(
&
self
)
->
&
[
T
]
{
match
self
.repr
{
Zero
=>
{
let
result
:
&
[
T
]
=
&
[];
...
...
@@ -105,7 +105,7 @@ pub fn push_all(&mut self, other: SmallVector<T>) {
}
}
pub
fn
get
<
'a
>
(
&
'a
self
,
idx
:
usize
)
->
&
'a
T
{
pub
fn
get
(
&
self
,
idx
:
usize
)
->
&
T
{
match
self
.repr
{
One
(
ref
v
)
if
idx
==
0
=>
v
,
Many
(
ref
vs
)
=>
&
vs
[
idx
],
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录