Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
5ffb7db4
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,发现更多精彩内容 >>
提交
5ffb7db4
编写于
2月 17, 2015
作者:
M
Manish Goregaokar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add `Gated` attribute type
上级
d5c3194c
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
34 addition
and
30 deletion
+34
-30
src/librustc/lint/builtin.rs
src/librustc/lint/builtin.rs
+6
-2
src/libsyntax/feature_gate.rs
src/libsyntax/feature_gate.rs
+28
-28
未找到文件。
src/librustc/lint/builtin.rs
浏览文件 @
5ffb7db4
...
@@ -642,8 +642,12 @@ fn get_lints(&self) -> LintArray {
...
@@ -642,8 +642,12 @@ fn get_lints(&self) -> LintArray {
fn
check_attribute
(
&
mut
self
,
cx
:
&
Context
,
attr
:
&
ast
::
Attribute
)
{
fn
check_attribute
(
&
mut
self
,
cx
:
&
Context
,
attr
:
&
ast
::
Attribute
)
{
for
&
(
ref
name
,
ty
)
in
KNOWN_ATTRIBUTES
{
for
&
(
ref
name
,
ty
)
in
KNOWN_ATTRIBUTES
{
if
ty
==
AttributeType
::
Whitelisted
&&
attr
.check_name
(
name
)
{
match
ty
{
AttributeType
::
Whitelisted
|
AttributeType
::
Gated
(
_
,
_
)
if
attr
.check_name
(
name
)
=>
{
break
;
break
;
},
_
=>
()
}
}
}
}
...
...
src/libsyntax/feature_gate.rs
浏览文件 @
5ffb7db4
...
@@ -166,20 +166,17 @@ enum Status {
...
@@ -166,20 +166,17 @@ enum Status {
(
"macro_reexport"
,
Normal
),
(
"macro_reexport"
,
Normal
),
(
"macro_use"
,
Normal
),
(
"macro_use"
,
Normal
),
(
"plugin"
,
Normal
),
(
"macro_export"
,
Normal
),
(
"macro_export"
,
Normal
),
(
"plugin_registrar"
,
Normal
),
(
"plugin_registrar"
,
Normal
),
(
"cfg"
,
Normal
),
(
"cfg"
,
Normal
),
(
"main"
,
Normal
),
(
"main"
,
Normal
),
(
"lang"
,
Normal
),
(
"start"
,
Normal
),
(
"start"
,
Normal
),
(
"test"
,
Normal
),
(
"test"
,
Normal
),
(
"bench"
,
Normal
),
(
"bench"
,
Normal
),
(
"simd"
,
Normal
),
(
"simd"
,
Normal
),
(
"repr"
,
Normal
),
(
"repr"
,
Normal
),
(
"path"
,
Normal
),
(
"path"
,
Normal
),
(
"staged_api"
,
Normal
),
(
"abi"
,
Normal
),
(
"abi"
,
Normal
),
(
"rustc_move_fragments"
,
Normal
),
(
"rustc_move_fragments"
,
Normal
),
(
"rustc_variance"
,
Normal
),
(
"rustc_variance"
,
Normal
),
...
@@ -195,6 +192,17 @@ enum Status {
...
@@ -195,6 +192,17 @@ enum Status {
(
"link_args"
,
Normal
),
(
"link_args"
,
Normal
),
(
"macro_escape"
,
Normal
),
(
"macro_escape"
,
Normal
),
(
"staged_api"
,
Gated
(
"staged_api"
,
"staged_api is for use by rustc only"
)),
(
"plugin"
,
Gated
(
"plugin"
,
"compiler plugins are experimental
\
and possibly buggy"
)),
(
"no_std"
,
Gated
(
"no_std"
,
"no_std is experimental"
)),
(
"lang"
,
Gated
(
"lang_items"
,
"language items are subject to change"
)),
// FIXME: #14408 whitelist docs since rustdoc looks at them
// FIXME: #14408 whitelist docs since rustdoc looks at them
(
"doc"
,
Whitelisted
),
(
"doc"
,
Whitelisted
),
...
@@ -242,7 +250,6 @@ enum Status {
...
@@ -242,7 +250,6 @@ enum Status {
(
"feature"
,
CrateLevel
),
(
"feature"
,
CrateLevel
),
(
"no_start"
,
CrateLevel
),
(
"no_start"
,
CrateLevel
),
(
"no_main"
,
CrateLevel
),
(
"no_main"
,
CrateLevel
),
(
"no_std"
,
CrateLevel
),
(
"no_builtins"
,
CrateLevel
),
(
"no_builtins"
,
CrateLevel
),
(
"recursion_limit"
,
CrateLevel
),
(
"recursion_limit"
,
CrateLevel
),
];
];
...
@@ -258,6 +265,10 @@ pub enum AttributeType {
...
@@ -258,6 +265,10 @@ pub enum AttributeType {
/// will be ignored by the unused_attribute lint
/// will be ignored by the unused_attribute lint
Whitelisted
,
Whitelisted
,
/// Is gated by a given feature gate and reason
/// These get whitelisted too
Gated
(
&
'static
str
,
&
'static
str
),
/// Builtin attribute that is only allowed at the crate level
/// Builtin attribute that is only allowed at the crate level
CrateLevel
,
CrateLevel
,
}
}
...
@@ -573,33 +584,22 @@ fn visit_expr(&mut self, e: &ast::Expr) {
...
@@ -573,33 +584,22 @@ fn visit_expr(&mut self, e: &ast::Expr) {
}
}
fn
visit_attribute
(
&
mut
self
,
attr
:
&
ast
::
Attribute
)
{
fn
visit_attribute
(
&
mut
self
,
attr
:
&
ast
::
Attribute
)
{
match
&*
attr
.name
()
{
let
name
=
&*
attr
.name
();
"staged_api"
=>
self
.gate_feature
(
"staged_api"
,
attr
.span
,
for
&
(
n
,
ty
)
in
KNOWN_ATTRIBUTES
{
"staged_api is for use by rustc only"
),
if
n
==
name
{
"plugin"
=>
self
.gate_feature
(
"plugin"
,
attr
.span
,
if
let
Gated
(
gate
,
desc
)
=
ty
{
"compiler plugins are experimental
\
self
.gate_feature
(
gate
,
attr
.span
,
desc
);
and possibly buggy"
),
}
"no_std"
=>
self
.gate_feature
(
"no_std"
,
attr
.span
,
return
;
"no_std is experimental"
),
}
"unsafe_no_drop_flag"
=>
self
.gate_feature
(
"unsafe_no_drop_flag"
,
attr
.span
,
"unsafe_no_drop_flag has unstable
\
}
semantics and may be removed
\
in the future"
),
"lang"
=>
self
.gate_feature
(
"lang_items"
,
attr
.span
,
"language items are subject to change"
),
name
=>
{
// Custom attribute check
if
KNOWN_ATTRIBUTES
.iter
()
.all
(|
&
(
n
,
_
)|
n
!=
name
)
{
self
.gate_feature
(
"custom_attribute"
,
attr
.span
,
self
.gate_feature
(
"custom_attribute"
,
attr
.span
,
format!
(
"The attribute `{}` is currently
\
format!
(
"The attribute `{}` is currently
\
unknown to the the compiler and
\
unknown to the the compiler and
\
may have meaning
\
may have meaning
\
added to it in the future"
,
added to it in the future"
,
attr
.name
())
.as_slice
());
name
)
.as_slice
());
}
}
}
}
}
fn
visit_pat
(
&
mut
self
,
pattern
:
&
ast
::
Pat
)
{
fn
visit_pat
(
&
mut
self
,
pattern
:
&
ast
::
Pat
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录