Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
1ff0ba03
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,发现更多精彩内容 >>
未验证
提交
1ff0ba03
编写于
6月 07, 2020
作者:
D
Dylan DPC
提交者:
GitHub
6月 07, 2020
浏览文件
操作
浏览文件
下载
差异文件
Rollup merge of #72970 - OddCoincidence:feature-gated-lints, r=petrochenkov
Properly handle feature-gated lints Closes #72694
上级
cbab7452
e7e6bc11
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
29 addition
and
21 deletion
+29
-21
src/librustc_lint/levels.rs
src/librustc_lint/levels.rs
+15
-14
src/librustc_session/lint.rs
src/librustc_session/lint.rs
+9
-1
src/librustc_session/lint/builtin.rs
src/librustc_session/lint/builtin.rs
+2
-0
src/librustdoc/core.rs
src/librustdoc/core.rs
+3
-6
未找到文件。
src/librustc_lint/levels.rs
浏览文件 @
1ff0ba03
...
...
@@ -214,9 +214,9 @@ pub fn push(&mut self, attrs: &[ast::Attribute], store: &LintStore) -> BuilderPu
match
store
.check_lint_name
(
&
name
.as_str
(),
tool_name
)
{
CheckLintNameResult
::
Ok
(
ids
)
=>
{
let
src
=
LintSource
::
Node
(
name
,
li
.span
(),
reason
);
for
id
in
ids
{
self
.check_gated_lint
(
*
id
,
attr
.span
);
specs
.insert
(
*
id
,
(
level
,
src
));
for
&
id
in
ids
{
self
.check_gated_lint
(
id
,
attr
.span
);
specs
.insert
(
id
,
(
level
,
src
));
}
}
...
...
@@ -386,17 +386,18 @@ pub fn push(&mut self, attrs: &[ast::Attribute], store: &LintStore) -> BuilderPu
BuilderPush
{
prev
,
changed
:
prev
!=
self
.cur
}
}
fn
check_gated_lint
(
&
self
,
id
:
LintId
,
span
:
Span
)
{
if
id
==
LintId
::
of
(
builtin
::
UNSAFE_OP_IN_UNSAFE_FN
)
&&
!
self
.sess
.features_untracked
()
.unsafe_block_in_unsafe_fn
{
feature_err
(
&
self
.sess.parse_sess
,
sym
::
unsafe_block_in_unsafe_fn
,
span
,
"the `unsafe_op_in_unsafe_fn` lint is unstable"
,
)
.emit
();
/// Checks if the lint is gated on a feature that is not enabled.
fn
check_gated_lint
(
&
self
,
lint_id
:
LintId
,
span
:
Span
)
{
if
let
Some
(
feature
)
=
lint_id
.lint.feature_gate
{
if
!
self
.sess
.features_untracked
()
.enabled
(
feature
)
{
feature_err
(
&
self
.sess.parse_sess
,
feature
,
span
,
&
format!
(
"the `{}` lint is unstable"
,
lint_id
.lint
.name_lower
()),
)
.emit
();
}
}
}
...
...
src/librustc_session/lint.rs
浏览文件 @
1ff0ba03
...
...
@@ -85,6 +85,9 @@ pub struct Lint {
pub
future_incompatible
:
Option
<
FutureIncompatibleInfo
>
,
pub
is_plugin
:
bool
,
/// `Some` if this lint is feature gated, otherwise `None`.
pub
feature_gate
:
Option
<
Symbol
>
,
}
/// Extra information for a future incompatibility lint.
...
...
@@ -107,6 +110,7 @@ pub const fn default_fields_for_macro() -> Self {
is_plugin
:
false
,
report_in_external_macro
:
false
,
future_incompatible
:
None
,
feature_gate
:
None
,
}
}
...
...
@@ -276,7 +280,9 @@ pub fn buffer_lint_with_diagnostic(
);
);
(
$vis
:
vis
$NAME
:
ident
,
$Level
:
ident
,
$desc
:
expr
,
$
(
@
future_incompatible
=
$fi:expr
;)
?
$
(
$v:ident
),
*
)
=>
(
$
(
@
future_incompatible
=
$fi:expr
;)
?
$
(
@
feature_gate
=
$gate:expr
;)
?
$
(
$v:ident
),
*
)
=>
(
$vis
static
$NAME
:
&
$crate
::
lint
::
Lint
=
&
$crate
::
lint
::
Lint
{
name
:
stringify!
(
$NAME
),
default_level
:
$crate
::
lint
::
$Level
,
...
...
@@ -285,6 +291,7 @@ pub fn buffer_lint_with_diagnostic(
is_plugin
:
false
,
$
(
$v
:
true
,)
*
$
(
future_incompatible
:
Some
(
$fi
),)
*
$
(
feature_gate
:
Some
(
$gate
),)
*
..
$crate
::
lint
::
Lint
::
default_fields_for_macro
()
};
);
...
...
@@ -328,6 +335,7 @@ pub fn buffer_lint_with_diagnostic(
report_in_external_macro
:
$external
,
future_incompatible
:
None
,
is_plugin
:
true
,
feature_gate
:
None
,
};
);
}
...
...
src/librustc_session/lint/builtin.rs
浏览文件 @
1ff0ba03
...
...
@@ -7,6 +7,7 @@
use
crate
::
lint
::
FutureIncompatibleInfo
;
use
crate
::{
declare_lint
,
declare_lint_pass
};
use
rustc_span
::
edition
::
Edition
;
use
rustc_span
::
symbol
::
sym
;
declare_lint!
{
pub
ILL_FORMED_ATTRIBUTE_INPUT
,
...
...
@@ -530,6 +531,7 @@
pub
UNSAFE_OP_IN_UNSAFE_FN
,
Allow
,
"unsafe operations in unsafe functions without an explicit unsafe block are deprecated"
,
@
feature_gate
=
sym
::
unsafe_block_in_unsafe_fn
;
}
declare_lint_pass!
{
...
...
src/librustdoc/core.rs
浏览文件 @
1ff0ba03
...
...
@@ -225,11 +225,6 @@ pub fn init_lints<F>(
{
let
warnings_lint_name
=
lint
::
builtin
::
WARNINGS
.name
;
// Whitelist feature-gated lints to avoid feature errors when trying to
// allow all lints.
// FIXME(#72694): handle feature-gated lints properly.
let
unsafe_op_in_unsafe_fn_name
=
rustc_lint
::
builtin
::
UNSAFE_OP_IN_UNSAFE_FN
.name
;
whitelisted_lints
.push
(
warnings_lint_name
.to_owned
());
whitelisted_lints
.extend
(
lint_opts
.iter
()
.map
(|(
lint
,
_
)|
lint
)
.cloned
());
...
...
@@ -241,7 +236,9 @@ pub fn init_lints<F>(
let
lint_opts
=
lints
()
.filter_map
(|
lint
|
{
if
lint
.name
==
warnings_lint_name
||
lint
.name
==
unsafe_op_in_unsafe_fn_name
{
// Whitelist feature-gated lints to avoid feature errors when trying to
// allow all lints.
if
lint
.name
==
warnings_lint_name
||
lint
.feature_gate
.is_some
()
{
None
}
else
{
filter_call
(
lint
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录