Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
c701872a
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,发现更多精彩内容 >>
提交
c701872a
编写于
1月 24, 2021
作者:
C
Camille GILLOT
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove hir::Item::attrs.
上级
5474f170
变更
32
隐藏空白更改
内联
并排
Showing
32 changed file
with
104 addition
and
76 deletion
+104
-76
compiler/rustc_ast_lowering/src/item.rs
compiler/rustc_ast_lowering/src/item.rs
+1
-3
compiler/rustc_ast_lowering/src/lib.rs
compiler/rustc_ast_lowering/src/lib.rs
+0
-1
compiler/rustc_hir/src/hir.rs
compiler/rustc_hir/src/hir.rs
+1
-2
compiler/rustc_hir/src/stable_hash_impls.rs
compiler/rustc_hir/src/stable_hash_impls.rs
+1
-2
compiler/rustc_hir_pretty/src/lib.rs
compiler/rustc_hir_pretty/src/lib.rs
+5
-4
compiler/rustc_interface/src/proc_macro_decls.rs
compiler/rustc_interface/src/proc_macro_decls.rs
+2
-1
compiler/rustc_lint/src/builtin.rs
compiler/rustc_lint/src/builtin.rs
+5
-3
compiler/rustc_lint/src/internal.rs
compiler/rustc_lint/src/internal.rs
+1
-1
compiler/rustc_lint/src/nonstandard_style.rs
compiler/rustc_lint/src/nonstandard_style.rs
+2
-1
compiler/rustc_metadata/src/link_args.rs
compiler/rustc_metadata/src/link_args.rs
+3
-1
compiler/rustc_metadata/src/native_libs.rs
compiler/rustc_metadata/src/native_libs.rs
+2
-1
compiler/rustc_passes/src/entry.rs
compiler/rustc_passes/src/entry.rs
+8
-6
compiler/rustc_passes/src/stability.rs
compiler/rustc_passes/src/stability.rs
+2
-1
compiler/rustc_plugin_impl/src/build.rs
compiler/rustc_plugin_impl/src/build.rs
+2
-1
compiler/rustc_resolve/src/late/lifetimes.rs
compiler/rustc_resolve/src/late/lifetimes.rs
+2
-1
compiler/rustc_save_analysis/src/dump_visitor.rs
compiler/rustc_save_analysis/src/dump_visitor.rs
+9
-6
compiler/rustc_save_analysis/src/lib.rs
compiler/rustc_save_analysis/src/lib.rs
+11
-10
compiler/rustc_typeck/src/check/method/suggest.rs
compiler/rustc_typeck/src/check/method/suggest.rs
+3
-2
compiler/rustc_typeck/src/lib.rs
compiler/rustc_typeck/src/lib.rs
+4
-2
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+12
-10
src/librustdoc/visit_ast.rs
src/librustdoc/visit_ast.rs
+3
-1
src/tools/clippy/clippy_lints/src/attrs.rs
src/tools/clippy/clippy_lints/src/attrs.rs
+4
-3
src/tools/clippy/clippy_lints/src/derive.rs
src/tools/clippy/clippy_lints/src/derive.rs
+2
-1
src/tools/clippy/clippy_lints/src/doc.rs
src/tools/clippy/clippy_lints/src/doc.rs
+2
-1
src/tools/clippy/clippy_lints/src/exhaustive_items.rs
src/tools/clippy/clippy_lints/src/exhaustive_items.rs
+2
-1
src/tools/clippy/clippy_lints/src/functions.rs
src/tools/clippy/clippy_lints/src/functions.rs
+3
-2
src/tools/clippy/clippy_lints/src/macro_use.rs
src/tools/clippy/clippy_lints/src/macro_use.rs
+2
-2
src/tools/clippy/clippy_lints/src/missing_doc.rs
src/tools/clippy/clippy_lints/src/missing_doc.rs
+2
-1
src/tools/clippy/clippy_lints/src/missing_inline.rs
src/tools/clippy/clippy_lints/src/missing_inline.rs
+2
-1
src/tools/clippy/clippy_lints/src/needless_borrow.rs
src/tools/clippy/clippy_lints/src/needless_borrow.rs
+3
-2
src/tools/clippy/clippy_lints/src/partialeq_ne_impl.rs
src/tools/clippy/clippy_lints/src/partialeq_ne_impl.rs
+2
-1
src/tools/clippy/clippy_lints/src/utils/inspector.rs
src/tools/clippy/clippy_lints/src/utils/inspector.rs
+1
-1
未找到文件。
compiler/rustc_ast_lowering/src/item.rs
浏览文件 @
c701872a
...
@@ -242,7 +242,7 @@ pub fn lower_item(&mut self, i: &Item) -> Option<hir::Item<'hir>> {
...
@@ -242,7 +242,7 @@ pub fn lower_item(&mut self, i: &Item) -> Option<hir::Item<'hir>> {
let
hir_id
=
self
.lower_node_id
(
i
.id
);
let
hir_id
=
self
.lower_node_id
(
i
.id
);
let
attrs
=
self
.lower_attrs
(
hir_id
,
&
i
.attrs
);
let
attrs
=
self
.lower_attrs
(
hir_id
,
&
i
.attrs
);
let
kind
=
self
.lower_item_kind
(
i
.span
,
i
.id
,
hir_id
,
&
mut
ident
,
attrs
,
&
mut
vis
,
&
i
.kind
);
let
kind
=
self
.lower_item_kind
(
i
.span
,
i
.id
,
hir_id
,
&
mut
ident
,
attrs
,
&
mut
vis
,
&
i
.kind
);
Some
(
hir
::
Item
{
def_id
:
hir_id
.expect_owner
(),
ident
,
attrs
,
kind
,
vis
,
span
:
i
.span
})
Some
(
hir
::
Item
{
def_id
:
hir_id
.expect_owner
(),
ident
,
kind
,
vis
,
span
:
i
.span
})
}
}
fn
lower_item_kind
(
fn
lower_item_kind
(
...
@@ -556,7 +556,6 @@ fn lower_use_tree(
...
@@ -556,7 +556,6 @@ fn lower_use_tree(
this
.insert_item
(
hir
::
Item
{
this
.insert_item
(
hir
::
Item
{
def_id
:
new_id
.expect_owner
(),
def_id
:
new_id
.expect_owner
(),
ident
,
ident
,
attrs
,
kind
,
kind
,
vis
,
vis
,
span
,
span
,
...
@@ -629,7 +628,6 @@ fn lower_use_tree(
...
@@ -629,7 +628,6 @@ fn lower_use_tree(
this
.insert_item
(
hir
::
Item
{
this
.insert_item
(
hir
::
Item
{
def_id
:
new_hir_id
.expect_owner
(),
def_id
:
new_hir_id
.expect_owner
(),
ident
,
ident
,
attrs
,
kind
,
kind
,
vis
,
vis
,
span
:
use_tree
.span
,
span
:
use_tree
.span
,
...
...
compiler/rustc_ast_lowering/src/lib.rs
浏览文件 @
c701872a
...
@@ -1579,7 +1579,6 @@ fn generate_opaque_type(
...
@@ -1579,7 +1579,6 @@ fn generate_opaque_type(
let
opaque_ty_item
=
hir
::
Item
{
let
opaque_ty_item
=
hir
::
Item
{
def_id
:
opaque_ty_id
,
def_id
:
opaque_ty_id
,
ident
:
Ident
::
invalid
(),
ident
:
Ident
::
invalid
(),
attrs
:
Default
::
default
(),
kind
:
opaque_ty_item_kind
,
kind
:
opaque_ty_item_kind
,
vis
:
respan
(
span
.shrink_to_lo
(),
hir
::
VisibilityKind
::
Inherited
),
vis
:
respan
(
span
.shrink_to_lo
(),
hir
::
VisibilityKind
::
Inherited
),
span
:
opaque_ty_span
,
span
:
opaque_ty_span
,
...
...
compiler/rustc_hir/src/hir.rs
浏览文件 @
c701872a
...
@@ -2697,7 +2697,6 @@ pub fn hir_id(&self) -> HirId {
...
@@ -2697,7 +2697,6 @@ pub fn hir_id(&self) -> HirId {
pub
struct
Item
<
'hir
>
{
pub
struct
Item
<
'hir
>
{
pub
ident
:
Ident
,
pub
ident
:
Ident
,
pub
def_id
:
LocalDefId
,
pub
def_id
:
LocalDefId
,
pub
attrs
:
&
'hir
[
Attribute
],
pub
kind
:
ItemKind
<
'hir
>
,
pub
kind
:
ItemKind
<
'hir
>
,
pub
vis
:
Visibility
<
'hir
>
,
pub
vis
:
Visibility
<
'hir
>
,
pub
span
:
Span
,
pub
span
:
Span
,
...
@@ -3077,7 +3076,7 @@ mod size_asserts {
...
@@ -3077,7 +3076,7 @@ mod size_asserts {
rustc_data_structures
::
static_assert_size!
(
super
::
QPath
<
'static
>
,
24
);
rustc_data_structures
::
static_assert_size!
(
super
::
QPath
<
'static
>
,
24
);
rustc_data_structures
::
static_assert_size!
(
super
::
Ty
<
'static
>
,
72
);
rustc_data_structures
::
static_assert_size!
(
super
::
Ty
<
'static
>
,
72
);
rustc_data_structures
::
static_assert_size!
(
super
::
Item
<
'static
>
,
200
);
rustc_data_structures
::
static_assert_size!
(
super
::
Item
<
'static
>
,
184
);
rustc_data_structures
::
static_assert_size!
(
super
::
TraitItem
<
'static
>
,
128
);
rustc_data_structures
::
static_assert_size!
(
super
::
TraitItem
<
'static
>
,
128
);
rustc_data_structures
::
static_assert_size!
(
super
::
ImplItem
<
'static
>
,
152
);
rustc_data_structures
::
static_assert_size!
(
super
::
ImplItem
<
'static
>
,
152
);
rustc_data_structures
::
static_assert_size!
(
super
::
ForeignItem
<
'static
>
,
136
);
rustc_data_structures
::
static_assert_size!
(
super
::
ForeignItem
<
'static
>
,
136
);
...
...
compiler/rustc_hir/src/stable_hash_impls.rs
浏览文件 @
c701872a
...
@@ -181,11 +181,10 @@ fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
...
@@ -181,11 +181,10 @@ fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
impl
<
HirCtx
:
crate
::
HashStableContext
>
HashStable
<
HirCtx
>
for
Item
<
'_
>
{
impl
<
HirCtx
:
crate
::
HashStableContext
>
HashStable
<
HirCtx
>
for
Item
<
'_
>
{
fn
hash_stable
(
&
self
,
hcx
:
&
mut
HirCtx
,
hasher
:
&
mut
StableHasher
)
{
fn
hash_stable
(
&
self
,
hcx
:
&
mut
HirCtx
,
hasher
:
&
mut
StableHasher
)
{
let
Item
{
ident
,
ref
attrs
,
def_id
:
_
,
ref
kind
,
ref
vis
,
span
}
=
*
self
;
let
Item
{
ident
,
def_id
:
_
,
ref
kind
,
ref
vis
,
span
}
=
*
self
;
hcx
.hash_hir_item_like
(|
hcx
|
{
hcx
.hash_hir_item_like
(|
hcx
|
{
ident
.name
.hash_stable
(
hcx
,
hasher
);
ident
.name
.hash_stable
(
hcx
,
hasher
);
attrs
.hash_stable
(
hcx
,
hasher
);
kind
.hash_stable
(
hcx
,
hasher
);
kind
.hash_stable
(
hcx
,
hasher
);
vis
.hash_stable
(
hcx
,
hasher
);
vis
.hash_stable
(
hcx
,
hasher
);
span
.hash_stable
(
hcx
,
hasher
);
span
.hash_stable
(
hcx
,
hasher
);
...
...
compiler/rustc_hir_pretty/src/lib.rs
浏览文件 @
c701872a
...
@@ -561,7 +561,8 @@ fn print_item_type(
...
@@ -561,7 +561,8 @@ fn print_item_type(
pub
fn
print_item
(
&
mut
self
,
item
:
&
hir
::
Item
<
'_
>
)
{
pub
fn
print_item
(
&
mut
self
,
item
:
&
hir
::
Item
<
'_
>
)
{
self
.hardbreak_if_not_bol
();
self
.hardbreak_if_not_bol
();
self
.maybe_print_comment
(
item
.span
.lo
());
self
.maybe_print_comment
(
item
.span
.lo
());
self
.print_outer_attributes
(
&
item
.attrs
);
let
attrs
=
self
.attrs
(
item
.hir_id
());
self
.print_outer_attributes
(
attrs
);
self
.ann
.pre
(
self
,
AnnNode
::
Item
(
item
));
self
.ann
.pre
(
self
,
AnnNode
::
Item
(
item
));
match
item
.kind
{
match
item
.kind
{
hir
::
ItemKind
::
ExternCrate
(
orig_name
)
=>
{
hir
::
ItemKind
::
ExternCrate
(
orig_name
)
=>
{
...
@@ -646,14 +647,14 @@ pub fn print_item(&mut self, item: &hir::Item<'_>) {
...
@@ -646,14 +647,14 @@ pub fn print_item(&mut self, item: &hir::Item<'_>) {
self
.print_ident
(
item
.ident
);
self
.print_ident
(
item
.ident
);
self
.nbsp
();
self
.nbsp
();
self
.bopen
();
self
.bopen
();
self
.print_mod
(
_
mod
,
&
item
.
attrs
);
self
.print_mod
(
_
mod
,
attrs
);
self
.bclose
(
item
.span
);
self
.bclose
(
item
.span
);
}
}
hir
::
ItemKind
::
ForeignMod
{
abi
,
items
}
=>
{
hir
::
ItemKind
::
ForeignMod
{
abi
,
items
}
=>
{
self
.head
(
"extern"
);
self
.head
(
"extern"
);
self
.word_nbsp
(
abi
.to_string
());
self
.word_nbsp
(
abi
.to_string
());
self
.bopen
();
self
.bopen
();
self
.print_inner_attributes
(
item
.attrs
);
self
.print_inner_attributes
(
self
.attrs
(
item
.hir_id
())
);
for
item
in
items
{
for
item
in
items
{
self
.ann
.nested
(
self
,
Nested
::
ForeignItem
(
item
.id
));
self
.ann
.nested
(
self
,
Nested
::
ForeignItem
(
item
.id
));
}
}
...
@@ -737,7 +738,7 @@ pub fn print_item(&mut self, item: &hir::Item<'_>) {
...
@@ -737,7 +738,7 @@ pub fn print_item(&mut self, item: &hir::Item<'_>) {
self
.s
.space
();
self
.s
.space
();
self
.bopen
();
self
.bopen
();
self
.print_inner_attributes
(
&
item
.
attrs
);
self
.print_inner_attributes
(
attrs
);
for
impl_item
in
items
{
for
impl_item
in
items
{
self
.ann
.nested
(
self
,
Nested
::
ImplItem
(
impl_item
.id
));
self
.ann
.nested
(
self
,
Nested
::
ImplItem
(
impl_item
.id
));
}
}
...
...
compiler/rustc_interface/src/proc_macro_decls.rs
浏览文件 @
c701872a
...
@@ -25,7 +25,8 @@ struct Finder<'tcx> {
...
@@ -25,7 +25,8 @@ struct Finder<'tcx> {
impl
<
'v
>
ItemLikeVisitor
<
'v
>
for
Finder
<
'_
>
{
impl
<
'v
>
ItemLikeVisitor
<
'v
>
for
Finder
<
'_
>
{
fn
visit_item
(
&
mut
self
,
item
:
&
hir
::
Item
<
'_
>
)
{
fn
visit_item
(
&
mut
self
,
item
:
&
hir
::
Item
<
'_
>
)
{
if
self
.tcx.sess
.contains_name
(
&
item
.attrs
,
sym
::
rustc_proc_macro_decls
)
{
let
attrs
=
self
.tcx
.hir
()
.attrs
(
item
.hir_id
());
if
self
.tcx.sess
.contains_name
(
attrs
,
sym
::
rustc_proc_macro_decls
)
{
self
.decls
=
Some
(
item
.hir_id
());
self
.decls
=
Some
(
item
.hir_id
());
}
}
}
}
...
...
compiler/rustc_lint/src/builtin.rs
浏览文件 @
c701872a
...
@@ -1092,9 +1092,10 @@ fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &ast::Expr) {
...
@@ -1092,9 +1092,10 @@ fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &ast::Expr) {
impl
<
'tcx
>
LateLintPass
<
'tcx
>
for
InvalidNoMangleItems
{
impl
<
'tcx
>
LateLintPass
<
'tcx
>
for
InvalidNoMangleItems
{
fn
check_item
(
&
mut
self
,
cx
:
&
LateContext
<
'_
>
,
it
:
&
hir
::
Item
<
'_
>
)
{
fn
check_item
(
&
mut
self
,
cx
:
&
LateContext
<
'_
>
,
it
:
&
hir
::
Item
<
'_
>
)
{
let
attrs
=
cx
.tcx
.hir
()
.attrs
(
it
.hir_id
());
match
it
.kind
{
match
it
.kind
{
hir
::
ItemKind
::
Fn
(
..
,
ref
generics
,
_
)
=>
{
hir
::
ItemKind
::
Fn
(
..
,
ref
generics
,
_
)
=>
{
if
let
Some
(
no_mangle_attr
)
=
cx
.sess
()
.find_by_name
(
&
it
.
attrs
,
sym
::
no_mangle
)
{
if
let
Some
(
no_mangle_attr
)
=
cx
.sess
()
.find_by_name
(
attrs
,
sym
::
no_mangle
)
{
for
param
in
generics
.params
{
for
param
in
generics
.params
{
match
param
.kind
{
match
param
.kind
{
GenericParamKind
::
Lifetime
{
..
}
=>
{}
GenericParamKind
::
Lifetime
{
..
}
=>
{}
...
@@ -1120,7 +1121,7 @@ fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
...
@@ -1120,7 +1121,7 @@ fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
}
}
}
}
hir
::
ItemKind
::
Const
(
..
)
=>
{
hir
::
ItemKind
::
Const
(
..
)
=>
{
if
cx
.sess
()
.contains_name
(
&
it
.
attrs
,
sym
::
no_mangle
)
{
if
cx
.sess
()
.contains_name
(
attrs
,
sym
::
no_mangle
)
{
// Const items do not refer to a particular location in memory, and therefore
// Const items do not refer to a particular location in memory, and therefore
// don't have anything to attach a symbol to
// don't have anything to attach a symbol to
cx
.struct_span_lint
(
NO_MANGLE_CONST_ITEMS
,
it
.span
,
|
lint
|
{
cx
.struct_span_lint
(
NO_MANGLE_CONST_ITEMS
,
it
.span
,
|
lint
|
{
...
@@ -1800,7 +1801,8 @@ fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
...
@@ -1800,7 +1801,8 @@ fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
return
;
return
;
}
}
if
let
Some
(
attr
)
=
cx
.sess
()
.find_by_name
(
&
it
.attrs
,
sym
::
rustc_test_marker
)
{
let
attrs
=
cx
.tcx
.hir
()
.attrs
(
it
.hir_id
());
if
let
Some
(
attr
)
=
cx
.sess
()
.find_by_name
(
attrs
,
sym
::
rustc_test_marker
)
{
cx
.struct_span_lint
(
UNNAMEABLE_TEST_ITEMS
,
attr
.span
,
|
lint
|
{
cx
.struct_span_lint
(
UNNAMEABLE_TEST_ITEMS
,
attr
.span
,
|
lint
|
{
lint
.build
(
"cannot test inner items"
)
.emit
()
lint
.build
(
"cannot test inner items"
)
.emit
()
});
});
...
...
compiler/rustc_lint/src/internal.rs
浏览文件 @
c701872a
...
@@ -283,7 +283,7 @@ fn is_doc_keyword(s: Symbol) -> bool {
...
@@ -283,7 +283,7 @@ fn is_doc_keyword(s: Symbol) -> bool {
impl
<
'tcx
>
LateLintPass
<
'tcx
>
for
ExistingDocKeyword
{
impl
<
'tcx
>
LateLintPass
<
'tcx
>
for
ExistingDocKeyword
{
fn
check_item
(
&
mut
self
,
cx
:
&
LateContext
<
'_
>
,
item
:
&
rustc_hir
::
Item
<
'_
>
)
{
fn
check_item
(
&
mut
self
,
cx
:
&
LateContext
<
'_
>
,
item
:
&
rustc_hir
::
Item
<
'_
>
)
{
for
attr
in
item
.attrs
{
for
attr
in
cx
.tcx
.hir
()
.attrs
(
item
.hir_id
())
{
if
!
attr
.has_name
(
sym
::
doc
)
{
if
!
attr
.has_name
(
sym
::
doc
)
{
continue
;
continue
;
}
}
...
...
compiler/rustc_lint/src/nonstandard_style.rs
浏览文件 @
c701872a
...
@@ -505,8 +505,9 @@ fn check_upper_case(cx: &LateContext<'_>, sort: &str, ident: &Ident) {
...
@@ -505,8 +505,9 @@ fn check_upper_case(cx: &LateContext<'_>, sort: &str, ident: &Ident) {
impl
<
'tcx
>
LateLintPass
<
'tcx
>
for
NonUpperCaseGlobals
{
impl
<
'tcx
>
LateLintPass
<
'tcx
>
for
NonUpperCaseGlobals
{
fn
check_item
(
&
mut
self
,
cx
:
&
LateContext
<
'_
>
,
it
:
&
hir
::
Item
<
'_
>
)
{
fn
check_item
(
&
mut
self
,
cx
:
&
LateContext
<
'_
>
,
it
:
&
hir
::
Item
<
'_
>
)
{
let
attrs
=
cx
.tcx
.hir
()
.attrs
(
it
.hir_id
());
match
it
.kind
{
match
it
.kind
{
hir
::
ItemKind
::
Static
(
..
)
if
!
cx
.sess
()
.contains_name
(
&
it
.
attrs
,
sym
::
no_mangle
)
=>
{
hir
::
ItemKind
::
Static
(
..
)
if
!
cx
.sess
()
.contains_name
(
attrs
,
sym
::
no_mangle
)
=>
{
NonUpperCaseGlobals
::
check_upper_case
(
cx
,
"static variable"
,
&
it
.ident
);
NonUpperCaseGlobals
::
check_upper_case
(
cx
,
"static variable"
,
&
it
.ident
);
}
}
hir
::
ItemKind
::
Const
(
..
)
=>
{
hir
::
ItemKind
::
Const
(
..
)
=>
{
...
...
compiler/rustc_metadata/src/link_args.rs
浏览文件 @
c701872a
...
@@ -36,7 +36,9 @@ fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) {
...
@@ -36,7 +36,9 @@ fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) {
// First, add all of the custom #[link_args] attributes
// First, add all of the custom #[link_args] attributes
let
sess
=
&
self
.tcx.sess
;
let
sess
=
&
self
.tcx.sess
;
for
m
in
it
.attrs
.iter
()
.filter
(|
a
|
sess
.check_name
(
a
,
sym
::
link_args
))
{
for
m
in
self
.tcx
.hir
()
.attrs
(
it
.hir_id
())
.iter
()
.filter
(|
a
|
sess
.check_name
(
a
,
sym
::
link_args
))
{
if
let
Some
(
linkarg
)
=
m
.value_str
()
{
if
let
Some
(
linkarg
)
=
m
.value_str
()
{
self
.add_link_args
(
linkarg
);
self
.add_link_args
(
linkarg
);
}
}
...
...
compiler/rustc_metadata/src/native_libs.rs
浏览文件 @
c701872a
...
@@ -44,7 +44,8 @@ fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) {
...
@@ -44,7 +44,8 @@ fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) {
// Process all of the #[link(..)]-style arguments
// Process all of the #[link(..)]-style arguments
let
sess
=
&
self
.tcx.sess
;
let
sess
=
&
self
.tcx.sess
;
for
m
in
it
.attrs
.iter
()
.filter
(|
a
|
sess
.check_name
(
a
,
sym
::
link
))
{
for
m
in
self
.tcx
.hir
()
.attrs
(
it
.hir_id
())
.iter
()
.filter
(|
a
|
sess
.check_name
(
a
,
sym
::
link
))
{
let
items
=
match
m
.meta_item_list
()
{
let
items
=
match
m
.meta_item_list
()
{
Some
(
item
)
=>
item
,
Some
(
item
)
=>
item
,
None
=>
continue
,
None
=>
continue
,
...
...
compiler/rustc_passes/src/entry.rs
浏览文件 @
c701872a
...
@@ -80,10 +80,11 @@ fn entry_fn(tcx: TyCtxt<'_>, cnum: CrateNum) -> Option<(LocalDefId, EntryFnType)
...
@@ -80,10 +80,11 @@ fn entry_fn(tcx: TyCtxt<'_>, cnum: CrateNum) -> Option<(LocalDefId, EntryFnType)
// Beware, this is duplicated in `librustc_builtin_macros/test_harness.rs`
// Beware, this is duplicated in `librustc_builtin_macros/test_harness.rs`
// (with `ast::Item`), so make sure to keep them in sync.
// (with `ast::Item`), so make sure to keep them in sync.
fn
entry_point_type
(
sess
:
&
Session
,
item
:
&
Item
<
'_
>
,
at_root
:
bool
)
->
EntryPointType
{
fn
entry_point_type
(
ctxt
:
&
EntryContext
<
'_
,
'_
>
,
item
:
&
Item
<
'_
>
,
at_root
:
bool
)
->
EntryPointType
{
if
sess
.contains_name
(
&
item
.attrs
,
sym
::
start
)
{
let
attrs
=
ctxt
.map
.attrs
(
item
.hir_id
());
if
ctxt
.session
.contains_name
(
attrs
,
sym
::
start
)
{
EntryPointType
::
Start
EntryPointType
::
Start
}
else
if
sess
.contains_name
(
&
item
.
attrs
,
sym
::
main
)
{
}
else
if
ctxt
.session
.contains_name
(
attrs
,
sym
::
main
)
{
EntryPointType
::
MainAttr
EntryPointType
::
MainAttr
}
else
if
item
.ident.name
==
sym
::
main
{
}
else
if
item
.ident.name
==
sym
::
main
{
if
at_root
{
if
at_root
{
...
@@ -103,13 +104,14 @@ fn throw_attr_err(sess: &Session, span: Span, attr: &str) {
...
@@ -103,13 +104,14 @@ fn throw_attr_err(sess: &Session, span: Span, attr: &str) {
}
}
fn
find_item
(
item
:
&
Item
<
'_
>
,
ctxt
:
&
mut
EntryContext
<
'_
,
'_
>
,
at_root
:
bool
)
{
fn
find_item
(
item
:
&
Item
<
'_
>
,
ctxt
:
&
mut
EntryContext
<
'_
,
'_
>
,
at_root
:
bool
)
{
match
entry_point_type
(
&
ctxt
.session
,
item
,
at_root
)
{
match
entry_point_type
(
ctxt
,
item
,
at_root
)
{
EntryPointType
::
None
=>
(),
EntryPointType
::
None
=>
(),
_
if
!
matches!
(
item
.kind
,
ItemKind
::
Fn
(
..
))
=>
{
_
if
!
matches!
(
item
.kind
,
ItemKind
::
Fn
(
..
))
=>
{
if
let
Some
(
attr
)
=
ctxt
.session
.find_by_name
(
item
.attrs
,
sym
::
start
)
{
let
attrs
=
ctxt
.map
.attrs
(
item
.hir_id
());
if
let
Some
(
attr
)
=
ctxt
.session
.find_by_name
(
attrs
,
sym
::
start
)
{
throw_attr_err
(
&
ctxt
.session
,
attr
.span
,
"start"
);
throw_attr_err
(
&
ctxt
.session
,
attr
.span
,
"start"
);
}
}
if
let
Some
(
attr
)
=
ctxt
.session
.find_by_name
(
item
.
attrs
,
sym
::
main
)
{
if
let
Some
(
attr
)
=
ctxt
.session
.find_by_name
(
attrs
,
sym
::
main
)
{
throw_attr_err
(
&
ctxt
.session
,
attr
.span
,
"main"
);
throw_attr_err
(
&
ctxt
.session
,
attr
.span
,
"main"
);
}
}
}
}
...
...
compiler/rustc_passes/src/stability.rs
浏览文件 @
c701872a
...
@@ -751,8 +751,9 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
...
@@ -751,8 +751,9 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
// error if all involved types and traits are stable, because
// error if all involved types and traits are stable, because
// it will have no effect.
// it will have no effect.
// See: https://github.com/rust-lang/rust/issues/55436
// See: https://github.com/rust-lang/rust/issues/55436
let
attrs
=
self
.tcx
.hir
()
.attrs
(
item
.hir_id
());
if
let
(
Some
((
Stability
{
level
:
attr
::
Unstable
{
..
},
..
},
span
)),
_
)
=
if
let
(
Some
((
Stability
{
level
:
attr
::
Unstable
{
..
},
..
},
span
)),
_
)
=
attr
::
find_stability
(
&
self
.tcx.sess
,
&
item
.
attrs
,
item
.span
)
attr
::
find_stability
(
&
self
.tcx.sess
,
attrs
,
item
.span
)
{
{
let
mut
c
=
CheckTraitImplStable
{
tcx
:
self
.tcx
,
fully_stable
:
true
};
let
mut
c
=
CheckTraitImplStable
{
tcx
:
self
.tcx
,
fully_stable
:
true
};
c
.visit_ty
(
self_ty
);
c
.visit_ty
(
self_ty
);
...
...
compiler/rustc_plugin_impl/src/build.rs
浏览文件 @
c701872a
...
@@ -16,7 +16,8 @@ struct RegistrarFinder<'tcx> {
...
@@ -16,7 +16,8 @@ struct RegistrarFinder<'tcx> {
impl
<
'v
,
'tcx
>
ItemLikeVisitor
<
'v
>
for
RegistrarFinder
<
'tcx
>
{
impl
<
'v
,
'tcx
>
ItemLikeVisitor
<
'v
>
for
RegistrarFinder
<
'tcx
>
{
fn
visit_item
(
&
mut
self
,
item
:
&
hir
::
Item
<
'_
>
)
{
fn
visit_item
(
&
mut
self
,
item
:
&
hir
::
Item
<
'_
>
)
{
if
let
hir
::
ItemKind
::
Fn
(
..
)
=
item
.kind
{
if
let
hir
::
ItemKind
::
Fn
(
..
)
=
item
.kind
{
if
self
.tcx.sess
.contains_name
(
&
item
.attrs
,
sym
::
plugin_registrar
)
{
let
attrs
=
self
.tcx
.hir
()
.attrs
(
item
.hir_id
());
if
self
.tcx.sess
.contains_name
(
attrs
,
sym
::
plugin_registrar
)
{
self
.registrars
.push
((
item
.def_id
,
item
.span
));
self
.registrars
.push
((
item
.def_id
,
item
.span
));
}
}
}
}
...
...
compiler/rustc_resolve/src/late/lifetimes.rs
浏览文件 @
c701872a
...
@@ -1239,7 +1239,8 @@ fn compute_object_lifetime_defaults(tcx: TyCtxt<'_>) -> HirIdMap<Vec<ObjectLifet
...
@@ -1239,7 +1239,8 @@ fn compute_object_lifetime_defaults(tcx: TyCtxt<'_>) -> HirIdMap<Vec<ObjectLifet
let
result
=
object_lifetime_defaults_for_item
(
tcx
,
generics
);
let
result
=
object_lifetime_defaults_for_item
(
tcx
,
generics
);
// Debugging aid.
// Debugging aid.
if
tcx
.sess
.contains_name
(
&
item
.attrs
,
sym
::
rustc_object_lifetime_default
)
{
let
attrs
=
tcx
.hir
()
.attrs
(
item
.hir_id
());
if
tcx
.sess
.contains_name
(
attrs
,
sym
::
rustc_object_lifetime_default
)
{
let
object_lifetime_default_reprs
:
String
=
result
let
object_lifetime_default_reprs
:
String
=
result
.iter
()
.iter
()
.map
(|
set
|
match
*
set
{
.map
(|
set
|
match
*
set
{
...
...
compiler/rustc_save_analysis/src/dump_visitor.rs
浏览文件 @
c701872a
...
@@ -496,6 +496,7 @@ fn process_struct(
...
@@ -496,6 +496,7 @@ fn process_struct(
if
!
self
.span
.filter_generated
(
item
.ident.span
)
{
if
!
self
.span
.filter_generated
(
item
.ident.span
)
{
let
span
=
self
.span_from_span
(
item
.ident.span
);
let
span
=
self
.span_from_span
(
item
.ident.span
);
let
attrs
=
self
.tcx
.hir
()
.attrs
(
item
.hir_id
());
self
.dumper
.dump_def
(
self
.dumper
.dump_def
(
&
access_from!
(
self
.save_ctxt
,
item
,
item
.hir_id
()),
&
access_from!
(
self
.save_ctxt
,
item
,
item
.hir_id
()),
Def
{
Def
{
...
@@ -508,9 +509,9 @@ fn process_struct(
...
@@ -508,9 +509,9 @@ fn process_struct(
parent
:
None
,
parent
:
None
,
children
:
fields
,
children
:
fields
,
decl_id
:
None
,
decl_id
:
None
,
docs
:
self
.save_ctxt
.docs_for_attrs
(
&
item
.
attrs
),
docs
:
self
.save_ctxt
.docs_for_attrs
(
attrs
),
sig
:
sig
::
item_signature
(
item
,
&
self
.save_ctxt
),
sig
:
sig
::
item_signature
(
item
,
&
self
.save_ctxt
),
attributes
:
lower_attributes
(
item
.
attrs
.to_vec
(),
&
self
.save_ctxt
),
attributes
:
lower_attributes
(
attrs
.to_vec
(),
&
self
.save_ctxt
),
},
},
);
);
}
}
...
@@ -671,6 +672,7 @@ fn process_trait(
...
@@ -671,6 +672,7 @@ fn process_trait(
let
span
=
self
.span_from_span
(
item
.ident.span
);
let
span
=
self
.span_from_span
(
item
.ident.span
);
let
children
=
let
children
=
methods
.iter
()
.map
(|
i
|
id_from_def_id
(
i
.id.def_id
.to_def_id
()))
.collect
();
methods
.iter
()
.map
(|
i
|
id_from_def_id
(
i
.id.def_id
.to_def_id
()))
.collect
();
let
attrs
=
self
.tcx
.hir
()
.attrs
(
item
.hir_id
());
self
.dumper
.dump_def
(
self
.dumper
.dump_def
(
&
access_from!
(
self
.save_ctxt
,
item
,
item
.hir_id
()),
&
access_from!
(
self
.save_ctxt
,
item
,
item
.hir_id
()),
Def
{
Def
{
...
@@ -683,9 +685,9 @@ fn process_trait(
...
@@ -683,9 +685,9 @@ fn process_trait(
parent
:
None
,
parent
:
None
,
children
,
children
,
decl_id
:
None
,
decl_id
:
None
,
docs
:
self
.save_ctxt
.docs_for_attrs
(
&
item
.
attrs
),
docs
:
self
.save_ctxt
.docs_for_attrs
(
attrs
),
sig
:
sig
::
item_signature
(
item
,
&
self
.save_ctxt
),
sig
:
sig
::
item_signature
(
item
,
&
self
.save_ctxt
),
attributes
:
lower_attributes
(
item
.
attrs
.to_vec
(),
&
self
.save_ctxt
),
attributes
:
lower_attributes
(
attrs
.to_vec
(),
&
self
.save_ctxt
),
},
},
);
);
}
}
...
@@ -1260,6 +1262,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
...
@@ -1260,6 +1262,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
if
!
self
.span
.filter_generated
(
item
.ident.span
)
{
if
!
self
.span
.filter_generated
(
item
.ident.span
)
{
let
span
=
self
.span_from_span
(
item
.ident.span
);
let
span
=
self
.span_from_span
(
item
.ident.span
);
let
id
=
id_from_def_id
(
item
.def_id
.to_def_id
());
let
id
=
id_from_def_id
(
item
.def_id
.to_def_id
());
let
attrs
=
self
.tcx
.hir
()
.attrs
(
item
.hir_id
());
self
.dumper
.dump_def
(
self
.dumper
.dump_def
(
&
access_from!
(
self
.save_ctxt
,
item
,
item
.hir_id
()),
&
access_from!
(
self
.save_ctxt
,
item
,
item
.hir_id
()),
...
@@ -1273,9 +1276,9 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
...
@@ -1273,9 +1276,9 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
parent
:
None
,
parent
:
None
,
children
:
vec!
[],
children
:
vec!
[],
decl_id
:
None
,
decl_id
:
None
,
docs
:
self
.save_ctxt
.docs_for_attrs
(
&
item
.
attrs
),
docs
:
self
.save_ctxt
.docs_for_attrs
(
attrs
),
sig
:
sig
::
item_signature
(
item
,
&
self
.save_ctxt
),
sig
:
sig
::
item_signature
(
item
,
&
self
.save_ctxt
),
attributes
:
lower_attributes
(
item
.
attrs
.to_vec
(),
&
self
.save_ctxt
),
attributes
:
lower_attributes
(
attrs
.to_vec
(),
&
self
.save_ctxt
),
},
},
);
);
}
}
...
...
compiler/rustc_save_analysis/src/lib.rs
浏览文件 @
c701872a
...
@@ -203,6 +203,7 @@ pub fn get_extern_item_data(&self, item: &hir::ForeignItem<'_>) -> Option<Data>
...
@@ -203,6 +203,7 @@ pub fn get_extern_item_data(&self, item: &hir::ForeignItem<'_>) -> Option<Data>
pub
fn
get_item_data
(
&
self
,
item
:
&
hir
::
Item
<
'_
>
)
->
Option
<
Data
>
{
pub
fn
get_item_data
(
&
self
,
item
:
&
hir
::
Item
<
'_
>
)
->
Option
<
Data
>
{
let
def_id
=
item
.def_id
.to_def_id
();
let
def_id
=
item
.def_id
.to_def_id
();
let
attrs
=
self
.tcx
.hir
()
.attrs
(
item
.hir_id
());
match
item
.kind
{
match
item
.kind
{
hir
::
ItemKind
::
Fn
(
ref
sig
,
ref
generics
,
_
)
=>
{
hir
::
ItemKind
::
Fn
(
ref
sig
,
ref
generics
,
_
)
=>
{
let
qualname
=
format!
(
"::{}"
,
self
.tcx
.def_path_str
(
def_id
));
let
qualname
=
format!
(
"::{}"
,
self
.tcx
.def_path_str
(
def_id
));
...
@@ -225,9 +226,9 @@ pub fn get_item_data(&self, item: &hir::Item<'_>) -> Option<Data> {
...
@@ -225,9 +226,9 @@ pub fn get_item_data(&self, item: &hir::Item<'_>) -> Option<Data> {
parent
:
None
,
parent
:
None
,
children
:
vec!
[],
children
:
vec!
[],
decl_id
:
None
,
decl_id
:
None
,
docs
:
self
.docs_for_attrs
(
&
item
.
attrs
),
docs
:
self
.docs_for_attrs
(
attrs
),
sig
:
sig
::
item_signature
(
item
,
self
),
sig
:
sig
::
item_signature
(
item
,
self
),
attributes
:
lower_attributes
(
item
.
attrs
.to_vec
(),
self
),
attributes
:
lower_attributes
(
attrs
.to_vec
(),
self
),
}))
}))
}
}
hir
::
ItemKind
::
Static
(
ref
typ
,
..
)
=>
{
hir
::
ItemKind
::
Static
(
ref
typ
,
..
)
=>
{
...
@@ -248,9 +249,9 @@ pub fn get_item_data(&self, item: &hir::Item<'_>) -> Option<Data> {
...
@@ -248,9 +249,9 @@ pub fn get_item_data(&self, item: &hir::Item<'_>) -> Option<Data> {
parent
:
None
,
parent
:
None
,
children
:
vec!
[],
children
:
vec!
[],
decl_id
:
None
,
decl_id
:
None
,
docs
:
self
.docs_for_attrs
(
&
item
.
attrs
),
docs
:
self
.docs_for_attrs
(
attrs
),
sig
:
sig
::
item_signature
(
item
,
self
),
sig
:
sig
::
item_signature
(
item
,
self
),
attributes
:
lower_attributes
(
item
.
attrs
.to_vec
(),
self
),
attributes
:
lower_attributes
(
attrs
.to_vec
(),
self
),
}))
}))
}
}
hir
::
ItemKind
::
Const
(
ref
typ
,
_
)
=>
{
hir
::
ItemKind
::
Const
(
ref
typ
,
_
)
=>
{
...
@@ -270,9 +271,9 @@ pub fn get_item_data(&self, item: &hir::Item<'_>) -> Option<Data> {
...
@@ -270,9 +271,9 @@ pub fn get_item_data(&self, item: &hir::Item<'_>) -> Option<Data> {
parent
:
None
,
parent
:
None
,
children
:
vec!
[],
children
:
vec!
[],
decl_id
:
None
,
decl_id
:
None
,
docs
:
self
.docs_for_attrs
(
&
item
.
attrs
),
docs
:
self
.docs_for_attrs
(
attrs
),
sig
:
sig
::
item_signature
(
item
,
self
),
sig
:
sig
::
item_signature
(
item
,
self
),
attributes
:
lower_attributes
(
item
.
attrs
.to_vec
(),
self
),
attributes
:
lower_attributes
(
attrs
.to_vec
(),
self
),
}))
}))
}
}
hir
::
ItemKind
::
Mod
(
ref
m
)
=>
{
hir
::
ItemKind
::
Mod
(
ref
m
)
=>
{
...
@@ -297,9 +298,9 @@ pub fn get_item_data(&self, item: &hir::Item<'_>) -> Option<Data> {
...
@@ -297,9 +298,9 @@ pub fn get_item_data(&self, item: &hir::Item<'_>) -> Option<Data> {
.map
(|
i
|
id_from_def_id
(
i
.def_id
.to_def_id
()))
.map
(|
i
|
id_from_def_id
(
i
.def_id
.to_def_id
()))
.collect
(),
.collect
(),
decl_id
:
None
,
decl_id
:
None
,
docs
:
self
.docs_for_attrs
(
&
item
.
attrs
),
docs
:
self
.docs_for_attrs
(
attrs
),
sig
:
sig
::
item_signature
(
item
,
self
),
sig
:
sig
::
item_signature
(
item
,
self
),
attributes
:
lower_attributes
(
item
.
attrs
.to_vec
(),
self
),
attributes
:
lower_attributes
(
attrs
.to_vec
(),
self
),
}))
}))
}
}
hir
::
ItemKind
::
Enum
(
ref
def
,
ref
generics
)
=>
{
hir
::
ItemKind
::
Enum
(
ref
def
,
ref
generics
)
=>
{
...
@@ -318,9 +319,9 @@ pub fn get_item_data(&self, item: &hir::Item<'_>) -> Option<Data> {
...
@@ -318,9 +319,9 @@ pub fn get_item_data(&self, item: &hir::Item<'_>) -> Option<Data> {
parent
:
None
,
parent
:
None
,
children
:
def
.variants
.iter
()
.map
(|
v
|
id_from_hir_id
(
v
.id
,
self
))
.collect
(),
children
:
def
.variants
.iter
()
.map
(|
v
|
id_from_hir_id
(
v
.id
,
self
))
.collect
(),
decl_id
:
None
,
decl_id
:
None
,
docs
:
self
.docs_for_attrs
(
&
item
.
attrs
),
docs
:
self
.docs_for_attrs
(
attrs
),
sig
:
sig
::
item_signature
(
item
,
self
),
sig
:
sig
::
item_signature
(
item
,
self
),
attributes
:
lower_attributes
(
item
.
attrs
.to_vec
(),
self
),
attributes
:
lower_attributes
(
attrs
.to_vec
(),
self
),
}))
}))
}
}
hir
::
ItemKind
::
Impl
(
hir
::
Impl
{
ref
of_trait
,
ref
self_ty
,
ref
items
,
..
})
=>
{
hir
::
ItemKind
::
Impl
(
hir
::
Impl
{
ref
of_trait
,
ref
self_ty
,
ref
items
,
..
})
=>
{
...
...
compiler/rustc_typeck/src/check/method/suggest.rs
浏览文件 @
c701872a
...
@@ -1466,11 +1466,12 @@ fn visit_mod(&mut self, module: &'tcx hir::Mod<'tcx>, _: Span, hir_id: hir::HirI
...
@@ -1466,11 +1466,12 @@ fn visit_mod(&mut self, module: &'tcx hir::Mod<'tcx>, _: Span, hir_id: hir::HirI
if
self
.span
.map_or
(
true
,
|
span
|
item
.span
<
span
)
{
if
self
.span
.map_or
(
true
,
|
span
|
item
.span
<
span
)
{
if
!
item
.span
.from_expansion
()
{
if
!
item
.span
.from_expansion
()
{
// Don't insert between attributes and an item.
// Don't insert between attributes and an item.
if
item
.attrs
.is_empty
()
{
let
attrs
=
self
.tcx
.hir
()
.attrs
(
item
.hir_id
());
if
attrs
.is_empty
()
{
self
.span
=
Some
(
item
.span
.shrink_to_lo
());
self
.span
=
Some
(
item
.span
.shrink_to_lo
());
}
else
{
}
else
{
// Find the first attribute on the item.
// Find the first attribute on the item.
for
attr
in
item
.
attrs
{
for
attr
in
attrs
{
if
self
.span
.map_or
(
true
,
|
span
|
attr
.span
<
span
)
{
if
self
.span
.map_or
(
true
,
|
span
|
attr
.span
<
span
)
{
self
.span
=
Some
(
attr
.span
.shrink_to_lo
());
self
.span
=
Some
(
attr
.span
.shrink_to_lo
());
}
}
...
...
compiler/rustc_typeck/src/lib.rs
浏览文件 @
c701872a
...
@@ -201,7 +201,8 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: LocalDefId) {
...
@@ -201,7 +201,8 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: LocalDefId) {
error
=
true
;
error
=
true
;
}
}
for
attr
in
it
.attrs
{
let
attrs
=
tcx
.hir
()
.attrs
(
main_id
);
for
attr
in
attrs
{
if
tcx
.sess
.check_name
(
attr
,
sym
::
track_caller
)
{
if
tcx
.sess
.check_name
(
attr
,
sym
::
track_caller
)
{
tcx
.sess
tcx
.sess
.struct_span_err
(
.struct_span_err
(
...
@@ -300,7 +301,8 @@ fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: LocalDefId) {
...
@@ -300,7 +301,8 @@ fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: LocalDefId) {
error
=
true
;
error
=
true
;
}
}
for
attr
in
it
.attrs
{
let
attrs
=
tcx
.hir
()
.attrs
(
start_id
);
for
attr
in
attrs
{
if
tcx
.sess
.check_name
(
attr
,
sym
::
track_caller
)
{
if
tcx
.sess
.check_name
(
attr
,
sym
::
track_caller
)
{
tcx
.sess
tcx
.sess
.struct_span_err
(
.struct_span_err
(
...
...
src/librustdoc/clean/mod.rs
浏览文件 @
c701872a
...
@@ -863,7 +863,8 @@ fn clean_fn_or_proc_macro(
...
@@ -863,7 +863,8 @@ fn clean_fn_or_proc_macro(
name
:
&
mut
Symbol
,
name
:
&
mut
Symbol
,
cx
:
&
mut
DocContext
<
'_
>
,
cx
:
&
mut
DocContext
<
'_
>
,
)
->
ItemKind
{
)
->
ItemKind
{
let
macro_kind
=
item
.attrs
.iter
()
.find_map
(|
a
|
{
let
attrs
=
cx
.tcx
.hir
()
.attrs
(
item
.hir_id
());
let
macro_kind
=
attrs
.iter
()
.find_map
(|
a
|
{
if
a
.has_name
(
sym
::
proc_macro
)
{
if
a
.has_name
(
sym
::
proc_macro
)
{
Some
(
MacroKind
::
Bang
)
Some
(
MacroKind
::
Bang
)
}
else
if
a
.has_name
(
sym
::
proc_macro_derive
)
{
}
else
if
a
.has_name
(
sym
::
proc_macro_derive
)
{
...
@@ -877,8 +878,7 @@ fn clean_fn_or_proc_macro(
...
@@ -877,8 +878,7 @@ fn clean_fn_or_proc_macro(
match
macro_kind
{
match
macro_kind
{
Some
(
kind
)
=>
{
Some
(
kind
)
=>
{
if
kind
==
MacroKind
::
Derive
{
if
kind
==
MacroKind
::
Derive
{
*
name
=
item
*
name
=
attrs
.attrs
.lists
(
sym
::
proc_macro_derive
)
.lists
(
sym
::
proc_macro_derive
)
.find_map
(|
mi
|
mi
.ident
())
.find_map
(|
mi
|
mi
.ident
())
.expect
(
"proc-macro derives require a name"
)
.expect
(
"proc-macro derives require a name"
)
...
@@ -886,7 +886,7 @@ fn clean_fn_or_proc_macro(
...
@@ -886,7 +886,7 @@ fn clean_fn_or_proc_macro(
}
}
let
mut
helpers
=
Vec
::
new
();
let
mut
helpers
=
Vec
::
new
();
for
mi
in
item
.
attrs
.lists
(
sym
::
proc_macro_derive
)
{
for
mi
in
attrs
.lists
(
sym
::
proc_macro_derive
)
{
if
!
mi
.has_name
(
sym
::
attributes
)
{
if
!
mi
.has_name
(
sym
::
attributes
)
{
continue
;
continue
;
}
}
...
@@ -2102,8 +2102,9 @@ fn clean_extern_crate(
...
@@ -2102,8 +2102,9 @@ fn clean_extern_crate(
let
cnum
=
cx
.tcx
.extern_mod_stmt_cnum
(
krate
.def_id
)
.unwrap_or
(
LOCAL_CRATE
);
let
cnum
=
cx
.tcx
.extern_mod_stmt_cnum
(
krate
.def_id
)
.unwrap_or
(
LOCAL_CRATE
);
// this is the ID of the crate itself
// this is the ID of the crate itself
let
crate_def_id
=
DefId
{
krate
:
cnum
,
index
:
CRATE_DEF_INDEX
};
let
crate_def_id
=
DefId
{
krate
:
cnum
,
index
:
CRATE_DEF_INDEX
};
let
attrs
=
cx
.tcx
.hir
()
.attrs
(
krate
.hir_id
());
let
please_inline
=
krate
.vis.node
.is_pub
()
let
please_inline
=
krate
.vis.node
.is_pub
()
&&
krate
.
attrs
.iter
()
.any
(|
a
|
{
&&
attrs
.iter
()
.any
(|
a
|
{
a
.has_name
(
sym
::
doc
)
a
.has_name
(
sym
::
doc
)
&&
match
a
.meta_item_list
()
{
&&
match
a
.meta_item_list
()
{
Some
(
l
)
=>
attr
::
list_contains_name
(
&
l
,
sym
::
inline
),
Some
(
l
)
=>
attr
::
list_contains_name
(
&
l
,
sym
::
inline
),
...
@@ -2121,7 +2122,7 @@ fn clean_extern_crate(
...
@@ -2121,7 +2122,7 @@ fn clean_extern_crate(
cx
.tcx
.parent_module
(
krate
.hir_id
())
.to_def_id
(),
cx
.tcx
.parent_module
(
krate
.hir_id
())
.to_def_id
(),
res
,
res
,
name
,
name
,
Some
(
krate
.
attrs
),
Some
(
attrs
),
&
mut
visited
,
&
mut
visited
,
)
{
)
{
return
items
;
return
items
;
...
@@ -2130,7 +2131,7 @@ fn clean_extern_crate(
...
@@ -2130,7 +2131,7 @@ fn clean_extern_crate(
// FIXME: using `from_def_id_and_kind` breaks `rustdoc/masked` for some reason
// FIXME: using `from_def_id_and_kind` breaks `rustdoc/masked` for some reason
vec!
[
Item
{
vec!
[
Item
{
name
:
Some
(
name
),
name
:
Some
(
name
),
attrs
:
box
krate
.
attrs
.clean
(
cx
),
attrs
:
box
attrs
.clean
(
cx
),
source
:
krate
.span
.clean
(
cx
),
source
:
krate
.span
.clean
(
cx
),
def_id
:
crate_def_id
,
def_id
:
crate_def_id
,
visibility
:
krate
.vis
.clean
(
cx
),
visibility
:
krate
.vis
.clean
(
cx
),
...
@@ -2152,7 +2153,8 @@ fn clean_use_statement(
...
@@ -2152,7 +2153,8 @@ fn clean_use_statement(
return
Vec
::
new
();
return
Vec
::
new
();
}
}
let
inline_attr
=
import
.attrs
.lists
(
sym
::
doc
)
.get_word_attr
(
sym
::
inline
);
let
attrs
=
cx
.tcx
.hir
()
.attrs
(
import
.hir_id
());
let
inline_attr
=
attrs
.lists
(
sym
::
doc
)
.get_word_attr
(
sym
::
inline
);
let
pub_underscore
=
import
.vis.node
.is_pub
()
&&
name
==
kw
::
Underscore
;
let
pub_underscore
=
import
.vis.node
.is_pub
()
&&
name
==
kw
::
Underscore
;
if
pub_underscore
{
if
pub_underscore
{
...
@@ -2174,7 +2176,7 @@ fn clean_use_statement(
...
@@ -2174,7 +2176,7 @@ fn clean_use_statement(
// Don't inline doc(hidden) imports so they can be stripped at a later stage.
// Don't inline doc(hidden) imports so they can be stripped at a later stage.
let
mut
denied
=
!
import
.vis.node
.is_pub
()
let
mut
denied
=
!
import
.vis.node
.is_pub
()
||
pub_underscore
||
pub_underscore
||
import
.
attrs
.iter
()
.any
(|
a
|
{
||
attrs
.iter
()
.any
(|
a
|
{
a
.has_name
(
sym
::
doc
)
a
.has_name
(
sym
::
doc
)
&&
match
a
.meta_item_list
()
{
&&
match
a
.meta_item_list
()
{
Some
(
l
)
=>
{
Some
(
l
)
=>
{
...
@@ -2214,7 +2216,7 @@ fn clean_use_statement(
...
@@ -2214,7 +2216,7 @@ fn clean_use_statement(
cx
.tcx
.parent_module
(
import
.hir_id
())
.to_def_id
(),
cx
.tcx
.parent_module
(
import
.hir_id
())
.to_def_id
(),
path
.res
,
path
.res
,
name
,
name
,
Some
(
import
.
attrs
),
Some
(
attrs
),
&
mut
visited
,
&
mut
visited
,
)
{
)
{
items
.push
(
Item
::
from_def_id_and_parts
(
items
.push
(
Item
::
from_def_id_and_parts
(
...
...
src/librustdoc/visit_ast.rs
浏览文件 @
c701872a
...
@@ -285,10 +285,12 @@ fn visit_item(
...
@@ -285,10 +285,12 @@ fn visit_item(
return
;
return
;
}
}
let
attrs
=
self
.cx.tcx
.hir
()
.attrs
(
item
.hir_id
());
// If there was a private module in the current path then don't bother inlining
// If there was a private module in the current path then don't bother inlining
// anything as it will probably be stripped anyway.
// anything as it will probably be stripped anyway.
if
item
.vis.node
.is_pub
()
&&
self
.inside_public_path
{
if
item
.vis.node
.is_pub
()
&&
self
.inside_public_path
{
let
please_inline
=
item
.
attrs
.iter
()
.any
(|
item
|
match
item
.meta_item_list
()
{
let
please_inline
=
attrs
.iter
()
.any
(|
item
|
match
item
.meta_item_list
()
{
Some
(
ref
list
)
if
item
.has_name
(
sym
::
doc
)
=>
{
Some
(
ref
list
)
if
item
.has_name
(
sym
::
doc
)
=>
{
list
.iter
()
.any
(|
i
|
i
.has_name
(
sym
::
inline
))
list
.iter
()
.any
(|
i
|
i
.has_name
(
sym
::
inline
))
}
}
...
...
src/tools/clippy/clippy_lints/src/attrs.rs
浏览文件 @
c701872a
...
@@ -276,14 +276,15 @@ fn check_attribute(&mut self, cx: &LateContext<'tcx>, attr: &'tcx Attribute) {
...
@@ -276,14 +276,15 @@ fn check_attribute(&mut self, cx: &LateContext<'tcx>, attr: &'tcx Attribute) {
}
}
fn
check_item
(
&
mut
self
,
cx
:
&
LateContext
<
'tcx
>
,
item
:
&
'tcx
Item
<
'_
>
)
{
fn
check_item
(
&
mut
self
,
cx
:
&
LateContext
<
'tcx
>
,
item
:
&
'tcx
Item
<
'_
>
)
{
let
attrs
=
cx
.tcx
.hir
()
.attrs
(
item
.hir_id
());
if
is_relevant_item
(
cx
,
item
)
{
if
is_relevant_item
(
cx
,
item
)
{
check_attrs
(
cx
,
item
.span
,
item
.ident.name
,
&
item
.
attrs
)
check_attrs
(
cx
,
item
.span
,
item
.ident.name
,
attrs
)
}
}
match
item
.kind
{
match
item
.kind
{
ItemKind
::
ExternCrate
(
..
)
|
ItemKind
::
Use
(
..
)
=>
{
ItemKind
::
ExternCrate
(
..
)
|
ItemKind
::
Use
(
..
)
=>
{
let
skip_unused_imports
=
item
.
attrs
.iter
()
.any
(|
attr
|
attr
.has_name
(
sym
::
macro_use
));
let
skip_unused_imports
=
attrs
.iter
()
.any
(|
attr
|
attr
.has_name
(
sym
::
macro_use
));
for
attr
in
item
.
attrs
{
for
attr
in
attrs
{
if
in_external_macro
(
cx
.sess
(),
attr
.span
)
{
if
in_external_macro
(
cx
.sess
(),
attr
.span
)
{
return
;
return
;
}
}
...
...
src/tools/clippy/clippy_lints/src/derive.rs
浏览文件 @
c701872a
...
@@ -170,7 +170,8 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
...
@@ -170,7 +170,8 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
})
=
item
.kind
})
=
item
.kind
{
{
let
ty
=
cx
.tcx
.type_of
(
item
.def_id
);
let
ty
=
cx
.tcx
.type_of
(
item
.def_id
);
let
is_automatically_derived
=
is_automatically_derived
(
&*
item
.attrs
);
let
attrs
=
cx
.tcx
.hir
()
.attrs
(
item
.hir_id
());
let
is_automatically_derived
=
is_automatically_derived
(
attrs
);
check_hash_peq
(
cx
,
item
.span
,
trait_ref
,
ty
,
is_automatically_derived
);
check_hash_peq
(
cx
,
item
.span
,
trait_ref
,
ty
,
is_automatically_derived
);
check_ord_partial_ord
(
cx
,
item
.span
,
trait_ref
,
ty
,
is_automatically_derived
);
check_ord_partial_ord
(
cx
,
item
.span
,
trait_ref
,
ty
,
is_automatically_derived
);
...
...
src/tools/clippy/clippy_lints/src/doc.rs
浏览文件 @
c701872a
...
@@ -214,7 +214,8 @@ fn check_crate(&mut self, cx: &LateContext<'tcx>, _: &'tcx hir::Crate<'_>) {
...
@@ -214,7 +214,8 @@ fn check_crate(&mut self, cx: &LateContext<'tcx>, _: &'tcx hir::Crate<'_>) {
}
}
fn
check_item
(
&
mut
self
,
cx
:
&
LateContext
<
'tcx
>
,
item
:
&
'tcx
hir
::
Item
<
'_
>
)
{
fn
check_item
(
&
mut
self
,
cx
:
&
LateContext
<
'tcx
>
,
item
:
&
'tcx
hir
::
Item
<
'_
>
)
{
let
headers
=
check_attrs
(
cx
,
&
self
.valid_idents
,
&
item
.attrs
);
let
attrs
=
cx
.tcx
.hir
()
.attrs
(
item
.hir_id
());
let
headers
=
check_attrs
(
cx
,
&
self
.valid_idents
,
attrs
);
match
item
.kind
{
match
item
.kind
{
hir
::
ItemKind
::
Fn
(
ref
sig
,
_
,
body_id
)
=>
{
hir
::
ItemKind
::
Fn
(
ref
sig
,
_
,
body_id
)
=>
{
if
!
(
is_entrypoint_fn
(
cx
,
item
.def_id
.to_def_id
())
||
in_external_macro
(
cx
.tcx.sess
,
item
.span
))
{
if
!
(
is_entrypoint_fn
(
cx
,
item
.def_id
.to_def_id
())
||
in_external_macro
(
cx
.tcx.sess
,
item
.span
))
{
...
...
src/tools/clippy/clippy_lints/src/exhaustive_items.rs
浏览文件 @
c701872a
...
@@ -73,7 +73,8 @@ fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) {
...
@@ -73,7 +73,8 @@ fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) {
if_chain!
{
if_chain!
{
if
let
ItemKind
::
Enum
(
..
)
|
ItemKind
::
Struct
(
..
)
=
item
.kind
;
if
let
ItemKind
::
Enum
(
..
)
|
ItemKind
::
Struct
(
..
)
=
item
.kind
;
if
cx
.access_levels
.is_exported
(
item
.hir_id
());
if
cx
.access_levels
.is_exported
(
item
.hir_id
());
if
!
item
.attrs
.iter
()
.any
(|
a
|
a
.has_name
(
sym
::
non_exhaustive
));
let
attrs
=
cx
.tcx
.hir
()
.attrs
(
item
.hir_id
());
if
!
attrs
.iter
()
.any
(|
a
|
a
.has_name
(
sym
::
non_exhaustive
));
then
{
then
{
let
(
lint
,
msg
)
=
if
let
ItemKind
::
Struct
(
ref
v
,
..
)
=
item
.kind
{
let
(
lint
,
msg
)
=
if
let
ItemKind
::
Struct
(
ref
v
,
..
)
=
item
.kind
{
if
v
.fields
()
.iter
()
.any
(|
f
|
!
f
.vis.node
.is_pub
())
{
if
v
.fields
()
.iter
()
.any
(|
f
|
!
f
.vis.node
.is_pub
())
{
...
...
src/tools/clippy/clippy_lints/src/functions.rs
浏览文件 @
c701872a
...
@@ -280,7 +280,8 @@ fn check_fn(
...
@@ -280,7 +280,8 @@ fn check_fn(
}
}
fn
check_item
(
&
mut
self
,
cx
:
&
LateContext
<
'tcx
>
,
item
:
&
'tcx
hir
::
Item
<
'_
>
)
{
fn
check_item
(
&
mut
self
,
cx
:
&
LateContext
<
'tcx
>
,
item
:
&
'tcx
hir
::
Item
<
'_
>
)
{
let
attr
=
must_use_attr
(
&
item
.attrs
);
let
attrs
=
cx
.tcx
.hir
()
.attrs
(
item
.hir_id
());
let
attr
=
must_use_attr
(
attrs
);
if
let
hir
::
ItemKind
::
Fn
(
ref
sig
,
ref
_
generics
,
ref
body_id
)
=
item
.kind
{
if
let
hir
::
ItemKind
::
Fn
(
ref
sig
,
ref
_
generics
,
ref
body_id
)
=
item
.kind
{
let
is_public
=
cx
.access_levels
.is_exported
(
item
.hir_id
());
let
is_public
=
cx
.access_levels
.is_exported
(
item
.hir_id
());
let
fn_header_span
=
item
.span
.with_hi
(
sig
.decl.output
.span
()
.hi
());
let
fn_header_span
=
item
.span
.with_hi
(
sig
.decl.output
.span
()
.hi
());
...
@@ -291,7 +292,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
...
@@ -291,7 +292,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
check_needless_must_use
(
cx
,
&
sig
.decl
,
item
.hir_id
(),
item
.span
,
fn_header_span
,
attr
);
check_needless_must_use
(
cx
,
&
sig
.decl
,
item
.hir_id
(),
item
.span
,
fn_header_span
,
attr
);
return
;
return
;
}
}
if
is_public
&&
!
is_proc_macro
(
cx
.sess
(),
&
item
.attrs
)
&&
attr_by_name
(
&
item
.
attrs
,
"no_mangle"
)
.is_none
()
{
if
is_public
&&
!
is_proc_macro
(
cx
.sess
(),
attrs
)
&&
attr_by_name
(
attrs
,
"no_mangle"
)
.is_none
()
{
check_must_use_candidate
(
check_must_use_candidate
(
cx
,
cx
,
&
sig
.decl
,
&
sig
.decl
,
...
...
src/tools/clippy/clippy_lints/src/macro_use.rs
浏览文件 @
c701872a
...
@@ -107,8 +107,8 @@ fn check_item(&mut self, cx: &LateContext<'_>, item: &hir::Item<'_>) {
...
@@ -107,8 +107,8 @@ fn check_item(&mut self, cx: &LateContext<'_>, item: &hir::Item<'_>) {
if_chain!
{
if_chain!
{
if
cx
.sess
()
.opts.edition
>=
Edition
::
Edition2018
;
if
cx
.sess
()
.opts.edition
>=
Edition
::
Edition2018
;
if
let
hir
::
ItemKind
::
Use
(
path
,
_
kind
)
=
&
item
.kind
;
if
let
hir
::
ItemKind
::
Use
(
path
,
_
kind
)
=
&
item
.kind
;
if
let
Some
(
mac_attr
)
=
item
let
attrs
=
cx
.tcx
.hir
()
.attrs
(
item
.hir_id
());
.
attrs
if
let
Some
(
mac_attr
)
=
attrs
.iter
()
.iter
()
.find
(|
attr
|
attr
.ident
()
.map
(|
s
|
s
.to_string
())
==
Some
(
"macro_use"
.to_string
()));
.find
(|
attr
|
attr
.ident
()
.map
(|
s
|
s
.to_string
())
==
Some
(
"macro_use"
.to_string
()));
if
let
Res
::
Def
(
DefKind
::
Mod
,
id
)
=
path
.res
;
if
let
Res
::
Def
(
DefKind
::
Mod
,
id
)
=
path
.res
;
...
...
src/tools/clippy/clippy_lints/src/missing_doc.rs
浏览文件 @
c701872a
...
@@ -161,7 +161,8 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, it: &'tcx hir::Item<'_>) {
...
@@ -161,7 +161,8 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, it: &'tcx hir::Item<'_>) {
let
(
article
,
desc
)
=
cx
.tcx
.article_and_description
(
it
.def_id
.to_def_id
());
let
(
article
,
desc
)
=
cx
.tcx
.article_and_description
(
it
.def_id
.to_def_id
());
self
.check_missing_docs_attrs
(
cx
,
&
it
.attrs
,
it
.span
,
article
,
desc
);
let
attrs
=
cx
.tcx
.hir
()
.attrs
(
it
.hir_id
());
self
.check_missing_docs_attrs
(
cx
,
attrs
,
it
.span
,
article
,
desc
);
}
}
fn
check_trait_item
(
&
mut
self
,
cx
:
&
LateContext
<
'tcx
>
,
trait_item
:
&
'tcx
hir
::
TraitItem
<
'_
>
)
{
fn
check_trait_item
(
&
mut
self
,
cx
:
&
LateContext
<
'tcx
>
,
trait_item
:
&
'tcx
hir
::
TraitItem
<
'_
>
)
{
...
...
src/tools/clippy/clippy_lints/src/missing_inline.rs
浏览文件 @
c701872a
...
@@ -93,7 +93,8 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, it: &'tcx hir::Item<'_>) {
...
@@ -93,7 +93,8 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, it: &'tcx hir::Item<'_>) {
match
it
.kind
{
match
it
.kind
{
hir
::
ItemKind
::
Fn
(
..
)
=>
{
hir
::
ItemKind
::
Fn
(
..
)
=>
{
let
desc
=
"a function"
;
let
desc
=
"a function"
;
check_missing_inline_attrs
(
cx
,
&
it
.attrs
,
it
.span
,
desc
);
let
attrs
=
cx
.tcx
.hir
()
.attrs
(
it
.hir_id
());
check_missing_inline_attrs
(
cx
,
attrs
,
it
.span
,
desc
);
},
},
hir
::
ItemKind
::
Trait
(
ref
_
is_auto
,
ref
_u
nsafe
,
ref
_
generics
,
ref
_
bounds
,
trait_items
)
=>
{
hir
::
ItemKind
::
Trait
(
ref
_
is_auto
,
ref
_u
nsafe
,
ref
_
generics
,
ref
_
bounds
,
trait_items
)
=>
{
// note: we need to check if the trait is exported so we can't use
// note: we need to check if the trait is exported so we can't use
...
...
src/tools/clippy/clippy_lints/src/needless_borrow.rs
浏览文件 @
c701872a
...
@@ -115,8 +115,9 @@ fn check_pat(&mut self, cx: &LateContext<'tcx>, pat: &'tcx Pat<'_>) {
...
@@ -115,8 +115,9 @@ fn check_pat(&mut self, cx: &LateContext<'tcx>, pat: &'tcx Pat<'_>) {
}
}
}
}
fn
check_item
(
&
mut
self
,
_
:
&
LateContext
<
'tcx
>
,
item
:
&
'tcx
Item
<
'_
>
)
{
fn
check_item
(
&
mut
self
,
cx
:
&
LateContext
<
'tcx
>
,
item
:
&
'tcx
Item
<
'_
>
)
{
if
is_automatically_derived
(
item
.attrs
)
{
let
attrs
=
cx
.tcx
.hir
()
.attrs
(
item
.hir_id
());
if
is_automatically_derived
(
attrs
)
{
debug_assert!
(
self
.derived_item
.is_none
());
debug_assert!
(
self
.derived_item
.is_none
());
self
.derived_item
=
Some
(
item
.def_id
);
self
.derived_item
=
Some
(
item
.def_id
);
}
}
...
...
src/tools/clippy/clippy_lints/src/partialeq_ne_impl.rs
浏览文件 @
c701872a
...
@@ -35,7 +35,8 @@ impl<'tcx> LateLintPass<'tcx> for PartialEqNeImpl {
...
@@ -35,7 +35,8 @@ impl<'tcx> LateLintPass<'tcx> for PartialEqNeImpl {
fn
check_item
(
&
mut
self
,
cx
:
&
LateContext
<
'tcx
>
,
item
:
&
'tcx
Item
<
'_
>
)
{
fn
check_item
(
&
mut
self
,
cx
:
&
LateContext
<
'tcx
>
,
item
:
&
'tcx
Item
<
'_
>
)
{
if_chain!
{
if_chain!
{
if
let
ItemKind
::
Impl
(
Impl
{
of_trait
:
Some
(
ref
trait_ref
),
items
:
impl_items
,
..
})
=
item
.kind
;
if
let
ItemKind
::
Impl
(
Impl
{
of_trait
:
Some
(
ref
trait_ref
),
items
:
impl_items
,
..
})
=
item
.kind
;
if
!
is_automatically_derived
(
&*
item
.attrs
);
let
attrs
=
cx
.tcx
.hir
()
.attrs
(
item
.hir_id
());
if
!
is_automatically_derived
(
attrs
);
if
let
Some
(
eq_trait
)
=
cx
.tcx
.lang_items
()
.eq_trait
();
if
let
Some
(
eq_trait
)
=
cx
.tcx
.lang_items
()
.eq_trait
();
if
trait_ref
.path.res
.def_id
()
==
eq_trait
;
if
trait_ref
.path.res
.def_id
()
==
eq_trait
;
then
{
then
{
...
...
src/tools/clippy/clippy_lints/src/utils/inspector.rs
浏览文件 @
c701872a
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
impl
<
'tcx
>
LateLintPass
<
'tcx
>
for
DeepCodeInspector
{
impl
<
'tcx
>
LateLintPass
<
'tcx
>
for
DeepCodeInspector
{
fn
check_item
(
&
mut
self
,
cx
:
&
LateContext
<
'tcx
>
,
item
:
&
'tcx
hir
::
Item
<
'_
>
)
{
fn
check_item
(
&
mut
self
,
cx
:
&
LateContext
<
'tcx
>
,
item
:
&
'tcx
hir
::
Item
<
'_
>
)
{
if
!
has_attr
(
cx
.sess
(),
&
item
.attrs
)
{
if
!
has_attr
(
cx
.sess
(),
cx
.tcx
.hir
()
.attrs
(
item
.hir_id
())
)
{
return
;
return
;
}
}
print_item
(
cx
,
item
);
print_item
(
cx
,
item
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录