Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
25b7f10c
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,发现更多精彩内容 >>
提交
25b7f10c
编写于
5月 15, 2017
作者:
E
est31
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Address review comments
上级
0d0cb279
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
13 addition
and
17 deletion
+13
-17
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+4
-6
src/librustc_resolve/macros.rs
src/librustc_resolve/macros.rs
+7
-7
src/libsyntax/ext/tt/macro_rules.rs
src/libsyntax/ext/tt/macro_rules.rs
+2
-4
未找到文件。
src/librustc_resolve/lib.rs
浏览文件 @
25b7f10c
...
...
@@ -1195,11 +1195,9 @@ pub struct Resolver<'a> {
pub
whitelisted_legacy_custom_derives
:
Vec
<
Name
>
,
pub
found_unresolved_macro
:
bool
,
// List of macros that we need to warn about as being unused.
// The bool is true if the macro is unused, and false if its used.
// Setting a bool to false should be much faster than removing a single
// element from a FxHashSet.
unused_macros
:
FxHashMap
<
DefId
,
bool
>
,
// List of crate local macros that we need to warn about as being unused.
// Right now this only includes macro_rules! macros.
unused_macros
:
FxHashSet
<
DefId
>
,
// Maps the `Mark` of an expansion to its containing module or block.
invocations
:
FxHashMap
<
Mark
,
&
'a
InvocationData
<
'a
>>
,
...
...
@@ -1406,7 +1404,7 @@ pub fn new(session: &'a Session,
potentially_unused_imports
:
Vec
::
new
(),
struct_constructors
:
DefIdMap
(),
found_unresolved_macro
:
false
,
unused_macros
:
FxHash
Map
(),
unused_macros
:
FxHash
Set
(),
}
}
...
...
src/librustc_resolve/macros.rs
浏览文件 @
25b7f10c
...
...
@@ -291,24 +291,24 @@ fn resolve_invoc(&mut self, invoc: &mut Invocation, scope: Mark, force: bool)
},
};
self
.macro_defs
.insert
(
invoc
.expansion_data.mark
,
def
.def_id
());
self
.unused_macros
.
get_mut
(
&
def
.def_id
())
.map
(|
m
|
*
m
=
false
);
self
.unused_macros
.
remove
(
&
def
.def_id
()
);
Ok
(
Some
(
self
.get_macro
(
def
)))
}
fn
resolve_macro
(
&
mut
self
,
scope
:
Mark
,
path
:
&
ast
::
Path
,
kind
:
MacroKind
,
force
:
bool
)
->
Result
<
Rc
<
SyntaxExtension
>
,
Determinacy
>
{
self
.resolve_macro_to_def
(
scope
,
path
,
kind
,
force
)
.map
(|
def
|
{
self
.unused_macros
.
get_mut
(
&
def
.def_id
())
.map
(|
m
|
*
m
=
false
);
self
.unused_macros
.
remove
(
&
def
.def_id
()
);
self
.get_macro
(
def
)
})
}
fn
check_unused_macros
(
&
self
)
{
for
(
did
,
_
)
in
self
.unused_macros
.iter
()
.filter
(|
&
(
_
,
b
)|
*
b
)
{
for
did
in
self
.unused_macros
.iter
(
)
{
let
id_span
=
match
*
self
.macro_map
[
did
]
{
SyntaxExtension
::
NormalTT
(
_
,
isp
,
_
)
=>
isp
,
_
=>
None
};
SyntaxExtension
::
NormalTT
(
_
,
isp
,
_
)
=>
isp
,
_
=>
None
,
};
if
let
Some
((
id
,
span
))
=
id_span
{
let
lint
=
lint
::
builtin
::
UNUSED_MACROS
;
let
msg
=
"unused macro definition"
.to_string
();
...
...
@@ -708,7 +708,7 @@ pub fn define_macro(&mut self, item: &ast::Item, legacy_scope: &mut LegacyScope<
let
def
=
Def
::
Macro
(
def_id
,
MacroKind
::
Bang
);
self
.macro_exports
.push
(
Export
{
name
:
ident
.name
,
def
:
def
,
span
:
item
.span
});
}
else
{
self
.unused_macros
.insert
(
def_id
,
true
);
self
.unused_macros
.insert
(
def_id
);
}
}
...
...
src/libsyntax/ext/tt/macro_rules.rs
浏览文件 @
25b7f10c
...
...
@@ -252,11 +252,9 @@ pub fn compile(sess: &ParseSess, features: &RefCell<Features>, def: &ast::Item)
valid
:
valid
,
});
NormalTT
(
exp
,
NormalTT
(
exp
,
Some
((
def
.id
,
def
.span
)),
attr
::
contains_name
(
&
def
.attrs
,
"allow_internal_unstable"
)
)
attr
::
contains_name
(
&
def
.attrs
,
"allow_internal_unstable"
))
}
fn
check_lhs_nt_follows
(
sess
:
&
ParseSess
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录