Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
215c1460
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,发现更多精彩内容 >>
提交
215c1460
编写于
5月 20, 2016
作者:
J
Jeffrey Seyfried
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Check attributes in `expand_mac_invoc`
上级
f4075e94
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
12 addition
and
22 deletion
+12
-22
src/libsyntax/ext/expand.rs
src/libsyntax/ext/expand.rs
+12
-22
未找到文件。
src/libsyntax/ext/expand.rs
浏览文件 @
215c1460
...
...
@@ -16,7 +16,7 @@
use
ext
::
mtwt
;
use
ext
::
build
::
AstBuilder
;
use
attr
;
use
attr
::{
AttrMetaMethods
,
WithAttrs
};
use
attr
::{
AttrMetaMethods
,
WithAttrs
,
ThinAttributesExt
};
use
codemap
;
use
codemap
::{
Span
,
Spanned
,
ExpnInfo
,
NameAndSpan
,
MacroBang
,
MacroAttribute
};
use
ext
::
base
::
*
;
...
...
@@ -86,14 +86,7 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
// expr_mac should really be expr_ext or something; it's the
// entry-point for all syntax extensions.
ast
::
ExprKind
::
Mac
(
mac
)
=>
{
if
let
Some
(
ref
attrs
)
=
attrs
{
check_attributes
(
attrs
,
fld
);
}
// Assert that we drop any macro attributes on the floor here
drop
(
attrs
);
expand_mac_invoc
(
mac
,
span
,
fld
)
expand_mac_invoc
(
mac
,
attrs
.into_attr_vec
(),
span
,
fld
)
}
ast
::
ExprKind
::
InPlace
(
placer
,
value_expr
)
=>
{
...
...
@@ -204,7 +197,12 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
}
/// Expand a (not-ident-style) macro invocation. Returns the result of expansion.
fn
expand_mac_invoc
<
T
:
MacroGenerable
>
(
mac
:
ast
::
Mac
,
span
:
Span
,
fld
:
&
mut
MacroExpander
)
->
T
{
fn
expand_mac_invoc
<
T
>
(
mac
:
ast
::
Mac
,
attrs
:
Vec
<
ast
::
Attribute
>
,
span
:
Span
,
fld
:
&
mut
MacroExpander
)
->
T
where
T
:
MacroGenerable
,
{
check_attributes
(
&
attrs
,
fld
);
// it would almost certainly be cleaner to pass the whole
// macro invocation in, rather than pulling it apart and
// marking the tts and the ctxt separately. This also goes
...
...
@@ -527,15 +525,8 @@ fn expand_stmt(stmt: Stmt, fld: &mut MacroExpander) -> SmallVector<Stmt> {
_
=>
return
expand_non_macro_stmt
(
stmt
,
fld
)
};
if
let
Some
(
ref
attrs
)
=
attrs
{
check_attributes
(
attrs
,
fld
);
}
// Assert that we drop any macro attributes on the floor here
drop
(
attrs
);
let
mut
fully_expanded
:
SmallVector
<
ast
::
Stmt
>
=
expand_mac_invoc
(
mac
.unwrap
(),
stmt
.span
,
fld
);
expand_mac_invoc
(
mac
.unwrap
(),
attrs
.into_attr_vec
(),
stmt
.span
,
fld
);
// If this is a macro invocation with a semicolon, then apply that
// semicolon to the final statement produced by expansion.
...
...
@@ -752,7 +743,7 @@ fn expand_pat(p: P<ast::Pat>, fld: &mut MacroExpander) -> P<ast::Pat> {
}
p
.and_then
(|
ast
::
Pat
{
node
,
span
,
..
}|
{
match
node
{
PatKind
::
Mac
(
mac
)
=>
expand_mac_invoc
(
mac
,
span
,
fld
),
PatKind
::
Mac
(
mac
)
=>
expand_mac_invoc
(
mac
,
Vec
::
new
(),
span
,
fld
),
_
=>
unreachable!
()
}
})
...
...
@@ -1007,8 +998,7 @@ fn expand_impl_item(ii: ast::ImplItem, fld: &mut MacroExpander)
span
:
fld
.new_span
(
ii
.span
)
}),
ast
::
ImplItemKind
::
Macro
(
mac
)
=>
{
check_attributes
(
&
ii
.attrs
,
fld
);
expand_mac_invoc
(
mac
,
ii
.span
,
fld
)
expand_mac_invoc
(
mac
,
ii
.attrs
,
ii
.span
,
fld
)
}
_
=>
fold
::
noop_fold_impl_item
(
ii
,
fld
)
}
...
...
@@ -1052,7 +1042,7 @@ pub fn expand_type(t: P<ast::Ty>, fld: &mut MacroExpander) -> P<ast::Ty> {
let
t
=
match
t
.node
.clone
()
{
ast
::
TyKind
::
Mac
(
mac
)
=>
{
if
fld
.cx.ecfg.features
.unwrap
()
.type_macros
{
expand_mac_invoc
(
mac
,
t
.span
,
fld
)
expand_mac_invoc
(
mac
,
Vec
::
new
(),
t
.span
,
fld
)
}
else
{
feature_gate
::
emit_feature_err
(
&
fld
.cx.parse_sess.span_diagnostic
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录