Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
53de24bb
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,发现更多精彩内容 >>
提交
53de24bb
编写于
10月 19, 2016
作者:
J
Jeffrey Seyfried
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor away fields `MacroDef::{use_locally, export}`.
上级
e4baeaa3
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
22 addition
and
34 deletion
+22
-34
src/librustc/hir/lowering.rs
src/librustc/hir/lowering.rs
+0
-2
src/librustc/hir/mod.rs
src/librustc/hir/mod.rs
+0
-2
src/librustc_incremental/calculate_svh/svh_visitor.rs
src/librustc_incremental/calculate_svh/svh_visitor.rs
+5
-7
src/librustc_metadata/creader.rs
src/librustc_metadata/creader.rs
+0
-3
src/librustc_resolve/macros.rs
src/librustc_resolve/macros.rs
+13
-13
src/libsyntax/ast.rs
src/libsyntax/ast.rs
+0
-2
src/libsyntax/ext/base.rs
src/libsyntax/ext/base.rs
+2
-2
src/libsyntax/ext/tt/macro_rules.rs
src/libsyntax/ext/tt/macro_rules.rs
+2
-3
未找到文件。
src/librustc/hir/lowering.rs
浏览文件 @
53de24bb
...
...
@@ -716,8 +716,6 @@ fn lower_macro_def(&mut self, m: &MacroDef) -> hir::MacroDef {
id
:
m
.id
,
span
:
m
.span
,
imported_from
:
m
.imported_from
.map
(|
x
|
x
.name
),
export
:
m
.export
,
use_locally
:
m
.use_locally
,
allow_internal_unstable
:
m
.allow_internal_unstable
,
body
:
m
.body
.clone
()
.into
(),
}
...
...
src/librustc/hir/mod.rs
浏览文件 @
53de24bb
...
...
@@ -458,8 +458,6 @@ pub struct MacroDef {
pub
id
:
NodeId
,
pub
span
:
Span
,
pub
imported_from
:
Option
<
Name
>
,
pub
export
:
bool
,
pub
use_locally
:
bool
,
pub
allow_internal_unstable
:
bool
,
pub
body
:
HirVec
<
TokenTree
>
,
}
...
...
src/librustc_incremental/calculate_svh/svh_visitor.rs
浏览文件 @
53de24bb
...
...
@@ -675,13 +675,11 @@ fn visit_attribute(&mut self, _: &ast::Attribute) {
fn
visit_macro_def
(
&
mut
self
,
macro_def
:
&
'tcx
MacroDef
)
{
debug!
(
"visit_macro_def: st={:?}"
,
self
.st
);
if
macro_def
.export
{
SawMacroDef
.hash
(
self
.st
);
hash_attrs!
(
self
,
&
macro_def
.attrs
);
visit
::
walk_macro_def
(
self
,
macro_def
)
// FIXME(mw): We should hash the body of the macro too but we don't
// have a stable way of doing so yet.
}
SawMacroDef
.hash
(
self
.st
);
hash_attrs!
(
self
,
&
macro_def
.attrs
);
visit
::
walk_macro_def
(
self
,
macro_def
)
// FIXME(mw): We should hash the body of the macro too but we don't
// have a stable way of doing so yet.
}
}
...
...
src/librustc_metadata/creader.rs
浏览文件 @
53de24bb
...
...
@@ -594,9 +594,6 @@ pub fn read_macros(&mut self, item: &ast::Item) -> Macros {
id
:
ast
::
DUMMY_NODE_ID
,
span
:
local_span
,
imported_from
:
Some
(
item
.ident
),
// overridden in plugin/load.rs
export
:
false
,
use_locally
:
false
,
allow_internal_unstable
:
attr
::
contains_name
(
&
def
.attrs
,
"allow_internal_unstable"
),
attrs
:
def
.attrs
,
body
:
body
,
...
...
src/librustc_resolve/macros.rs
浏览文件 @
53de24bb
...
...
@@ -114,22 +114,22 @@ fn visit_expansion(&mut self, mark: Mark, expansion: &Expansion) {
invocation
.expansion
.set
(
visitor
.legacy_scope
);
}
fn
add_macro
(
&
mut
self
,
scope
:
Mark
,
mut
def
:
ast
::
MacroDef
)
{
fn
add_macro
(
&
mut
self
,
scope
:
Mark
,
mut
def
:
ast
::
MacroDef
,
export
:
bool
)
{
if
&
def
.ident.name
.as_str
()
==
"macro_rules"
{
self
.session
.span_err
(
def
.span
,
"user-defined macros may not be named `macro_rules`"
);
}
if
def
.use_locally
{
let
invocation
=
self
.invocations
[
&
scope
];
let
binding
=
self
.arenas
.alloc_legacy_binding
(
LegacyBinding
{
parent
:
invocation
.legacy_scope
.get
(),
name
:
def
.ident.name
,
ext
:
Rc
::
new
(
macro_rules
::
compile
(
&
self
.session.parse_sess
,
&
def
)),
span
:
def
.span
,
});
invocation
.legacy_scope
.set
(
LegacyScope
::
Binding
(
binding
));
self
.macro_names
.insert
(
def
.ident.name
);
}
if
def
.
export
{
let
invocation
=
self
.invocations
[
&
scope
];
let
binding
=
self
.arenas
.alloc_legacy_binding
(
LegacyBinding
{
parent
:
invocation
.legacy_scope
.get
(),
name
:
def
.ident.name
,
ext
:
Rc
::
new
(
macro_rules
::
compile
(
&
self
.session.parse_sess
,
&
def
)),
span
:
def
.span
,
});
invocation
.legacy_scope
.set
(
LegacyScope
::
Binding
(
binding
));
self
.macro_names
.insert
(
def
.ident.name
);
if
export
{
def
.id
=
self
.next_node_id
();
self
.exported_macros
.push
(
def
);
}
...
...
src/libsyntax/ast.rs
浏览文件 @
53de24bb
...
...
@@ -2012,8 +2012,6 @@ pub struct MacroDef {
pub
id
:
NodeId
,
pub
span
:
Span
,
pub
imported_from
:
Option
<
Ident
>
,
pub
export
:
bool
,
pub
use_locally
:
bool
,
pub
allow_internal_unstable
:
bool
,
pub
body
:
Vec
<
TokenTree
>
,
}
...
...
src/libsyntax/ext/base.rs
浏览文件 @
53de24bb
...
...
@@ -519,7 +519,7 @@ pub trait Resolver {
fn
get_module_scope
(
&
mut
self
,
id
:
ast
::
NodeId
)
->
Mark
;
fn
visit_expansion
(
&
mut
self
,
mark
:
Mark
,
expansion
:
&
Expansion
);
fn
add_macro
(
&
mut
self
,
scope
:
Mark
,
def
:
ast
::
MacroDef
);
fn
add_macro
(
&
mut
self
,
scope
:
Mark
,
def
:
ast
::
MacroDef
,
export
:
bool
);
fn
add_ext
(
&
mut
self
,
ident
:
ast
::
Ident
,
ext
:
Rc
<
SyntaxExtension
>
);
fn
add_expansions_at_stmt
(
&
mut
self
,
id
:
ast
::
NodeId
,
macros
:
Vec
<
Mark
>
);
...
...
@@ -541,7 +541,7 @@ fn next_node_id(&mut self) -> ast::NodeId { ast::DUMMY_NODE_ID }
fn
get_module_scope
(
&
mut
self
,
_
id
:
ast
::
NodeId
)
->
Mark
{
Mark
::
root
()
}
fn
visit_expansion
(
&
mut
self
,
_
invoc
:
Mark
,
_
expansion
:
&
Expansion
)
{}
fn
add_macro
(
&
mut
self
,
_
scope
:
Mark
,
_
def
:
ast
::
MacroDef
)
{}
fn
add_macro
(
&
mut
self
,
_
scope
:
Mark
,
_
def
:
ast
::
MacroDef
,
_
export
:
bool
)
{}
fn
add_ext
(
&
mut
self
,
_
ident
:
ast
::
Ident
,
_
ext
:
Rc
<
SyntaxExtension
>
)
{}
fn
add_expansions_at_stmt
(
&
mut
self
,
_
id
:
ast
::
NodeId
,
_
macros
:
Vec
<
Mark
>
)
{}
...
...
src/libsyntax/ext/tt/macro_rules.rs
浏览文件 @
53de24bb
...
...
@@ -157,14 +157,13 @@ fn expand(&self,
tts
:
Vec
<
tokenstream
::
TokenTree
>
,
attrs
:
Vec
<
ast
::
Attribute
>
)
->
Box
<
MacResult
>
{
let
export
=
attr
::
contains_name
(
&
attrs
,
"macro_export"
);
let
def
=
ast
::
MacroDef
{
ident
:
ident
,
id
:
ast
::
DUMMY_NODE_ID
,
span
:
span
,
imported_from
:
None
,
use_locally
:
true
,
body
:
tts
,
export
:
attr
::
contains_name
(
&
attrs
,
"macro_export"
),
allow_internal_unstable
:
attr
::
contains_name
(
&
attrs
,
"allow_internal_unstable"
),
attrs
:
attrs
,
};
...
...
@@ -176,7 +175,7 @@ fn expand(&self,
MacEager
::
items
(
placeholders
::
macro_scope_placeholder
()
.make_items
())
};
cx
.resolver
.add_macro
(
cx
.current_expansion.mark
,
def
);
cx
.resolver
.add_macro
(
cx
.current_expansion.mark
,
def
,
export
);
result
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录