Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
eb58ac12
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
eb58ac12
编写于
9月 18, 2014
作者:
V
Victor Berger
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Lint stability now checks macro arguments.
Closes #17185.
上级
3907a13f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
36 addition
and
5 deletion
+36
-5
src/librustc/lint/builtin.rs
src/librustc/lint/builtin.rs
+21
-2
src/test/auxiliary/lint_stability.rs
src/test/auxiliary/lint_stability.rs
+10
-0
src/test/compile-fail/lint-stability.rs
src/test/compile-fail/lint-stability.rs
+5
-3
未找到文件。
src/librustc/lint/builtin.rs
浏览文件 @
eb58ac12
...
...
@@ -1490,8 +1490,27 @@ fn get_lints(&self) -> LintArray {
}
fn
check_expr
(
&
mut
self
,
cx
:
&
Context
,
e
:
&
ast
::
Expr
)
{
// if the expression was produced by a macro expansion,
if
e
.span.expn_id
!=
NO_EXPANSION
{
return
}
// skip if `e` is not from macro arguments
let
skip
=
cx
.tcx.sess
.codemap
()
.with_expn_info
(
e
.span.expn_id
,
|
expninfo
|
{
match
expninfo
{
Some
(
ref
info
)
=>
{
if
info
.call_site.expn_id
!=
NO_EXPANSION
||
!
(
e
.span.lo
>
info
.call_site.lo
&&
e
.span.hi
<
info
.call_site.hi
)
{
// This code is not from the arguments,
// or this macro call was generated by an other macro
// We can't handle it.
true
}
else
if
info
.callee.span
.is_none
()
{
// We don't want to mess with compiler builtins.
true
}
else
{
false
}
},
_
=>
{
false
}
}
});
if
skip
{
return
;
}
let
id
=
match
e
.node
{
ast
::
ExprPath
(
..
)
|
ast
::
ExprStruct
(
..
)
=>
{
...
...
src/test/auxiliary/lint_stability.rs
浏览文件 @
eb58ac12
...
...
@@ -181,3 +181,13 @@ pub enum Enum {
macro_rules!
macro_test
(
()
=>
(
deprecated
());
)
#[macro_export]
macro_rules!
macro_test_arg
(
(
$func:expr
)
=>
(
$func
);
)
#[macro_export]
macro_rules!
macro_test_arg_nested
(
(
$func:ident
)
=>
(
macro_test_arg!
(
$func
()));
)
src/test/compile-fail/lint-stability.rs
浏览文件 @
eb58ac12
...
...
@@ -109,12 +109,14 @@ fn test() {
let
_
=
FrozenTupleStruct
(
1
);
let
_
=
LockedTupleStruct
(
1
);
// At the moment, the
following just checks that the stability
//
level of expanded code does not trigger the
//
lint.
Eventually, we will want to lint the contents of the
// At the moment, the
lint checker only checks stability in
//
in the arguments of macros.
// Eventually, we will want to lint the contents of the
// macro in the module *defining* it. Also, stability levels
// on macros themselves are not yet linted.
macro_test!
();
macro_test_arg!
(
deprecated_text
());
//~ ERROR use of deprecated item: text
macro_test_arg_nested!
(
deprecated_text
);
}
fn
test_method_param
<
F
:
Trait
>
(
foo
:
F
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录