Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
748eccd4
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,发现更多精彩内容 >>
提交
748eccd4
编写于
10月 07, 2019
作者:
M
Mark Rousskov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Lints being from a plugin is dependent on the lint, not the registration
上级
2121b047
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
23 addition
and
23 deletion
+23
-23
src/librustc/lint/context.rs
src/librustc/lint/context.rs
+7
-10
src/librustc/lint/mod.rs
src/librustc/lint/mod.rs
+5
-0
src/librustc_driver/lib.rs
src/librustc_driver/lib.rs
+2
-3
src/librustc_interface/passes.rs
src/librustc_interface/passes.rs
+2
-2
src/librustc_lint/lib.rs
src/librustc_lint/lib.rs
+7
-8
未找到文件。
src/librustc/lint/context.rs
浏览文件 @
748eccd4
...
...
@@ -50,7 +50,7 @@
pub
struct
LintStore
{
/// Registered lints. The bool is true if the lint was
/// added by a plugin.
lints
:
Vec
<
(
&
'static
Lint
,
bool
)
>
,
lints
:
Vec
<
&
'static
Lint
>
,
/// Trait objects for each lint pass.
/// This is only `None` while performing a lint pass.
...
...
@@ -152,7 +152,7 @@ pub fn new() -> LintStore {
}
}
pub
fn
get_lints
<
't
>
(
&
't
self
)
->
&
't
[
(
&
'static
Lint
,
bool
)
]
{
pub
fn
get_lints
<
't
>
(
&
't
self
)
->
&
't
[
&
'static
Lint
]
{
&
self
.lints
}
...
...
@@ -169,10 +169,9 @@ pub fn get_lint_groups<'t>(&'t self) -> Vec<(&'static str, Vec<LintId>, bool)> {
}
pub
fn
register_early_pass
(
&
mut
self
,
from_plugin
:
bool
,
register_only
:
bool
,
pass
:
EarlyLintPassObject
)
{
self
.push_lints
(
from_plugin
,
&
pass
.get_lints
());
self
.push_lints
(
&
pass
.get_lints
());
if
!
register_only
{
self
.early_passes
.as_mut
()
.unwrap
()
.push
(
pass
);
}
...
...
@@ -180,22 +179,20 @@ pub fn register_early_pass(&mut self,
pub
fn
register_pre_expansion_pass
(
&
mut
self
,
from_plugin
:
bool
,
register_only
:
bool
,
pass
:
EarlyLintPassObject
,
)
{
self
.push_lints
(
from_plugin
,
&
pass
.get_lints
());
self
.push_lints
(
&
pass
.get_lints
());
if
!
register_only
{
self
.pre_expansion_passes
.as_mut
()
.unwrap
()
.push
(
pass
);
}
}
pub
fn
register_late_pass
(
&
mut
self
,
from_plugin
:
bool
,
register_only
:
bool
,
per_module
:
bool
,
pass
:
LateLintPassObject
)
{
self
.push_lints
(
from_plugin
,
&
pass
.get_lints
());
self
.push_lints
(
&
pass
.get_lints
());
if
!
register_only
{
if
per_module
{
self
.late_module_passes
.push
(
pass
);
...
...
@@ -206,9 +203,9 @@ pub fn register_late_pass(&mut self,
}
// Helper method for register_early/late_pass
fn
push_lints
(
&
mut
self
,
from_plugin
:
bool
,
lints
:
&
[
&
'static
Lint
])
{
fn
push_lints
(
&
mut
self
,
lints
:
&
[
&
'static
Lint
])
{
for
lint
in
lints
{
self
.lints
.push
(
(
lint
,
from_plugin
)
);
self
.lints
.push
(
lint
);
let
id
=
LintId
::
of
(
lint
);
if
self
.by_name
.insert
(
lint
.name_lower
(),
Id
(
id
))
.is_some
()
{
...
...
src/librustc/lint/mod.rs
浏览文件 @
748eccd4
...
...
@@ -76,6 +76,8 @@ pub struct Lint {
/// `true` if this lint is reported even inside expansions of external macros.
pub
report_in_external_macro
:
bool
,
pub
is_plugin
:
bool
,
}
impl
Lint
{
...
...
@@ -117,6 +119,7 @@ pub fn default_level(&self, session: &Session) -> Level {
desc
:
$desc
,
edition_lint_opts
:
None
,
report_in_external_macro
:
$external
,
is_plugin
:
false
,
};
);
(
$vis
:
vis
$NAME
:
ident
,
$Level
:
ident
,
$desc
:
expr
,
...
...
@@ -128,6 +131,7 @@ pub fn default_level(&self, session: &Session) -> Level {
desc
:
$desc
,
edition_lint_opts
:
Some
((
$lint_edition
,
$crate
::
lint
::
Level
::
$edition_level
)),
report_in_external_macro
:
false
,
is_plugin
:
false
,
};
);
}
...
...
@@ -156,6 +160,7 @@ pub fn default_level(&self, session: &Session) -> Level {
desc
:
$desc
,
edition_lint_opts
:
None
,
report_in_external_macro
:
$external
,
is_plugin
:
true
,
};
);
}
...
...
src/librustc_driver/lib.rs
浏览文件 @
748eccd4
...
...
@@ -835,8 +835,7 @@ fn describe_lints(sess: &Session, lint_store: &lint::LintStore, loaded_plugins:
"
);
fn
sort_lints
(
sess
:
&
Session
,
lints
:
Vec
<
(
&
'static
Lint
,
bool
)
>
)
->
Vec
<&
'static
Lint
>
{
let
mut
lints
:
Vec
<
_
>
=
lints
.into_iter
()
.map
(|(
x
,
_
)|
x
)
.collect
();
fn
sort_lints
(
sess
:
&
Session
,
mut
lints
:
Vec
<&
'static
Lint
>
)
->
Vec
<&
'static
Lint
>
{
// The sort doesn't case-fold but it's doubtful we care.
lints
.sort_by_cached_key
(|
x
:
&&
Lint
|
(
x
.default_level
(
sess
),
x
.name
));
lints
...
...
@@ -852,7 +851,7 @@ fn sort_lint_groups(lints: Vec<(&'static str, Vec<lint::LintId>, bool)>)
let
(
plugin
,
builtin
):
(
Vec
<
_
>
,
_
)
=
lint_store
.get_lints
()
.iter
()
.cloned
()
.partition
(|
&
(
_
,
p
)|
p
);
.partition
(|
&
lint
|
lint
.is_plugin
);
let
plugin
=
sort_lints
(
sess
,
plugin
);
let
builtin
=
sort_lints
(
sess
,
builtin
);
...
...
src/librustc_interface/passes.rs
浏览文件 @
748eccd4
...
...
@@ -299,10 +299,10 @@ pub fn register_plugins<'a>(
let
mut
ls
=
sess
.lint_store
.borrow_mut
();
for
pass
in
early_lint_passes
{
ls
.register_early_pass
(
true
,
false
,
pass
);
ls
.register_early_pass
(
false
,
pass
);
}
for
pass
in
late_lint_passes
{
ls
.register_late_pass
(
true
,
false
,
false
,
pass
);
ls
.register_late_pass
(
false
,
false
,
pass
);
}
for
(
name
,
(
to
,
deprecated_name
))
in
lint_groups
{
...
...
src/librustc_lint/lib.rs
浏览文件 @
748eccd4
...
...
@@ -205,7 +205,7 @@ pub fn register_builtins(store: &mut lint::LintStore, no_interleave_lints: bool)
macro_rules!
register_pass
{
(
$method:ident
,
$constructor:expr
,
[
$
(
$args:expr
),
*
])
=>
(
store
.
$method
(
false
,
false
,
$
(
$args
,)
*
box
$constructor
);
store
.
$method
(
false
,
$
(
$args
,)
*
box
$constructor
);
)
}
...
...
@@ -224,16 +224,15 @@ pub fn register_builtins(store: &mut lint::LintStore, no_interleave_lints: bool)
late_lint_mod_passes!
(
register_passes
,
[
register_late_pass
,
[
true
]]);
}
else
{
store
.register_pre_expansion_pass
(
false
,
true
,
box
BuiltinCombinedPreExpansionLintPass
::
new
()
);
store
.register_early_pass
(
false
,
true
,
box
BuiltinCombinedEarlyLintPass
::
new
());
store
.register_early_pass
(
true
,
box
BuiltinCombinedEarlyLintPass
::
new
());
store
.register_late_pass
(
false
,
true
,
true
,
box
BuiltinCombinedModuleLateLintPass
::
new
()
true
,
true
,
box
BuiltinCombinedModuleLateLintPass
::
new
()
);
store
.register_late_pass
(
false
,
true
,
false
,
box
BuiltinCombinedLateLintPass
::
new
()
true
,
false
,
box
BuiltinCombinedLateLintPass
::
new
()
);
}
...
...
@@ -492,9 +491,9 @@ pub fn register_builtins(store: &mut lint::LintStore, no_interleave_lints: bool)
}
pub
fn
register_internals
(
store
:
&
mut
lint
::
LintStore
)
{
store
.register_early_pass
(
false
,
false
,
box
DefaultHashTypes
::
new
());
store
.register_early_pass
(
false
,
false
,
box
LintPassImpl
);
store
.register_late_pass
(
false
,
false
,
false
,
box
TyTyKind
);
store
.register_early_pass
(
false
,
box
DefaultHashTypes
::
new
());
store
.register_early_pass
(
false
,
box
LintPassImpl
);
store
.register_late_pass
(
false
,
false
,
box
TyTyKind
);
store
.register_group
(
false
,
"rustc::internal"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录