Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
419a9186
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,发现更多精彩内容 >>
提交
419a9186
编写于
11月 11, 2020
作者:
C
Camille GILLOT
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Store ForeignItem in a side table.
上级
65ecc481
变更
46
隐藏空白更改
内联
并排
Showing
46 changed file
with
270 addition
and
55 deletion
+270
-55
compiler/rustc_ast_lowering/src/item.rs
compiler/rustc_ast_lowering/src/item.rs
+24
-1
compiler/rustc_ast_lowering/src/lib.rs
compiler/rustc_ast_lowering/src/lib.rs
+3
-0
compiler/rustc_hir/src/arena.rs
compiler/rustc_hir/src/arena.rs
+1
-0
compiler/rustc_hir/src/hir.rs
compiler/rustc_hir/src/hir.rs
+39
-1
compiler/rustc_hir/src/intravisit.rs
compiler/rustc_hir/src/intravisit.rs
+35
-1
compiler/rustc_hir/src/itemlikevisit.rs
compiler/rustc_hir/src/itemlikevisit.rs
+3
-1
compiler/rustc_hir/src/stable_hash_impls.rs
compiler/rustc_hir/src/stable_hash_impls.rs
+17
-2
compiler/rustc_hir_pretty/src/lib.rs
compiler/rustc_hir_pretty/src/lib.rs
+4
-1
compiler/rustc_incremental/src/persist/dirty_clean.rs
compiler/rustc_incremental/src/persist/dirty_clean.rs
+4
-0
compiler/rustc_interface/src/proc_macro_decls.rs
compiler/rustc_interface/src/proc_macro_decls.rs
+2
-0
compiler/rustc_metadata/src/foreign_modules.rs
compiler/rustc_metadata/src/foreign_modules.rs
+6
-2
compiler/rustc_metadata/src/link_args.rs
compiler/rustc_metadata/src/link_args.rs
+1
-0
compiler/rustc_metadata/src/native_libs.rs
compiler/rustc_metadata/src/native_libs.rs
+1
-0
compiler/rustc_metadata/src/rmeta/encoder.rs
compiler/rustc_metadata/src/rmeta/encoder.rs
+8
-1
compiler/rustc_middle/src/hir/map/collector.rs
compiler/rustc_middle/src/hir/map/collector.rs
+15
-4
compiler/rustc_middle/src/hir/map/mod.rs
compiler/rustc_middle/src/hir/map/mod.rs
+15
-0
compiler/rustc_mir/src/monomorphize/collector.rs
compiler/rustc_mir/src/monomorphize/collector.rs
+2
-0
compiler/rustc_passes/src/dead.rs
compiler/rustc_passes/src/dead.rs
+2
-0
compiler/rustc_passes/src/diagnostic_items.rs
compiler/rustc_passes/src/diagnostic_items.rs
+2
-0
compiler/rustc_passes/src/entry.rs
compiler/rustc_passes/src/entry.rs
+3
-1
compiler/rustc_passes/src/hir_id_validator.rs
compiler/rustc_passes/src/hir_id_validator.rs
+5
-0
compiler/rustc_passes/src/lang_items.rs
compiler/rustc_passes/src/lang_items.rs
+2
-0
compiler/rustc_passes/src/layout_test.rs
compiler/rustc_passes/src/layout_test.rs
+1
-0
compiler/rustc_passes/src/reachable.rs
compiler/rustc_passes/src/reachable.rs
+2
-0
compiler/rustc_plugin_impl/src/build.rs
compiler/rustc_plugin_impl/src/build.rs
+2
-0
compiler/rustc_privacy/src/lib.rs
compiler/rustc_privacy/src/lib.rs
+5
-5
compiler/rustc_symbol_mangling/src/test.rs
compiler/rustc_symbol_mangling/src/test.rs
+4
-0
compiler/rustc_typeck/src/check/check.rs
compiler/rustc_typeck/src/check/check.rs
+4
-1
compiler/rustc_typeck/src/check/method/suggest.rs
compiler/rustc_typeck/src/check/method/suggest.rs
+2
-0
compiler/rustc_typeck/src/check/mod.rs
compiler/rustc_typeck/src/check/mod.rs
+1
-0
compiler/rustc_typeck/src/check/wfcheck.rs
compiler/rustc_typeck/src/check/wfcheck.rs
+5
-0
compiler/rustc_typeck/src/check_unused.rs
compiler/rustc_typeck/src/check_unused.rs
+4
-0
compiler/rustc_typeck/src/coherence/inherent_impls.rs
compiler/rustc_typeck/src/coherence/inherent_impls.rs
+2
-0
compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs
...iler/rustc_typeck/src/coherence/inherent_impls_overlap.rs
+2
-0
compiler/rustc_typeck/src/coherence/orphan.rs
compiler/rustc_typeck/src/coherence/orphan.rs
+2
-0
compiler/rustc_typeck/src/coherence/unsafety.rs
compiler/rustc_typeck/src/coherence/unsafety.rs
+2
-0
compiler/rustc_typeck/src/collect.rs
compiler/rustc_typeck/src/collect.rs
+1
-0
compiler/rustc_typeck/src/impl_wf_check.rs
compiler/rustc_typeck/src/impl_wf_check.rs
+2
-0
compiler/rustc_typeck/src/outlives/implicit_infer.rs
compiler/rustc_typeck/src/outlives/implicit_infer.rs
+2
-0
compiler/rustc_typeck/src/outlives/test.rs
compiler/rustc_typeck/src/outlives/test.rs
+1
-0
compiler/rustc_typeck/src/variance/constraints.rs
compiler/rustc_typeck/src/variance/constraints.rs
+6
-8
compiler/rustc_typeck/src/variance/terms.rs
compiler/rustc_typeck/src/variance/terms.rs
+6
-8
compiler/rustc_typeck/src/variance/test.rs
compiler/rustc_typeck/src/variance/test.rs
+1
-0
src/librustdoc/visit_ast.rs
src/librustdoc/visit_ast.rs
+1
-0
src/test/ui/lint/inline-trait-and-foreign-items.stderr
src/test/ui/lint/inline-trait-and-foreign-items.stderr
+16
-16
src/test/ui/lint/warn-unused-inline-on-fn-prototypes.stderr
src/test/ui/lint/warn-unused-inline-on-fn-prototypes.stderr
+2
-2
未找到文件。
compiler/rustc_ast_lowering/src/item.rs
浏览文件 @
419a9186
...
@@ -43,6 +43,7 @@ fn visit_mod(&mut self, m: &'a Mod, _s: Span, _attrs: &[Attribute], n: NodeId) {
...
@@ -43,6 +43,7 @@ fn visit_mod(&mut self, m: &'a Mod, _s: Span, _attrs: &[Attribute], n: NodeId) {
items
:
BTreeSet
::
new
(),
items
:
BTreeSet
::
new
(),
trait_items
:
BTreeSet
::
new
(),
trait_items
:
BTreeSet
::
new
(),
impl_items
:
BTreeSet
::
new
(),
impl_items
:
BTreeSet
::
new
(),
foreign_items
:
BTreeSet
::
new
(),
},
},
);
);
...
@@ -105,6 +106,17 @@ fn visit_assoc_item(&mut self, item: &'a AssocItem, ctxt: AssocCtxt) {
...
@@ -105,6 +106,17 @@ fn visit_assoc_item(&mut self, item: &'a AssocItem, ctxt: AssocCtxt) {
visit
::
walk_assoc_item
(
self
,
item
,
ctxt
);
visit
::
walk_assoc_item
(
self
,
item
,
ctxt
);
}
}
fn
visit_foreign_item
(
&
mut
self
,
item
:
&
'a
ForeignItem
)
{
self
.lctx
.with_hir_id_owner
(
item
.id
,
|
lctx
|
{
let
hir_item
=
lctx
.lower_foreign_item
(
item
);
let
id
=
hir
::
ForeignItemId
{
hir_id
:
hir_item
.hir_id
};
lctx
.foreign_items
.insert
(
id
,
hir_item
);
lctx
.modules
.get_mut
(
&
lctx
.current_module
)
.unwrap
()
.foreign_items
.insert
(
id
);
});
visit
::
walk_foreign_item
(
self
,
item
);
}
}
}
impl
<
'hir
>
LoweringContext
<
'_
,
'hir
>
{
impl
<
'hir
>
LoweringContext
<
'_
,
'hir
>
{
...
@@ -704,10 +716,21 @@ fn lower_foreign_item(&mut self, i: &ForeignItem) -> hir::ForeignItem<'hir> {
...
@@ -704,10 +716,21 @@ fn lower_foreign_item(&mut self, i: &ForeignItem) -> hir::ForeignItem<'hir> {
}
}
}
}
fn
lower_foreign_item_ref
(
&
mut
self
,
i
:
&
ForeignItem
)
->
hir
::
ForeignItemRef
<
'hir
>
{
hir
::
ForeignItemRef
{
id
:
hir
::
ForeignItemId
{
hir_id
:
self
.lower_node_id
(
i
.id
)
},
ident
:
i
.ident
,
span
:
i
.span
,
vis
:
self
.lower_visibility
(
&
i
.vis
,
Some
(
i
.id
)),
}
}
fn
lower_foreign_mod
(
&
mut
self
,
fm
:
&
ForeignMod
)
->
hir
::
ForeignMod
<
'hir
>
{
fn
lower_foreign_mod
(
&
mut
self
,
fm
:
&
ForeignMod
)
->
hir
::
ForeignMod
<
'hir
>
{
hir
::
ForeignMod
{
hir
::
ForeignMod
{
abi
:
fm
.abi
.map_or
(
abi
::
Abi
::
C
,
|
abi
|
self
.lower_abi
(
abi
)),
abi
:
fm
.abi
.map_or
(
abi
::
Abi
::
C
,
|
abi
|
self
.lower_abi
(
abi
)),
items
:
self
.arena
.alloc_from_iter
(
fm
.items
.iter
()
.map
(|
x
|
self
.lower_foreign_item
(
x
))),
items
:
self
.arena
.alloc_from_iter
(
fm
.items
.iter
()
.map
(|
x
|
self
.lower_foreign_item_ref
(
x
))),
}
}
}
}
...
...
compiler/rustc_ast_lowering/src/lib.rs
浏览文件 @
419a9186
...
@@ -101,6 +101,7 @@ struct LoweringContext<'a, 'hir: 'a> {
...
@@ -101,6 +101,7 @@ struct LoweringContext<'a, 'hir: 'a> {
trait_items
:
BTreeMap
<
hir
::
TraitItemId
,
hir
::
TraitItem
<
'hir
>>
,
trait_items
:
BTreeMap
<
hir
::
TraitItemId
,
hir
::
TraitItem
<
'hir
>>
,
impl_items
:
BTreeMap
<
hir
::
ImplItemId
,
hir
::
ImplItem
<
'hir
>>
,
impl_items
:
BTreeMap
<
hir
::
ImplItemId
,
hir
::
ImplItem
<
'hir
>>
,
foreign_items
:
BTreeMap
<
hir
::
ForeignItemId
,
hir
::
ForeignItem
<
'hir
>>
,
bodies
:
BTreeMap
<
hir
::
BodyId
,
hir
::
Body
<
'hir
>>
,
bodies
:
BTreeMap
<
hir
::
BodyId
,
hir
::
Body
<
'hir
>>
,
exported_macros
:
Vec
<
hir
::
MacroDef
<
'hir
>>
,
exported_macros
:
Vec
<
hir
::
MacroDef
<
'hir
>>
,
non_exported_macro_attrs
:
Vec
<
ast
::
Attribute
>
,
non_exported_macro_attrs
:
Vec
<
ast
::
Attribute
>
,
...
@@ -298,6 +299,7 @@ pub fn lower_crate<'a, 'hir>(
...
@@ -298,6 +299,7 @@ pub fn lower_crate<'a, 'hir>(
items
:
BTreeMap
::
new
(),
items
:
BTreeMap
::
new
(),
trait_items
:
BTreeMap
::
new
(),
trait_items
:
BTreeMap
::
new
(),
impl_items
:
BTreeMap
::
new
(),
impl_items
:
BTreeMap
::
new
(),
foreign_items
:
BTreeMap
::
new
(),
bodies
:
BTreeMap
::
new
(),
bodies
:
BTreeMap
::
new
(),
trait_impls
:
BTreeMap
::
new
(),
trait_impls
:
BTreeMap
::
new
(),
modules
:
BTreeMap
::
new
(),
modules
:
BTreeMap
::
new
(),
...
@@ -548,6 +550,7 @@ fn visit_ty(&mut self, t: &'tcx Ty) {
...
@@ -548,6 +550,7 @@ fn visit_ty(&mut self, t: &'tcx Ty) {
items
:
self
.items
,
items
:
self
.items
,
trait_items
:
self
.trait_items
,
trait_items
:
self
.trait_items
,
impl_items
:
self
.impl_items
,
impl_items
:
self
.impl_items
,
foreign_items
:
self
.foreign_items
,
bodies
:
self
.bodies
,
bodies
:
self
.bodies
,
body_ids
,
body_ids
,
trait_impls
:
self
.trait_impls
,
trait_impls
:
self
.trait_impls
,
...
...
compiler/rustc_hir/src/arena.rs
浏览文件 @
419a9186
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
[]
field_pat
:
rustc_hir
::
FieldPat
<
$tcx
>
,
[]
field_pat
:
rustc_hir
::
FieldPat
<
$tcx
>
,
[]
fn_decl
:
rustc_hir
::
FnDecl
<
$tcx
>
,
[]
fn_decl
:
rustc_hir
::
FnDecl
<
$tcx
>
,
[]
foreign_item
:
rustc_hir
::
ForeignItem
<
$tcx
>
,
[]
foreign_item
:
rustc_hir
::
ForeignItem
<
$tcx
>
,
[]
foreign_item_ref
:
rustc_hir
::
ForeignItemRef
<
$tcx
>
,
[]
impl_item_ref
:
rustc_hir
::
ImplItemRef
<
$tcx
>
,
[]
impl_item_ref
:
rustc_hir
::
ImplItemRef
<
$tcx
>
,
[
few
]
inline_asm
:
rustc_hir
::
InlineAsm
<
$tcx
>
,
[
few
]
inline_asm
:
rustc_hir
::
InlineAsm
<
$tcx
>
,
[
few
]
llvm_inline_asm
:
rustc_hir
::
LlvmInlineAsm
<
$tcx
>
,
[
few
]
llvm_inline_asm
:
rustc_hir
::
LlvmInlineAsm
<
$tcx
>
,
...
...
compiler/rustc_hir/src/hir.rs
浏览文件 @
419a9186
...
@@ -579,6 +579,7 @@ pub struct ModuleItems {
...
@@ -579,6 +579,7 @@ pub struct ModuleItems {
pub
items
:
BTreeSet
<
HirId
>
,
pub
items
:
BTreeSet
<
HirId
>
,
pub
trait_items
:
BTreeSet
<
TraitItemId
>
,
pub
trait_items
:
BTreeSet
<
TraitItemId
>
,
pub
impl_items
:
BTreeSet
<
ImplItemId
>
,
pub
impl_items
:
BTreeSet
<
ImplItemId
>
,
pub
foreign_items
:
BTreeSet
<
ForeignItemId
>
,
}
}
/// A type representing only the top-level module.
/// A type representing only the top-level module.
...
@@ -612,6 +613,7 @@ pub struct Crate<'hir> {
...
@@ -612,6 +613,7 @@ pub struct Crate<'hir> {
pub
trait_items
:
BTreeMap
<
TraitItemId
,
TraitItem
<
'hir
>>
,
pub
trait_items
:
BTreeMap
<
TraitItemId
,
TraitItem
<
'hir
>>
,
pub
impl_items
:
BTreeMap
<
ImplItemId
,
ImplItem
<
'hir
>>
,
pub
impl_items
:
BTreeMap
<
ImplItemId
,
ImplItem
<
'hir
>>
,
pub
foreign_items
:
BTreeMap
<
ForeignItemId
,
ForeignItem
<
'hir
>>
,
pub
bodies
:
BTreeMap
<
BodyId
,
Body
<
'hir
>>
,
pub
bodies
:
BTreeMap
<
BodyId
,
Body
<
'hir
>>
,
pub
trait_impls
:
BTreeMap
<
DefId
,
Vec
<
HirId
>>
,
pub
trait_impls
:
BTreeMap
<
DefId
,
Vec
<
HirId
>>
,
...
@@ -644,6 +646,10 @@ pub fn impl_item(&self, id: ImplItemId) -> &ImplItem<'hir> {
...
@@ -644,6 +646,10 @@ pub fn impl_item(&self, id: ImplItemId) -> &ImplItem<'hir> {
&
self
.impl_items
[
&
id
]
&
self
.impl_items
[
&
id
]
}
}
pub
fn
foreign_item
(
&
self
,
id
:
ForeignItemId
)
->
&
ForeignItem
<
'hir
>
{
&
self
.foreign_items
[
&
id
]
}
pub
fn
body
(
&
self
,
id
:
BodyId
)
->
&
Body
<
'hir
>
{
pub
fn
body
(
&
self
,
id
:
BodyId
)
->
&
Body
<
'hir
>
{
&
self
.bodies
[
&
id
]
&
self
.bodies
[
&
id
]
}
}
...
@@ -673,6 +679,10 @@ pub fn visit_all_item_likes<'hir, V>(&'hir self, visitor: &mut V)
...
@@ -673,6 +679,10 @@ pub fn visit_all_item_likes<'hir, V>(&'hir self, visitor: &mut V)
for
impl_item
in
self
.impl_items
.values
()
{
for
impl_item
in
self
.impl_items
.values
()
{
visitor
.visit_impl_item
(
impl_item
);
visitor
.visit_impl_item
(
impl_item
);
}
}
for
foreign_item
in
self
.foreign_items
.values
()
{
visitor
.visit_foreign_item
(
foreign_item
);
}
}
}
/// A parallel version of `visit_all_item_likes`.
/// A parallel version of `visit_all_item_likes`.
...
@@ -695,6 +705,11 @@ pub fn par_visit_all_item_likes<'hir, V>(&'hir self, visitor: &V)
...
@@ -695,6 +705,11 @@ pub fn par_visit_all_item_likes<'hir, V>(&'hir self, visitor: &V)
par_for_each_in
(
&
self
.impl_items
,
|(
_
,
impl_item
)|
{
par_for_each_in
(
&
self
.impl_items
,
|(
_
,
impl_item
)|
{
visitor
.visit_impl_item
(
impl_item
);
visitor
.visit_impl_item
(
impl_item
);
});
});
},
{
par_for_each_in
(
&
self
.foreign_items
,
|(
_
,
foreign_item
)|
{
visitor
.visit_foreign_item
(
foreign_item
);
});
}
}
);
);
}
}
...
@@ -2272,7 +2287,7 @@ pub struct Mod<'hir> {
...
@@ -2272,7 +2287,7 @@ pub struct Mod<'hir> {
#[derive(Debug,
HashStable_Generic)]
#[derive(Debug,
HashStable_Generic)]
pub
struct
ForeignMod
<
'hir
>
{
pub
struct
ForeignMod
<
'hir
>
{
pub
abi
:
Abi
,
pub
abi
:
Abi
,
pub
items
:
&
'hir
[
ForeignItem
<
'hir
>
],
pub
items
:
&
'hir
[
ForeignItem
Ref
<
'hir
>
],
}
}
#[derive(Encodable,
Debug,
HashStable_Generic)]
#[derive(Encodable,
Debug,
HashStable_Generic)]
...
@@ -2614,6 +2629,29 @@ pub enum AssocItemKind {
...
@@ -2614,6 +2629,29 @@ pub enum AssocItemKind {
Type
,
Type
,
}
}
// The bodies for items are stored "out of line", in a separate
// hashmap in the `Crate`. Here we just record the node-id of the item
// so it can fetched later.
#[derive(Copy,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Encodable,
Debug)]
pub
struct
ForeignItemId
{
pub
hir_id
:
HirId
,
}
/// A reference from a foreign block to one of its items. This
/// contains the item's ID, naturally, but also the item's name and
/// some other high-level details (like whether it is an associated
/// type or method, and whether it is public). This allows other
/// passes to find the impl they want without loading the ID (which
/// means fewer edges in the incremental compilation graph).
#[derive(Debug,
HashStable_Generic)]
pub
struct
ForeignItemRef
<
'hir
>
{
pub
id
:
ForeignItemId
,
#[stable_hasher(project(name))]
pub
ident
:
Ident
,
pub
span
:
Span
,
pub
vis
:
Visibility
<
'hir
>
,
}
#[derive(Debug,
HashStable_Generic)]
#[derive(Debug,
HashStable_Generic)]
pub
struct
ForeignItem
<
'hir
>
{
pub
struct
ForeignItem
<
'hir
>
{
#[stable_hasher(project(name))]
#[stable_hasher(project(name))]
...
...
compiler/rustc_hir/src/intravisit.rs
浏览文件 @
419a9186
...
@@ -64,6 +64,10 @@ fn visit_trait_item(&mut self, trait_item: &'hir TraitItem<'hir>) {
...
@@ -64,6 +64,10 @@ fn visit_trait_item(&mut self, trait_item: &'hir TraitItem<'hir>) {
fn
visit_impl_item
(
&
mut
self
,
impl_item
:
&
'hir
ImplItem
<
'hir
>
)
{
fn
visit_impl_item
(
&
mut
self
,
impl_item
:
&
'hir
ImplItem
<
'hir
>
)
{
self
.visitor
.visit_impl_item
(
impl_item
);
self
.visitor
.visit_impl_item
(
impl_item
);
}
}
fn
visit_foreign_item
(
&
mut
self
,
foreign_item
:
&
'hir
ForeignItem
<
'hir
>
)
{
self
.visitor
.visit_foreign_item
(
foreign_item
);
}
}
}
pub
trait
IntoVisitor
<
'hir
>
{
pub
trait
IntoVisitor
<
'hir
>
{
...
@@ -88,6 +92,10 @@ fn visit_trait_item(&self, trait_item: &'hir TraitItem<'hir>) {
...
@@ -88,6 +92,10 @@ fn visit_trait_item(&self, trait_item: &'hir TraitItem<'hir>) {
fn
visit_impl_item
(
&
self
,
impl_item
:
&
'hir
ImplItem
<
'hir
>
)
{
fn
visit_impl_item
(
&
self
,
impl_item
:
&
'hir
ImplItem
<
'hir
>
)
{
self
.0
.into_visitor
()
.visit_impl_item
(
impl_item
);
self
.0
.into_visitor
()
.visit_impl_item
(
impl_item
);
}
}
fn
visit_foreign_item
(
&
self
,
foreign_item
:
&
'hir
ForeignItem
<
'hir
>
)
{
self
.0
.into_visitor
()
.visit_foreign_item
(
foreign_item
);
}
}
}
#[derive(Copy,
Clone)]
#[derive(Copy,
Clone)]
...
@@ -128,6 +136,7 @@ pub trait Map<'hir> {
...
@@ -128,6 +136,7 @@ pub trait Map<'hir> {
fn
item
(
&
self
,
id
:
HirId
)
->
&
'hir
Item
<
'hir
>
;
fn
item
(
&
self
,
id
:
HirId
)
->
&
'hir
Item
<
'hir
>
;
fn
trait_item
(
&
self
,
id
:
TraitItemId
)
->
&
'hir
TraitItem
<
'hir
>
;
fn
trait_item
(
&
self
,
id
:
TraitItemId
)
->
&
'hir
TraitItem
<
'hir
>
;
fn
impl_item
(
&
self
,
id
:
ImplItemId
)
->
&
'hir
ImplItem
<
'hir
>
;
fn
impl_item
(
&
self
,
id
:
ImplItemId
)
->
&
'hir
ImplItem
<
'hir
>
;
fn
foreign_item
(
&
self
,
id
:
ForeignItemId
)
->
&
'hir
ForeignItem
<
'hir
>
;
}
}
/// An erased version of `Map<'hir>`, using dynamic dispatch.
/// An erased version of `Map<'hir>`, using dynamic dispatch.
...
@@ -150,6 +159,9 @@ fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir> {
...
@@ -150,6 +159,9 @@ fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir> {
fn
impl_item
(
&
self
,
id
:
ImplItemId
)
->
&
'hir
ImplItem
<
'hir
>
{
fn
impl_item
(
&
self
,
id
:
ImplItemId
)
->
&
'hir
ImplItem
<
'hir
>
{
self
.0
.impl_item
(
id
)
self
.0
.impl_item
(
id
)
}
}
fn
foreign_item
(
&
self
,
id
:
ForeignItemId
)
->
&
'hir
ForeignItem
<
'hir
>
{
self
.0
.foreign_item
(
id
)
}
}
}
/// Specifies what nested things a visitor wants to visit. The most
/// Specifies what nested things a visitor wants to visit. The most
...
@@ -277,6 +289,14 @@ fn visit_nested_impl_item(&mut self, id: ImplItemId) {
...
@@ -277,6 +289,14 @@ fn visit_nested_impl_item(&mut self, id: ImplItemId) {
walk_list!
(
self
,
visit_impl_item
,
opt_item
);
walk_list!
(
self
,
visit_impl_item
,
opt_item
);
}
}
/// Like `visit_nested_item()`, but for impl items. See
/// `visit_nested_item()` for advice on when to override this
/// method.
fn
visit_nested_foreign_item
(
&
mut
self
,
id
:
ForeignItemId
)
{
let
opt_item
=
self
.nested_visit_map
()
.inter
()
.map
(|
map
|
map
.foreign_item
(
id
));
walk_list!
(
self
,
visit_foreign_item
,
opt_item
);
}
/// Invoked to visit the body of a function, method or closure. Like
/// Invoked to visit the body of a function, method or closure. Like
/// visit_nested_item, does nothing by default unless you override
/// visit_nested_item, does nothing by default unless you override
/// `nested_visit_map` to return other than `None`, in which case it will walk
/// `nested_visit_map` to return other than `None`, in which case it will walk
...
@@ -378,6 +398,9 @@ fn visit_trait_item_ref(&mut self, ii: &'v TraitItemRef) {
...
@@ -378,6 +398,9 @@ fn visit_trait_item_ref(&mut self, ii: &'v TraitItemRef) {
fn
visit_impl_item
(
&
mut
self
,
ii
:
&
'v
ImplItem
<
'v
>
)
{
fn
visit_impl_item
(
&
mut
self
,
ii
:
&
'v
ImplItem
<
'v
>
)
{
walk_impl_item
(
self
,
ii
)
walk_impl_item
(
self
,
ii
)
}
}
fn
visit_foreign_item_ref
(
&
mut
self
,
ii
:
&
'v
ForeignItemRef
<
'v
>
)
{
walk_foreign_item_ref
(
self
,
ii
)
}
fn
visit_impl_item_ref
(
&
mut
self
,
ii
:
&
'v
ImplItemRef
<
'v
>
)
{
fn
visit_impl_item_ref
(
&
mut
self
,
ii
:
&
'v
ImplItemRef
<
'v
>
)
{
walk_impl_item_ref
(
self
,
ii
)
walk_impl_item_ref
(
self
,
ii
)
}
}
...
@@ -568,7 +591,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) {
...
@@ -568,7 +591,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) {
}
}
ItemKind
::
ForeignMod
(
ref
foreign_module
)
=>
{
ItemKind
::
ForeignMod
(
ref
foreign_module
)
=>
{
visitor
.visit_id
(
item
.hir_id
);
visitor
.visit_id
(
item
.hir_id
);
walk_list!
(
visitor
,
visit_foreign_item
,
foreign_module
.items
);
walk_list!
(
visitor
,
visit_foreign_item
_ref
,
foreign_module
.items
);
}
}
ItemKind
::
GlobalAsm
(
_
)
=>
{
ItemKind
::
GlobalAsm
(
_
)
=>
{
visitor
.visit_id
(
item
.hir_id
);
visitor
.visit_id
(
item
.hir_id
);
...
@@ -1012,6 +1035,17 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
...
@@ -1012,6 +1035,17 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplIt
}
}
}
}
pub
fn
walk_foreign_item_ref
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
foreign_item_ref
:
&
'v
ForeignItemRef
<
'v
>
,
)
{
// N.B., deliberately force a compilation error if/when new fields are added.
let
ForeignItemRef
{
id
,
ident
,
span
:
_
,
ref
vis
}
=
*
foreign_item_ref
;
visitor
.visit_nested_foreign_item
(
id
);
visitor
.visit_ident
(
ident
);
visitor
.visit_vis
(
vis
);
}
pub
fn
walk_impl_item_ref
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
impl_item_ref
:
&
'v
ImplItemRef
<
'v
>
)
{
pub
fn
walk_impl_item_ref
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
impl_item_ref
:
&
'v
ImplItemRef
<
'v
>
)
{
// N.B., deliberately force a compilation error if/when new fields are added.
// N.B., deliberately force a compilation error if/when new fields are added.
let
ImplItemRef
{
id
,
ident
,
ref
kind
,
span
:
_
,
ref
vis
,
ref
defaultness
}
=
*
impl_item_ref
;
let
ImplItemRef
{
id
,
ident
,
ref
kind
,
span
:
_
,
ref
vis
,
ref
defaultness
}
=
*
impl_item_ref
;
...
...
compiler/rustc_hir/src/itemlikevisit.rs
浏览文件 @
419a9186
use
super
::{
ImplItem
,
Item
,
TraitItem
};
use
super
::{
ForeignItem
,
ImplItem
,
Item
,
TraitItem
};
/// The "item-like visitor" defines only the top-level methods
/// The "item-like visitor" defines only the top-level methods
/// that can be invoked by `Crate::visit_all_item_likes()`. Whether
/// that can be invoked by `Crate::visit_all_item_likes()`. Whether
...
@@ -47,6 +47,7 @@ pub trait ItemLikeVisitor<'hir> {
...
@@ -47,6 +47,7 @@ pub trait ItemLikeVisitor<'hir> {
fn
visit_item
(
&
mut
self
,
item
:
&
'hir
Item
<
'hir
>
);
fn
visit_item
(
&
mut
self
,
item
:
&
'hir
Item
<
'hir
>
);
fn
visit_trait_item
(
&
mut
self
,
trait_item
:
&
'hir
TraitItem
<
'hir
>
);
fn
visit_trait_item
(
&
mut
self
,
trait_item
:
&
'hir
TraitItem
<
'hir
>
);
fn
visit_impl_item
(
&
mut
self
,
impl_item
:
&
'hir
ImplItem
<
'hir
>
);
fn
visit_impl_item
(
&
mut
self
,
impl_item
:
&
'hir
ImplItem
<
'hir
>
);
fn
visit_foreign_item
(
&
mut
self
,
foreign_item
:
&
'hir
ForeignItem
<
'hir
>
);
}
}
/// A parallel variant of `ItemLikeVisitor`.
/// A parallel variant of `ItemLikeVisitor`.
...
@@ -54,4 +55,5 @@ pub trait ParItemLikeVisitor<'hir> {
...
@@ -54,4 +55,5 @@ pub trait ParItemLikeVisitor<'hir> {
fn
visit_item
(
&
self
,
item
:
&
'hir
Item
<
'hir
>
);
fn
visit_item
(
&
self
,
item
:
&
'hir
Item
<
'hir
>
);
fn
visit_trait_item
(
&
self
,
trait_item
:
&
'hir
TraitItem
<
'hir
>
);
fn
visit_trait_item
(
&
self
,
trait_item
:
&
'hir
TraitItem
<
'hir
>
);
fn
visit_impl_item
(
&
self
,
impl_item
:
&
'hir
ImplItem
<
'hir
>
);
fn
visit_impl_item
(
&
self
,
impl_item
:
&
'hir
ImplItem
<
'hir
>
);
fn
visit_foreign_item
(
&
self
,
foreign_item
:
&
'hir
ForeignItem
<
'hir
>
);
}
}
compiler/rustc_hir/src/stable_hash_impls.rs
浏览文件 @
419a9186
use
rustc_data_structures
::
stable_hasher
::{
HashStable
,
StableHasher
,
ToStableHashKey
};
use
rustc_data_structures
::
stable_hasher
::{
HashStable
,
StableHasher
,
ToStableHashKey
};
use
crate
::
hir
::{
use
crate
::
hir
::{
BodyId
,
Expr
,
ImplItem
,
ImplItemId
,
Item
,
ItemId
,
Mod
,
TraitItem
,
TraitItemId
,
Ty
,
BodyId
,
Expr
,
ForeignItemId
,
ImplItem
,
ImplItemId
,
Item
,
ItemId
,
Mod
,
TraitItem
,
TraitItemId
,
VisibilityKind
,
Ty
,
VisibilityKind
,
};
};
use
crate
::
hir_id
::{
HirId
,
ItemLocalId
};
use
crate
::
hir_id
::{
HirId
,
ItemLocalId
};
use
rustc_span
::
def_id
::{
DefPathHash
,
LocalDefId
};
use
rustc_span
::
def_id
::{
DefPathHash
,
LocalDefId
};
...
@@ -52,6 +52,15 @@ fn to_stable_hash_key(&self, hcx: &HirCtx) -> (DefPathHash, ItemLocalId) {
...
@@ -52,6 +52,15 @@ fn to_stable_hash_key(&self, hcx: &HirCtx) -> (DefPathHash, ItemLocalId) {
}
}
}
}
impl
<
HirCtx
:
crate
::
HashStableContext
>
ToStableHashKey
<
HirCtx
>
for
ForeignItemId
{
type
KeyType
=
(
DefPathHash
,
ItemLocalId
);
#[inline]
fn
to_stable_hash_key
(
&
self
,
hcx
:
&
HirCtx
)
->
(
DefPathHash
,
ItemLocalId
)
{
self
.hir_id
.to_stable_hash_key
(
hcx
)
}
}
impl
<
HirCtx
:
crate
::
HashStableContext
>
HashStable
<
HirCtx
>
for
HirId
{
impl
<
HirCtx
:
crate
::
HashStableContext
>
HashStable
<
HirCtx
>
for
HirId
{
fn
hash_stable
(
&
self
,
hcx
:
&
mut
HirCtx
,
hasher
:
&
mut
StableHasher
)
{
fn
hash_stable
(
&
self
,
hcx
:
&
mut
HirCtx
,
hasher
:
&
mut
StableHasher
)
{
hcx
.hash_hir_id
(
*
self
,
hasher
)
hcx
.hash_hir_id
(
*
self
,
hasher
)
...
@@ -77,6 +86,12 @@ fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
...
@@ -77,6 +86,12 @@ fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
}
}
}
}
impl
<
HirCtx
:
crate
::
HashStableContext
>
HashStable
<
HirCtx
>
for
ForeignItemId
{
fn
hash_stable
(
&
self
,
hcx
:
&
mut
HirCtx
,
hasher
:
&
mut
StableHasher
)
{
hcx
.hash_reference_to_item
(
self
.hir_id
,
hasher
)
}
}
impl
<
HirCtx
:
crate
::
HashStableContext
>
HashStable
<
HirCtx
>
for
ImplItemId
{
impl
<
HirCtx
:
crate
::
HashStableContext
>
HashStable
<
HirCtx
>
for
ImplItemId
{
fn
hash_stable
(
&
self
,
hcx
:
&
mut
HirCtx
,
hasher
:
&
mut
StableHasher
)
{
fn
hash_stable
(
&
self
,
hcx
:
&
mut
HirCtx
,
hasher
:
&
mut
StableHasher
)
{
hcx
.hash_reference_to_item
(
self
.hir_id
,
hasher
)
hcx
.hash_reference_to_item
(
self
.hir_id
,
hasher
)
...
...
compiler/rustc_hir_pretty/src/lib.rs
浏览文件 @
419a9186
...
@@ -36,6 +36,7 @@ pub enum Nested {
...
@@ -36,6 +36,7 @@ pub enum Nested {
Item
(
hir
::
ItemId
),
Item
(
hir
::
ItemId
),
TraitItem
(
hir
::
TraitItemId
),
TraitItem
(
hir
::
TraitItemId
),
ImplItem
(
hir
::
ImplItemId
),
ImplItem
(
hir
::
ImplItemId
),
ForeignItem
(
hir
::
ForeignItemId
),
Body
(
hir
::
BodyId
),
Body
(
hir
::
BodyId
),
BodyParamPat
(
hir
::
BodyId
,
usize
),
BodyParamPat
(
hir
::
BodyId
,
usize
),
}
}
...
@@ -56,6 +57,7 @@ fn nested(&self, state: &mut State<'_>, nested: Nested) {
...
@@ -56,6 +57,7 @@ fn nested(&self, state: &mut State<'_>, nested: Nested) {
Nested
::
Item
(
id
)
=>
state
.print_item
(
self
.item
(
id
.id
)),
Nested
::
Item
(
id
)
=>
state
.print_item
(
self
.item
(
id
.id
)),
Nested
::
TraitItem
(
id
)
=>
state
.print_trait_item
(
self
.trait_item
(
id
)),
Nested
::
TraitItem
(
id
)
=>
state
.print_trait_item
(
self
.trait_item
(
id
)),
Nested
::
ImplItem
(
id
)
=>
state
.print_impl_item
(
self
.impl_item
(
id
)),
Nested
::
ImplItem
(
id
)
=>
state
.print_impl_item
(
self
.impl_item
(
id
)),
Nested
::
ForeignItem
(
id
)
=>
state
.print_foreign_item
(
self
.foreign_item
(
id
)),
Nested
::
Body
(
id
)
=>
state
.print_expr
(
&
self
.body
(
id
)
.value
),
Nested
::
Body
(
id
)
=>
state
.print_expr
(
&
self
.body
(
id
)
.value
),
Nested
::
BodyParamPat
(
id
,
i
)
=>
state
.print_pat
(
&
self
.body
(
id
)
.params
[
i
]
.pat
),
Nested
::
BodyParamPat
(
id
,
i
)
=>
state
.print_pat
(
&
self
.body
(
id
)
.params
[
i
]
.pat
),
}
}
...
@@ -70,6 +72,7 @@ fn nested(&self, state: &mut State<'_>, nested: Nested) {
...
@@ -70,6 +72,7 @@ fn nested(&self, state: &mut State<'_>, nested: Nested) {
Nested
::
Item
(
id
)
=>
state
.print_item
(
self
.item
(
id
.id
)),
Nested
::
Item
(
id
)
=>
state
.print_item
(
self
.item
(
id
.id
)),
Nested
::
TraitItem
(
id
)
=>
state
.print_trait_item
(
self
.trait_item
(
id
)),
Nested
::
TraitItem
(
id
)
=>
state
.print_trait_item
(
self
.trait_item
(
id
)),
Nested
::
ImplItem
(
id
)
=>
state
.print_impl_item
(
self
.impl_item
(
id
)),
Nested
::
ImplItem
(
id
)
=>
state
.print_impl_item
(
self
.impl_item
(
id
)),
Nested
::
ForeignItem
(
id
)
=>
state
.print_foreign_item
(
self
.foreign_item
(
id
)),
Nested
::
Body
(
id
)
=>
state
.print_expr
(
&
self
.body
(
id
)
.value
),
Nested
::
Body
(
id
)
=>
state
.print_expr
(
&
self
.body
(
id
)
.value
),
Nested
::
BodyParamPat
(
id
,
i
)
=>
state
.print_pat
(
&
self
.body
(
id
)
.params
[
i
]
.pat
),
Nested
::
BodyParamPat
(
id
,
i
)
=>
state
.print_pat
(
&
self
.body
(
id
)
.params
[
i
]
.pat
),
}
}
...
@@ -352,7 +355,7 @@ pub fn print_mod(&mut self, _mod: &hir::Mod<'_>, attrs: &[ast::Attribute]) {
...
@@ -352,7 +355,7 @@ pub fn print_mod(&mut self, _mod: &hir::Mod<'_>, attrs: &[ast::Attribute]) {
pub
fn
print_foreign_mod
(
&
mut
self
,
nmod
:
&
hir
::
ForeignMod
<
'_
>
,
attrs
:
&
[
ast
::
Attribute
])
{
pub
fn
print_foreign_mod
(
&
mut
self
,
nmod
:
&
hir
::
ForeignMod
<
'_
>
,
attrs
:
&
[
ast
::
Attribute
])
{
self
.print_inner_attributes
(
attrs
);
self
.print_inner_attributes
(
attrs
);
for
item
in
nmod
.items
{
for
item
in
nmod
.items
{
self
.
print_foreign_item
(
item
);
self
.
ann
.nested
(
self
,
Nested
::
ForeignItem
(
item
.id
)
);
}
}
}
}
...
...
compiler/rustc_incremental/src/persist/dirty_clean.rs
浏览文件 @
419a9186
...
@@ -460,6 +460,10 @@ fn visit_trait_item(&mut self, item: &hir::TraitItem<'_>) {
...
@@ -460,6 +460,10 @@ fn visit_trait_item(&mut self, item: &hir::TraitItem<'_>) {
fn
visit_impl_item
(
&
mut
self
,
item
:
&
hir
::
ImplItem
<
'_
>
)
{
fn
visit_impl_item
(
&
mut
self
,
item
:
&
hir
::
ImplItem
<
'_
>
)
{
self
.check_item
(
item
.hir_id
,
item
.span
);
self
.check_item
(
item
.hir_id
,
item
.span
);
}
}
fn
visit_foreign_item
(
&
mut
self
,
item
:
&
hir
::
ForeignItem
<
'_
>
)
{
self
.check_item
(
item
.hir_id
,
item
.span
);
}
}
}
/// Given a `#[rustc_dirty]` or `#[rustc_clean]` attribute, scan
/// Given a `#[rustc_dirty]` or `#[rustc_clean]` attribute, scan
...
...
compiler/rustc_interface/src/proc_macro_decls.rs
浏览文件 @
419a9186
...
@@ -33,6 +33,8 @@ fn visit_item(&mut self, item: &hir::Item<'_>) {
...
@@ -33,6 +33,8 @@ fn visit_item(&mut self, item: &hir::Item<'_>) {
fn
visit_trait_item
(
&
mut
self
,
_
trait_item
:
&
hir
::
TraitItem
<
'_
>
)
{}
fn
visit_trait_item
(
&
mut
self
,
_
trait_item
:
&
hir
::
TraitItem
<
'_
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
hir
::
ImplItem
<
'_
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
hir
::
ImplItem
<
'_
>
)
{}
fn
visit_foreign_item
(
&
mut
self
,
_
foreign_item
:
&
hir
::
ForeignItem
<
'_
>
)
{}
}
}
pub
(
crate
)
fn
provide
(
providers
:
&
mut
Providers
)
{
pub
(
crate
)
fn
provide
(
providers
:
&
mut
Providers
)
{
...
...
compiler/rustc_metadata/src/foreign_modules.rs
浏览文件 @
419a9186
...
@@ -21,8 +21,11 @@ fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) {
...
@@ -21,8 +21,11 @@ fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) {
_
=>
return
,
_
=>
return
,
};
};
let
foreign_items
=
let
foreign_items
=
fm
fm
.items
.iter
()
.map
(|
it
|
self
.tcx
.hir
()
.local_def_id
(
it
.hir_id
)
.to_def_id
())
.collect
();
.items
.iter
()
.map
(|
it
|
self
.tcx
.hir
()
.local_def_id
(
it
.id.hir_id
)
.to_def_id
())
.collect
();
self
.modules
.push
(
ForeignModule
{
self
.modules
.push
(
ForeignModule
{
foreign_items
,
foreign_items
,
def_id
:
self
.tcx
.hir
()
.local_def_id
(
it
.hir_id
)
.to_def_id
(),
def_id
:
self
.tcx
.hir
()
.local_def_id
(
it
.hir_id
)
.to_def_id
(),
...
@@ -31,4 +34,5 @@ fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) {
...
@@ -31,4 +34,5 @@ fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) {
fn
visit_trait_item
(
&
mut
self
,
_
it
:
&
'tcx
hir
::
TraitItem
<
'tcx
>
)
{}
fn
visit_trait_item
(
&
mut
self
,
_
it
:
&
'tcx
hir
::
TraitItem
<
'tcx
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
it
:
&
'tcx
hir
::
ImplItem
<
'tcx
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
it
:
&
'tcx
hir
::
ImplItem
<
'tcx
>
)
{}
fn
visit_foreign_item
(
&
mut
self
,
_
it
:
&
'tcx
hir
::
ForeignItem
<
'tcx
>
)
{}
}
}
compiler/rustc_metadata/src/link_args.rs
浏览文件 @
419a9186
...
@@ -45,6 +45,7 @@ fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) {
...
@@ -45,6 +45,7 @@ fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) {
fn
visit_trait_item
(
&
mut
self
,
_
it
:
&
'tcx
hir
::
TraitItem
<
'tcx
>
)
{}
fn
visit_trait_item
(
&
mut
self
,
_
it
:
&
'tcx
hir
::
TraitItem
<
'tcx
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
it
:
&
'tcx
hir
::
ImplItem
<
'tcx
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
it
:
&
'tcx
hir
::
ImplItem
<
'tcx
>
)
{}
fn
visit_foreign_item
(
&
mut
self
,
_
it
:
&
'tcx
hir
::
ForeignItem
<
'tcx
>
)
{}
}
}
impl
<
'tcx
>
Collector
<
'tcx
>
{
impl
<
'tcx
>
Collector
<
'tcx
>
{
...
...
compiler/rustc_metadata/src/native_libs.rs
浏览文件 @
419a9186
...
@@ -127,6 +127,7 @@ fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) {
...
@@ -127,6 +127,7 @@ fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) {
fn
visit_trait_item
(
&
mut
self
,
_
it
:
&
'tcx
hir
::
TraitItem
<
'tcx
>
)
{}
fn
visit_trait_item
(
&
mut
self
,
_
it
:
&
'tcx
hir
::
TraitItem
<
'tcx
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
it
:
&
'tcx
hir
::
ImplItem
<
'tcx
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
it
:
&
'tcx
hir
::
ImplItem
<
'tcx
>
)
{}
fn
visit_foreign_item
(
&
mut
self
,
_
it
:
&
'tcx
hir
::
ForeignItem
<
'tcx
>
)
{}
}
}
impl
Collector
<
'tcx
>
{
impl
Collector
<
'tcx
>
{
...
...
compiler/rustc_metadata/src/rmeta/encoder.rs
浏览文件 @
419a9186
...
@@ -1324,7 +1324,7 @@ fn encode_info_for_item(&mut self, def_id: DefId, item: &'tcx hir::Item<'tcx>) {
...
@@ -1324,7 +1324,7 @@ fn encode_info_for_item(&mut self, def_id: DefId, item: &'tcx hir::Item<'tcx>) {
fm
.items
fm
.items
.iter
()
.iter
()
.map
(|
foreign_item
|
tcx
.hir
()
.local_def_id
(
.map
(|
foreign_item
|
tcx
.hir
()
.local_def_id
(
foreign_item
.hir_id
)
.local_def_index
)
foreign_item
.
id.
hir_id
)
.local_def_index
)
),
),
hir
::
ItemKind
::
Enum
(
..
)
=>
record!
(
self
.tables.children
[
def_id
]
<-
hir
::
ItemKind
::
Enum
(
..
)
=>
record!
(
self
.tables.children
[
def_id
]
<-
self
.tcx
.adt_def
(
def_id
)
.variants
.iter
()
.map
(|
v
|
{
self
.tcx
.adt_def
(
def_id
)
.variants
.iter
()
.map
(|
v
|
{
...
@@ -1913,6 +1913,8 @@ fn visit_trait_item(&mut self, _trait_item: &'v hir::TraitItem<'v>) {}
...
@@ -1913,6 +1913,8 @@ fn visit_trait_item(&mut self, _trait_item: &'v hir::TraitItem<'v>) {}
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
'v
hir
::
ImplItem
<
'v
>
)
{
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
'v
hir
::
ImplItem
<
'v
>
)
{
// handled in `visit_item` above
// handled in `visit_item` above
}
}
fn
visit_foreign_item
(
&
mut
self
,
_
foreign_item
:
&
'v
hir
::
ForeignItem
<
'v
>
)
{}
}
}
/// Used to prefetch queries which will be needed later by metadata encoding.
/// Used to prefetch queries which will be needed later by metadata encoding.
...
@@ -1977,6 +1979,11 @@ fn visit_impl_item(&self, impl_item: &'v hir::ImplItem<'v>) {
...
@@ -1977,6 +1979,11 @@ fn visit_impl_item(&self, impl_item: &'v hir::ImplItem<'v>) {
hir
::
ImplItemKind
::
TyAlias
(
..
)
=>
(),
hir
::
ImplItemKind
::
TyAlias
(
..
)
=>
(),
}
}
}
}
fn
visit_foreign_item
(
&
self
,
_
foreign_item
:
&
'v
hir
::
ForeignItem
<
'v
>
)
{
// This should be kept in sync with `encode_info_for_foreign_item`.
// Foreign items contain no MIR.
}
}
}
// NOTE(eddyb) The following comment was preserved for posterity, even
// NOTE(eddyb) The following comment was preserved for posterity, even
...
...
compiler/rustc_middle/src/hir/map/collector.rs
浏览文件 @
419a9186
...
@@ -112,6 +112,7 @@ pub(super) fn root(
...
@@ -112,6 +112,7 @@ pub(super) fn root(
items
:
_
,
items
:
_
,
trait_items
:
_
,
trait_items
:
_
,
impl_items
:
_
,
impl_items
:
_
,
foreign_items
:
_
,
bodies
:
_
,
bodies
:
_
,
trait_impls
:
_
,
trait_impls
:
_
,
body_ids
:
_
,
body_ids
:
_
,
...
@@ -319,6 +320,10 @@ fn visit_nested_impl_item(&mut self, item_id: ImplItemId) {
...
@@ -319,6 +320,10 @@ fn visit_nested_impl_item(&mut self, item_id: ImplItemId) {
self
.visit_impl_item
(
self
.krate
.impl_item
(
item_id
));
self
.visit_impl_item
(
self
.krate
.impl_item
(
item_id
));
}
}
fn
visit_nested_foreign_item
(
&
mut
self
,
foreign_id
:
ForeignItemId
)
{
self
.visit_foreign_item
(
self
.krate
.foreign_item
(
foreign_id
));
}
fn
visit_nested_body
(
&
mut
self
,
id
:
BodyId
)
{
fn
visit_nested_body
(
&
mut
self
,
id
:
BodyId
)
{
self
.visit_body
(
self
.krate
.body
(
id
));
self
.visit_body
(
self
.krate
.body
(
id
));
}
}
...
@@ -351,11 +356,17 @@ fn visit_item(&mut self, i: &'hir Item<'hir>) {
...
@@ -351,11 +356,17 @@ fn visit_item(&mut self, i: &'hir Item<'hir>) {
});
});
}
}
fn
visit_foreign_item
(
&
mut
self
,
foreign_item
:
&
'hir
ForeignItem
<
'hir
>
)
{
fn
visit_foreign_item
(
&
mut
self
,
fi
:
&
'hir
ForeignItem
<
'hir
>
)
{
self
.insert
(
foreign_item
.span
,
foreign_item
.hir_id
,
Node
::
ForeignItem
(
foreign_item
));
debug_assert_eq!
(
fi
.hir_id.owner
,
self
.definitions
.opt_hir_id_to_local_def_id
(
fi
.hir_id
)
.unwrap
()
);
self
.with_dep_node_owner
(
fi
.hir_id.owner
,
fi
,
|
this
,
hash
|
{
this
.insert_with_hash
(
fi
.span
,
fi
.hir_id
,
Node
::
ForeignItem
(
fi
),
hash
);
self
.with_parent
(
foreign_item
.hir_id
,
|
this
|
{
this
.with_parent
(
fi
.hir_id
,
|
this
|
{
intravisit
::
walk_foreign_item
(
this
,
foreign_item
);
intravisit
::
walk_foreign_item
(
this
,
fi
);
});
});
});
}
}
...
...
compiler/rustc_middle/src/hir/map/mod.rs
浏览文件 @
419a9186
...
@@ -309,6 +309,13 @@ pub fn impl_item(&self, id: ImplItemId) -> &'hir ImplItem<'hir> {
...
@@ -309,6 +309,13 @@ pub fn impl_item(&self, id: ImplItemId) -> &'hir ImplItem<'hir> {
}
}
}
}
pub
fn
foreign_item
(
&
self
,
id
:
ForeignItemId
)
->
&
'hir
ForeignItem
<
'hir
>
{
match
self
.find
(
id
.hir_id
)
.unwrap
()
{
Node
::
ForeignItem
(
item
)
=>
item
,
_
=>
bug!
(),
}
}
pub
fn
body
(
&
self
,
id
:
BodyId
)
->
&
'hir
Body
<
'hir
>
{
pub
fn
body
(
&
self
,
id
:
BodyId
)
->
&
'hir
Body
<
'hir
>
{
self
.tcx
.hir_owner_nodes
(
id
.hir_id.owner
)
.unwrap
()
.bodies
.get
(
&
id
.hir_id.local_id
)
.unwrap
()
self
.tcx
.hir_owner_nodes
(
id
.hir_id.owner
)
.unwrap
()
.bodies
.get
(
&
id
.hir_id.local_id
)
.unwrap
()
}
}
...
@@ -470,6 +477,10 @@ pub fn visit_item_likes_in_module<V>(&self, module: LocalDefId, visitor: &mut V)
...
@@ -470,6 +477,10 @@ pub fn visit_item_likes_in_module<V>(&self, module: LocalDefId, visitor: &mut V)
for
id
in
&
module
.impl_items
{
for
id
in
&
module
.impl_items
{
visitor
.visit_impl_item
(
self
.expect_impl_item
(
id
.hir_id
));
visitor
.visit_impl_item
(
self
.expect_impl_item
(
id
.hir_id
));
}
}
for
id
in
&
module
.foreign_items
{
visitor
.visit_foreign_item
(
self
.expect_foreign_item
(
id
.hir_id
));
}
}
}
/// Retrieves the `Node` corresponding to `id`, panicking if it cannot be found.
/// Retrieves the `Node` corresponding to `id`, panicking if it cannot be found.
...
@@ -937,6 +948,10 @@ fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir> {
...
@@ -937,6 +948,10 @@ fn trait_item(&self, id: TraitItemId) -> &'hir TraitItem<'hir> {
fn
impl_item
(
&
self
,
id
:
ImplItemId
)
->
&
'hir
ImplItem
<
'hir
>
{
fn
impl_item
(
&
self
,
id
:
ImplItemId
)
->
&
'hir
ImplItem
<
'hir
>
{
self
.impl_item
(
id
)
self
.impl_item
(
id
)
}
}
fn
foreign_item
(
&
self
,
id
:
ForeignItemId
)
->
&
'hir
ForeignItem
<
'hir
>
{
self
.foreign_item
(
id
)
}
}
}
trait
Named
{
trait
Named
{
...
...
compiler/rustc_mir/src/monomorphize/collector.rs
浏览文件 @
419a9186
...
@@ -1066,6 +1066,8 @@ fn visit_impl_item(&mut self, ii: &'v hir::ImplItem<'v>) {
...
@@ -1066,6 +1066,8 @@ fn visit_impl_item(&mut self, ii: &'v hir::ImplItem<'v>) {
self
.push_if_root
(
def_id
);
self
.push_if_root
(
def_id
);
}
}
}
}
fn
visit_foreign_item
(
&
mut
self
,
_
foreign_item
:
&
'v
hir
::
ForeignItem
<
'v
>
)
{}
}
}
impl
RootCollector
<
'_
,
'v
>
{
impl
RootCollector
<
'_
,
'v
>
{
...
...
compiler/rustc_passes/src/dead.rs
浏览文件 @
419a9186
...
@@ -447,6 +447,8 @@ fn visit_trait_item(&mut self, _item: &hir::TraitItem<'_>) {
...
@@ -447,6 +447,8 @@ fn visit_trait_item(&mut self, _item: &hir::TraitItem<'_>) {
fn
visit_impl_item
(
&
mut
self
,
_
item
:
&
hir
::
ImplItem
<
'_
>
)
{
fn
visit_impl_item
(
&
mut
self
,
_
item
:
&
hir
::
ImplItem
<
'_
>
)
{
// ignore: we are handling this in `visit_item` above
// ignore: we are handling this in `visit_item` above
}
}
fn
visit_foreign_item
(
&
mut
self
,
_
item
:
&
'v
hir
::
ForeignItem
<
'v
>
)
{}
}
}
fn
create_and_seed_worklist
<
'tcx
>
(
fn
create_and_seed_worklist
<
'tcx
>
(
...
...
compiler/rustc_passes/src/diagnostic_items.rs
浏览文件 @
419a9186
...
@@ -37,6 +37,8 @@ fn visit_trait_item(&mut self, trait_item: &hir::TraitItem<'_>) {
...
@@ -37,6 +37,8 @@ fn visit_trait_item(&mut self, trait_item: &hir::TraitItem<'_>) {
fn
visit_impl_item
(
&
mut
self
,
impl_item
:
&
hir
::
ImplItem
<
'_
>
)
{
fn
visit_impl_item
(
&
mut
self
,
impl_item
:
&
hir
::
ImplItem
<
'_
>
)
{
self
.observe_item
(
&
impl_item
.attrs
,
impl_item
.hir_id
);
self
.observe_item
(
&
impl_item
.attrs
,
impl_item
.hir_id
);
}
}
fn
visit_foreign_item
(
&
mut
self
,
_
foreign_item
:
&
hir
::
ForeignItem
<
'_
>
)
{}
}
}
impl
<
'tcx
>
DiagnosticItemCollector
<
'tcx
>
{
impl
<
'tcx
>
DiagnosticItemCollector
<
'tcx
>
{
...
...
compiler/rustc_passes/src/entry.rs
浏览文件 @
419a9186
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
use
rustc_errors
::
struct_span_err
;
use
rustc_errors
::
struct_span_err
;
use
rustc_hir
::
def_id
::{
CrateNum
,
LocalDefId
,
CRATE_DEF_INDEX
,
LOCAL_CRATE
};
use
rustc_hir
::
def_id
::{
CrateNum
,
LocalDefId
,
CRATE_DEF_INDEX
,
LOCAL_CRATE
};
use
rustc_hir
::
itemlikevisit
::
ItemLikeVisitor
;
use
rustc_hir
::
itemlikevisit
::
ItemLikeVisitor
;
use
rustc_hir
::{
HirId
,
ImplItem
,
Item
,
ItemKind
,
TraitItem
};
use
rustc_hir
::{
ForeignItem
,
HirId
,
ImplItem
,
Item
,
ItemKind
,
TraitItem
};
use
rustc_middle
::
hir
::
map
::
Map
;
use
rustc_middle
::
hir
::
map
::
Map
;
use
rustc_middle
::
ty
::
query
::
Providers
;
use
rustc_middle
::
ty
::
query
::
Providers
;
use
rustc_middle
::
ty
::
TyCtxt
;
use
rustc_middle
::
ty
::
TyCtxt
;
...
@@ -45,6 +45,8 @@ fn visit_trait_item(&mut self, _trait_item: &'tcx TraitItem<'tcx>) {
...
@@ -45,6 +45,8 @@ fn visit_trait_item(&mut self, _trait_item: &'tcx TraitItem<'tcx>) {
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
'tcx
ImplItem
<
'tcx
>
)
{
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
'tcx
ImplItem
<
'tcx
>
)
{
// Entry fn is never a trait item.
// Entry fn is never a trait item.
}
}
fn
visit_foreign_item
(
&
mut
self
,
_
:
&
'tcx
ForeignItem
<
'tcx
>
)
{}
}
}
fn
entry_fn
(
tcx
:
TyCtxt
<
'_
>
,
cnum
:
CrateNum
)
->
Option
<
(
LocalDefId
,
EntryFnType
)
>
{
fn
entry_fn
(
tcx
:
TyCtxt
<
'_
>
,
cnum
:
CrateNum
)
->
Option
<
(
LocalDefId
,
EntryFnType
)
>
{
...
...
compiler/rustc_passes/src/hir_id_validator.rs
浏览文件 @
419a9186
...
@@ -68,6 +68,11 @@ fn visit_impl_item(&mut self, i: &'hir hir::ImplItem<'hir>) {
...
@@ -68,6 +68,11 @@ fn visit_impl_item(&mut self, i: &'hir hir::ImplItem<'hir>) {
let
mut
inner_visitor
=
self
.new_inner_visitor
(
self
.hir_map
);
let
mut
inner_visitor
=
self
.new_inner_visitor
(
self
.hir_map
);
inner_visitor
.check
(
i
.hir_id
,
|
this
|
intravisit
::
walk_impl_item
(
this
,
i
));
inner_visitor
.check
(
i
.hir_id
,
|
this
|
intravisit
::
walk_impl_item
(
this
,
i
));
}
}
fn
visit_foreign_item
(
&
mut
self
,
i
:
&
'hir
hir
::
ForeignItem
<
'hir
>
)
{
let
mut
inner_visitor
=
self
.new_inner_visitor
(
self
.hir_map
);
inner_visitor
.check
(
i
.hir_id
,
|
this
|
intravisit
::
walk_foreign_item
(
this
,
i
));
}
}
}
impl
<
'a
,
'hir
>
HirIdValidator
<
'a
,
'hir
>
{
impl
<
'a
,
'hir
>
HirIdValidator
<
'a
,
'hir
>
{
...
...
compiler/rustc_passes/src/lang_items.rs
浏览文件 @
419a9186
...
@@ -54,6 +54,8 @@ fn visit_impl_item(&mut self, impl_item: &hir::ImplItem<'_>) {
...
@@ -54,6 +54,8 @@ fn visit_impl_item(&mut self, impl_item: &hir::ImplItem<'_>) {
impl_item
.attrs
,
impl_item
.attrs
,
)
)
}
}
fn
visit_foreign_item
(
&
mut
self
,
_
:
&
hir
::
ForeignItem
<
'_
>
)
{}
}
}
impl
LanguageItemCollector
<
'tcx
>
{
impl
LanguageItemCollector
<
'tcx
>
{
...
...
compiler/rustc_passes/src/layout_test.rs
浏览文件 @
419a9186
...
@@ -40,6 +40,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
...
@@ -40,6 +40,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
fn
visit_trait_item
(
&
mut
self
,
_
:
&
'tcx
hir
::
TraitItem
<
'tcx
>
)
{}
fn
visit_trait_item
(
&
mut
self
,
_
:
&
'tcx
hir
::
TraitItem
<
'tcx
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
:
&
'tcx
hir
::
ImplItem
<
'tcx
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
:
&
'tcx
hir
::
ImplItem
<
'tcx
>
)
{}
fn
visit_foreign_item
(
&
mut
self
,
_
:
&
'tcx
hir
::
ForeignItem
<
'tcx
>
)
{}
}
}
impl
LayoutTest
<
'tcx
>
{
impl
LayoutTest
<
'tcx
>
{
...
...
compiler/rustc_passes/src/reachable.rs
浏览文件 @
419a9186
...
@@ -378,6 +378,8 @@ fn visit_trait_item(&mut self, _trait_item: &hir::TraitItem<'_>) {}
...
@@ -378,6 +378,8 @@ fn visit_trait_item(&mut self, _trait_item: &hir::TraitItem<'_>) {}
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
hir
::
ImplItem
<
'_
>
)
{
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
hir
::
ImplItem
<
'_
>
)
{
// processed in visit_item above
// processed in visit_item above
}
}
fn
visit_foreign_item
(
&
mut
self
,
_
foreign_item
:
&
hir
::
ForeignItem
<
'_
>
)
{}
}
}
fn
reachable_set
<
'tcx
>
(
tcx
:
TyCtxt
<
'tcx
>
,
crate_num
:
CrateNum
)
->
FxHashSet
<
LocalDefId
>
{
fn
reachable_set
<
'tcx
>
(
tcx
:
TyCtxt
<
'tcx
>
,
crate_num
:
CrateNum
)
->
FxHashSet
<
LocalDefId
>
{
...
...
compiler/rustc_plugin_impl/src/build.rs
浏览文件 @
419a9186
...
@@ -25,6 +25,8 @@ fn visit_item(&mut self, item: &hir::Item<'_>) {
...
@@ -25,6 +25,8 @@ fn visit_item(&mut self, item: &hir::Item<'_>) {
fn
visit_trait_item
(
&
mut
self
,
_
trait_item
:
&
hir
::
TraitItem
<
'_
>
)
{}
fn
visit_trait_item
(
&
mut
self
,
_
trait_item
:
&
hir
::
TraitItem
<
'_
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
hir
::
ImplItem
<
'_
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
hir
::
ImplItem
<
'_
>
)
{}
fn
visit_foreign_item
(
&
mut
self
,
_
foreign_item
:
&
hir
::
ForeignItem
<
'_
>
)
{}
}
}
/// Finds the function marked with `#[plugin_registrar]`, if any.
/// Finds the function marked with `#[plugin_registrar]`, if any.
...
...
compiler/rustc_privacy/src/lib.rs
浏览文件 @
419a9186
...
@@ -657,7 +657,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
...
@@ -657,7 +657,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
hir
::
ItemKind
::
ForeignMod
(
ref
foreign_mod
)
=>
{
hir
::
ItemKind
::
ForeignMod
(
ref
foreign_mod
)
=>
{
for
foreign_item
in
foreign_mod
.items
{
for
foreign_item
in
foreign_mod
.items
{
if
foreign_item
.vis.node
.is_pub
()
{
if
foreign_item
.vis.node
.is_pub
()
{
self
.update
(
foreign_item
.hir_id
,
item_level
);
self
.update
(
foreign_item
.
id.
hir_id
,
item_level
);
}
}
}
}
}
}
...
@@ -772,9 +772,9 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
...
@@ -772,9 +772,9 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
// Visit everything, but foreign items have their own levels.
// Visit everything, but foreign items have their own levels.
hir
::
ItemKind
::
ForeignMod
(
ref
foreign_mod
)
=>
{
hir
::
ItemKind
::
ForeignMod
(
ref
foreign_mod
)
=>
{
for
foreign_item
in
foreign_mod
.items
{
for
foreign_item
in
foreign_mod
.items
{
let
foreign_item_level
=
self
.get
(
foreign_item
.hir_id
);
let
foreign_item_level
=
self
.get
(
foreign_item
.
id.
hir_id
);
if
foreign_item_level
.is_some
()
{
if
foreign_item_level
.is_some
()
{
self
.reach
(
foreign_item
.hir_id
,
foreign_item_level
)
self
.reach
(
foreign_item
.
id.
hir_id
,
foreign_item_level
)
.generics
()
.generics
()
.predicates
()
.predicates
()
.ty
();
.ty
();
...
@@ -1950,8 +1950,8 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
...
@@ -1950,8 +1950,8 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
// Subitems of foreign modules have their own publicity.
// Subitems of foreign modules have their own publicity.
hir
::
ItemKind
::
ForeignMod
(
ref
foreign_mod
)
=>
{
hir
::
ItemKind
::
ForeignMod
(
ref
foreign_mod
)
=>
{
for
foreign_item
in
foreign_mod
.items
{
for
foreign_item
in
foreign_mod
.items
{
let
vis
=
tcx
.visibility
(
tcx
.hir
()
.local_def_id
(
foreign_item
.hir_id
));
let
vis
=
tcx
.visibility
(
tcx
.hir
()
.local_def_id
(
foreign_item
.
id.
hir_id
));
self
.check
(
foreign_item
.hir_id
,
vis
)
.generics
()
.predicates
()
.ty
();
self
.check
(
foreign_item
.
id.
hir_id
,
vis
)
.generics
()
.predicates
()
.ty
();
}
}
}
}
// Subitems of structs and unions have their own publicity.
// Subitems of structs and unions have their own publicity.
...
...
compiler/rustc_symbol_mangling/src/test.rs
浏览文件 @
419a9186
...
@@ -71,4 +71,8 @@ fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) {
...
@@ -71,4 +71,8 @@ fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem<'tcx>) {
fn
visit_impl_item
(
&
mut
self
,
impl_item
:
&
'tcx
hir
::
ImplItem
<
'tcx
>
)
{
fn
visit_impl_item
(
&
mut
self
,
impl_item
:
&
'tcx
hir
::
ImplItem
<
'tcx
>
)
{
self
.process_attrs
(
impl_item
.hir_id
);
self
.process_attrs
(
impl_item
.hir_id
);
}
}
fn
visit_foreign_item
(
&
mut
self
,
foreign_item
:
&
'tcx
hir
::
ForeignItem
<
'tcx
>
)
{
self
.process_attrs
(
foreign_item
.hir_id
);
}
}
}
compiler/rustc_typeck/src/check/check.rs
浏览文件 @
419a9186
...
@@ -751,15 +751,17 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item<'tcx>) {
...
@@ -751,15 +751,17 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item<'tcx>) {
if
m
.abi
==
Abi
::
RustIntrinsic
{
if
m
.abi
==
Abi
::
RustIntrinsic
{
for
item
in
m
.items
{
for
item
in
m
.items
{
let
item
=
tcx
.hir
()
.foreign_item
(
item
.id
);
intrinsic
::
check_intrinsic_type
(
tcx
,
item
);
intrinsic
::
check_intrinsic_type
(
tcx
,
item
);
}
}
}
else
if
m
.abi
==
Abi
::
PlatformIntrinsic
{
}
else
if
m
.abi
==
Abi
::
PlatformIntrinsic
{
for
item
in
m
.items
{
for
item
in
m
.items
{
let
item
=
tcx
.hir
()
.foreign_item
(
item
.id
);
intrinsic
::
check_platform_intrinsic_type
(
tcx
,
item
);
intrinsic
::
check_platform_intrinsic_type
(
tcx
,
item
);
}
}
}
else
{
}
else
{
for
item
in
m
.items
{
for
item
in
m
.items
{
let
def_id
=
tcx
.hir
()
.local_def_id
(
item
.hir_id
);
let
def_id
=
tcx
.hir
()
.local_def_id
(
item
.
id.
hir_id
);
let
generics
=
tcx
.generics_of
(
def_id
);
let
generics
=
tcx
.generics_of
(
def_id
);
let
own_counts
=
generics
.own_counts
();
let
own_counts
=
generics
.own_counts
();
if
generics
.params
.len
()
-
own_counts
.lifetimes
!=
0
{
if
generics
.params
.len
()
-
own_counts
.lifetimes
!=
0
{
...
@@ -791,6 +793,7 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item<'tcx>) {
...
@@ -791,6 +793,7 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item<'tcx>) {
.emit
();
.emit
();
}
}
let
item
=
tcx
.hir
()
.foreign_item
(
item
.id
);
match
item
.kind
{
match
item
.kind
{
hir
::
ForeignItemKind
::
Fn
(
ref
fn_decl
,
_
,
_
)
=>
{
hir
::
ForeignItemKind
::
Fn
(
ref
fn_decl
,
_
,
_
)
=>
{
require_c_abi_if_c_variadic
(
tcx
,
fn_decl
,
m
.abi
,
item
.span
);
require_c_abi_if_c_variadic
(
tcx
,
fn_decl
,
m
.abi
,
item
.span
);
...
...
compiler/rustc_typeck/src/check/method/suggest.rs
浏览文件 @
419a9186
...
@@ -1308,6 +1308,8 @@ fn visit_item(&mut self, i: &'v hir::Item<'v>) {
...
@@ -1308,6 +1308,8 @@ fn visit_item(&mut self, i: &'v hir::Item<'v>) {
fn
visit_trait_item
(
&
mut
self
,
_
trait_item
:
&
hir
::
TraitItem
<
'_
>
)
{}
fn
visit_trait_item
(
&
mut
self
,
_
trait_item
:
&
hir
::
TraitItem
<
'_
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
hir
::
ImplItem
<
'_
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
hir
::
ImplItem
<
'_
>
)
{}
fn
visit_foreign_item
(
&
mut
self
,
_
foreign_item
:
&
hir
::
ForeignItem
<
'_
>
)
{}
}
}
tcx
.hir
()
.krate
()
.visit_all_item_likes
(
&
mut
Visitor
{
map
:
&
tcx
.hir
(),
traits
:
&
mut
traits
});
tcx
.hir
()
.krate
()
.visit_all_item_likes
(
&
mut
Visitor
{
map
:
&
tcx
.hir
(),
traits
:
&
mut
traits
});
...
...
compiler/rustc_typeck/src/check/mod.rs
浏览文件 @
419a9186
...
@@ -1134,6 +1134,7 @@ fn visit_item(&mut self, i: &'tcx hir::Item<'tcx>) {
...
@@ -1134,6 +1134,7 @@ fn visit_item(&mut self, i: &'tcx hir::Item<'tcx>) {
}
}
fn
visit_trait_item
(
&
mut
self
,
_
:
&
'tcx
hir
::
TraitItem
<
'tcx
>
)
{}
fn
visit_trait_item
(
&
mut
self
,
_
:
&
'tcx
hir
::
TraitItem
<
'tcx
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
:
&
'tcx
hir
::
ImplItem
<
'tcx
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
:
&
'tcx
hir
::
ImplItem
<
'tcx
>
)
{}
fn
visit_foreign_item
(
&
mut
self
,
_
:
&
'tcx
hir
::
ForeignItem
<
'tcx
>
)
{}
}
}
fn
typeck_item_bodies
(
tcx
:
TyCtxt
<
'_
>
,
crate_num
:
CrateNum
)
{
fn
typeck_item_bodies
(
tcx
:
TyCtxt
<
'_
>
,
crate_num
:
CrateNum
)
{
...
...
compiler/rustc_typeck/src/check/wfcheck.rs
浏览文件 @
419a9186
...
@@ -158,6 +158,7 @@ pub fn check_item_well_formed(tcx: TyCtxt<'_>, def_id: LocalDefId) {
...
@@ -158,6 +158,7 @@ pub fn check_item_well_formed(tcx: TyCtxt<'_>, def_id: LocalDefId) {
}
}
hir
::
ItemKind
::
ForeignMod
(
ref
module
)
=>
{
hir
::
ItemKind
::
ForeignMod
(
ref
module
)
=>
{
for
it
in
module
.items
.iter
()
{
for
it
in
module
.items
.iter
()
{
let
it
=
tcx
.hir
()
.foreign_item
(
it
.id
);
match
it
.kind
{
match
it
.kind
{
hir
::
ForeignItemKind
::
Fn
(
ref
decl
,
..
)
=>
{
hir
::
ForeignItemKind
::
Fn
(
ref
decl
,
..
)
=>
{
check_item_fn
(
tcx
,
it
.hir_id
,
it
.ident
,
it
.span
,
decl
)
check_item_fn
(
tcx
,
it
.hir_id
,
it
.ident
,
it
.span
,
decl
)
...
@@ -1345,6 +1346,10 @@ fn visit_trait_item(&self, trait_item: &'tcx hir::TraitItem<'tcx>) {
...
@@ -1345,6 +1346,10 @@ fn visit_trait_item(&self, trait_item: &'tcx hir::TraitItem<'tcx>) {
fn
visit_impl_item
(
&
self
,
impl_item
:
&
'tcx
hir
::
ImplItem
<
'tcx
>
)
{
fn
visit_impl_item
(
&
self
,
impl_item
:
&
'tcx
hir
::
ImplItem
<
'tcx
>
)
{
Visitor
::
visit_impl_item
(
&
mut
self
.clone
(),
impl_item
);
Visitor
::
visit_impl_item
(
&
mut
self
.clone
(),
impl_item
);
}
}
fn
visit_foreign_item
(
&
self
,
foreign_item
:
&
'tcx
hir
::
ForeignItem
<
'tcx
>
)
{
Visitor
::
visit_foreign_item
(
&
mut
self
.clone
(),
foreign_item
)
}
}
}
impl
Visitor
<
'tcx
>
for
CheckTypeWellFormedVisitor
<
'tcx
>
{
impl
Visitor
<
'tcx
>
for
CheckTypeWellFormedVisitor
<
'tcx
>
{
...
...
compiler/rustc_typeck/src/check_unused.rs
浏览文件 @
419a9186
...
@@ -35,6 +35,8 @@ fn visit_item(&mut self, item: &hir::Item<'_>) {
...
@@ -35,6 +35,8 @@ fn visit_item(&mut self, item: &hir::Item<'_>) {
fn
visit_trait_item
(
&
mut
self
,
_
trait_item
:
&
hir
::
TraitItem
<
'_
>
)
{}
fn
visit_trait_item
(
&
mut
self
,
_
trait_item
:
&
hir
::
TraitItem
<
'_
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
hir
::
ImplItem
<
'_
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
hir
::
ImplItem
<
'_
>
)
{}
fn
visit_foreign_item
(
&
mut
self
,
_
foreign_item
:
&
hir
::
ForeignItem
<
'_
>
)
{}
}
}
struct
CheckVisitor
<
'tcx
>
{
struct
CheckVisitor
<
'tcx
>
{
...
@@ -225,4 +227,6 @@ fn visit_item(&mut self, item: &hir::Item<'_>) {
...
@@ -225,4 +227,6 @@ fn visit_item(&mut self, item: &hir::Item<'_>) {
fn
visit_trait_item
(
&
mut
self
,
_
trait_item
:
&
hir
::
TraitItem
<
'_
>
)
{}
fn
visit_trait_item
(
&
mut
self
,
_
trait_item
:
&
hir
::
TraitItem
<
'_
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
hir
::
ImplItem
<
'_
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
hir
::
ImplItem
<
'_
>
)
{}
fn
visit_foreign_item
(
&
mut
self
,
_
foreign_item
:
&
hir
::
ForeignItem
<
'_
>
)
{}
}
}
compiler/rustc_typeck/src/coherence/inherent_impls.rs
浏览文件 @
419a9186
...
@@ -334,6 +334,8 @@ fn visit_item(&mut self, item: &hir::Item<'_>) {
...
@@ -334,6 +334,8 @@ fn visit_item(&mut self, item: &hir::Item<'_>) {
fn
visit_trait_item
(
&
mut
self
,
_
trait_item
:
&
hir
::
TraitItem
<
'_
>
)
{}
fn
visit_trait_item
(
&
mut
self
,
_
trait_item
:
&
hir
::
TraitItem
<
'_
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
hir
::
ImplItem
<
'_
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
hir
::
ImplItem
<
'_
>
)
{}
fn
visit_foreign_item
(
&
mut
self
,
_
foreign_item
:
&
hir
::
ForeignItem
<
'_
>
)
{}
}
}
impl
InherentCollect
<
'tcx
>
{
impl
InherentCollect
<
'tcx
>
{
...
...
compiler/rustc_typeck/src/coherence/inherent_impls_overlap.rs
浏览文件 @
419a9186
...
@@ -149,4 +149,6 @@ fn visit_item(&mut self, item: &'v hir::Item<'v>) {
...
@@ -149,4 +149,6 @@ fn visit_item(&mut self, item: &'v hir::Item<'v>) {
fn
visit_trait_item
(
&
mut
self
,
_
trait_item
:
&
hir
::
TraitItem
<
'v
>
)
{}
fn
visit_trait_item
(
&
mut
self
,
_
trait_item
:
&
hir
::
TraitItem
<
'v
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
hir
::
ImplItem
<
'v
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
hir
::
ImplItem
<
'v
>
)
{}
fn
visit_foreign_item
(
&
mut
self
,
_
foreign_item
:
&
hir
::
ForeignItem
<
'v
>
)
{}
}
}
compiler/rustc_typeck/src/coherence/orphan.rs
浏览文件 @
419a9186
...
@@ -244,4 +244,6 @@ fn visit_item(&mut self, item: &hir::Item<'_>) {
...
@@ -244,4 +244,6 @@ fn visit_item(&mut self, item: &hir::Item<'_>) {
fn
visit_trait_item
(
&
mut
self
,
_
trait_item
:
&
hir
::
TraitItem
<
'_
>
)
{}
fn
visit_trait_item
(
&
mut
self
,
_
trait_item
:
&
hir
::
TraitItem
<
'_
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
hir
::
ImplItem
<
'_
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
hir
::
ImplItem
<
'_
>
)
{}
fn
visit_foreign_item
(
&
mut
self
,
_
foreign_item
:
&
hir
::
ForeignItem
<
'_
>
)
{}
}
}
compiler/rustc_typeck/src/coherence/unsafety.rs
浏览文件 @
419a9186
...
@@ -94,4 +94,6 @@ fn visit_item(&mut self, item: &'v hir::Item<'v>) {
...
@@ -94,4 +94,6 @@ fn visit_item(&mut self, item: &'v hir::Item<'v>) {
fn
visit_trait_item
(
&
mut
self
,
_
trait_item
:
&
hir
::
TraitItem
<
'_
>
)
{}
fn
visit_trait_item
(
&
mut
self
,
_
trait_item
:
&
hir
::
TraitItem
<
'_
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
hir
::
ImplItem
<
'_
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
hir
::
ImplItem
<
'_
>
)
{}
fn
visit_foreign_item
(
&
mut
self
,
_
foreign_item
:
&
hir
::
ForeignItem
<
'_
>
)
{}
}
}
compiler/rustc_typeck/src/collect.rs
浏览文件 @
419a9186
...
@@ -648,6 +648,7 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::HirId) {
...
@@ -648,6 +648,7 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::HirId) {
|
hir
::
ItemKind
::
GlobalAsm
(
_
)
=>
{}
|
hir
::
ItemKind
::
GlobalAsm
(
_
)
=>
{}
hir
::
ItemKind
::
ForeignMod
(
ref
foreign_mod
)
=>
{
hir
::
ItemKind
::
ForeignMod
(
ref
foreign_mod
)
=>
{
for
item
in
foreign_mod
.items
{
for
item
in
foreign_mod
.items
{
let
item
=
tcx
.hir
()
.foreign_item
(
item
.id
);
let
def_id
=
tcx
.hir
()
.local_def_id
(
item
.hir_id
);
let
def_id
=
tcx
.hir
()
.local_def_id
(
item
.hir_id
);
tcx
.ensure
()
.generics_of
(
def_id
);
tcx
.ensure
()
.generics_of
(
def_id
);
tcx
.ensure
()
.type_of
(
def_id
);
tcx
.ensure
()
.type_of
(
def_id
);
...
...
compiler/rustc_typeck/src/impl_wf_check.rs
浏览文件 @
419a9186
...
@@ -93,6 +93,8 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
...
@@ -93,6 +93,8 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
fn
visit_trait_item
(
&
mut
self
,
_
trait_item
:
&
'tcx
hir
::
TraitItem
<
'tcx
>
)
{}
fn
visit_trait_item
(
&
mut
self
,
_
trait_item
:
&
'tcx
hir
::
TraitItem
<
'tcx
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
'tcx
hir
::
ImplItem
<
'tcx
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
'tcx
hir
::
ImplItem
<
'tcx
>
)
{}
fn
visit_foreign_item
(
&
mut
self
,
_
foreign_item
:
&
'tcx
hir
::
ForeignItem
<
'tcx
>
)
{}
}
}
fn
enforce_impl_params_are_constrained
(
fn
enforce_impl_params_are_constrained
(
...
...
compiler/rustc_typeck/src/outlives/implicit_infer.rs
浏览文件 @
419a9186
...
@@ -109,6 +109,8 @@ fn visit_item(&mut self, item: &hir::Item<'_>) {
...
@@ -109,6 +109,8 @@ fn visit_item(&mut self, item: &hir::Item<'_>) {
fn
visit_trait_item
(
&
mut
self
,
_
trait_item
:
&
'tcx
hir
::
TraitItem
<
'tcx
>
)
{}
fn
visit_trait_item
(
&
mut
self
,
_
trait_item
:
&
'tcx
hir
::
TraitItem
<
'tcx
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
'tcx
hir
::
ImplItem
<
'tcx
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
impl_item
:
&
'tcx
hir
::
ImplItem
<
'tcx
>
)
{}
fn
visit_foreign_item
(
&
mut
self
,
_
foreign_item
:
&
'tcx
hir
::
ForeignItem
<
'tcx
>
)
{}
}
}
fn
insert_required_predicates_to_be_wf
<
'tcx
>
(
fn
insert_required_predicates_to_be_wf
<
'tcx
>
(
...
...
compiler/rustc_typeck/src/outlives/test.rs
浏览文件 @
419a9186
...
@@ -26,4 +26,5 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
...
@@ -26,4 +26,5 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
fn
visit_trait_item
(
&
mut
self
,
_
:
&
'tcx
hir
::
TraitItem
<
'tcx
>
)
{}
fn
visit_trait_item
(
&
mut
self
,
_
:
&
'tcx
hir
::
TraitItem
<
'tcx
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
:
&
'tcx
hir
::
ImplItem
<
'tcx
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
:
&
'tcx
hir
::
ImplItem
<
'tcx
>
)
{}
fn
visit_foreign_item
(
&
mut
self
,
_
:
&
'tcx
hir
::
ForeignItem
<
'tcx
>
)
{}
}
}
compiler/rustc_typeck/src/variance/constraints.rs
浏览文件 @
419a9186
...
@@ -92,14 +92,6 @@ fn visit_item(&mut self, item: &hir::Item<'_>) {
...
@@ -92,14 +92,6 @@ fn visit_item(&mut self, item: &hir::Item<'_>) {
self
.visit_node_helper
(
item
.hir_id
);
self
.visit_node_helper
(
item
.hir_id
);
}
}
hir
::
ItemKind
::
ForeignMod
(
ref
foreign_mod
)
=>
{
for
foreign_item
in
foreign_mod
.items
{
if
let
hir
::
ForeignItemKind
::
Fn
(
..
)
=
foreign_item
.kind
{
self
.visit_node_helper
(
foreign_item
.hir_id
);
}
}
}
_
=>
{}
_
=>
{}
}
}
}
}
...
@@ -115,6 +107,12 @@ fn visit_impl_item(&mut self, impl_item: &hir::ImplItem<'_>) {
...
@@ -115,6 +107,12 @@ fn visit_impl_item(&mut self, impl_item: &hir::ImplItem<'_>) {
self
.visit_node_helper
(
impl_item
.hir_id
);
self
.visit_node_helper
(
impl_item
.hir_id
);
}
}
}
}
fn
visit_foreign_item
(
&
mut
self
,
foreign_item
:
&
hir
::
ForeignItem
<
'_
>
)
{
if
let
hir
::
ForeignItemKind
::
Fn
(
..
)
=
foreign_item
.kind
{
self
.visit_node_helper
(
foreign_item
.hir_id
);
}
}
}
}
impl
<
'a
,
'tcx
>
ConstraintContext
<
'a
,
'tcx
>
{
impl
<
'a
,
'tcx
>
ConstraintContext
<
'a
,
'tcx
>
{
...
...
compiler/rustc_typeck/src/variance/terms.rs
浏览文件 @
419a9186
...
@@ -153,14 +153,6 @@ fn visit_item(&mut self, item: &hir::Item<'_>) {
...
@@ -153,14 +153,6 @@ fn visit_item(&mut self, item: &hir::Item<'_>) {
self
.add_inferreds_for_item
(
item
.hir_id
);
self
.add_inferreds_for_item
(
item
.hir_id
);
}
}
hir
::
ItemKind
::
ForeignMod
(
ref
foreign_mod
)
=>
{
for
foreign_item
in
foreign_mod
.items
{
if
let
hir
::
ForeignItemKind
::
Fn
(
..
)
=
foreign_item
.kind
{
self
.add_inferreds_for_item
(
foreign_item
.hir_id
);
}
}
}
_
=>
{}
_
=>
{}
}
}
}
}
...
@@ -176,4 +168,10 @@ fn visit_impl_item(&mut self, impl_item: &hir::ImplItem<'_>) {
...
@@ -176,4 +168,10 @@ fn visit_impl_item(&mut self, impl_item: &hir::ImplItem<'_>) {
self
.add_inferreds_for_item
(
impl_item
.hir_id
);
self
.add_inferreds_for_item
(
impl_item
.hir_id
);
}
}
}
}
fn
visit_foreign_item
(
&
mut
self
,
foreign_item
:
&
hir
::
ForeignItem
<
'_
>
)
{
if
let
hir
::
ForeignItemKind
::
Fn
(
..
)
=
foreign_item
.kind
{
self
.add_inferreds_for_item
(
foreign_item
.hir_id
);
}
}
}
}
compiler/rustc_typeck/src/variance/test.rs
浏览文件 @
419a9186
...
@@ -26,4 +26,5 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
...
@@ -26,4 +26,5 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
fn
visit_trait_item
(
&
mut
self
,
_
:
&
'tcx
hir
::
TraitItem
<
'tcx
>
)
{}
fn
visit_trait_item
(
&
mut
self
,
_
:
&
'tcx
hir
::
TraitItem
<
'tcx
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
:
&
'tcx
hir
::
ImplItem
<
'tcx
>
)
{}
fn
visit_impl_item
(
&
mut
self
,
_
:
&
'tcx
hir
::
ImplItem
<
'tcx
>
)
{}
fn
visit_foreign_item
(
&
mut
self
,
_
:
&
'tcx
hir
::
ForeignItem
<
'tcx
>
)
{}
}
}
src/librustdoc/visit_ast.rs
浏览文件 @
419a9186
...
@@ -242,6 +242,7 @@ fn visit_item(
...
@@ -242,6 +242,7 @@ fn visit_item(
match
item
.kind
{
match
item
.kind
{
hir
::
ItemKind
::
ForeignMod
(
ref
fm
)
=>
{
hir
::
ItemKind
::
ForeignMod
(
ref
fm
)
=>
{
for
item
in
fm
.items
{
for
item
in
fm
.items
{
let
item
=
self
.cx.tcx
.hir
()
.foreign_item
(
item
.id
);
self
.visit_foreign_item
(
item
,
None
,
om
);
self
.visit_foreign_item
(
item
,
None
,
om
);
}
}
}
}
...
...
src/test/ui/lint/inline-trait-and-foreign-items.stderr
浏览文件 @
419a9186
error[E0518]: attribute should be applied to function or closure
--> $DIR/inline-trait-and-foreign-items.rs:30:5
|
LL | #[inline]
| ^^^^^^^^^
LL | static X: u32;
| -------------- not a function or closure
error[E0518]: attribute should be applied to function or closure
--> $DIR/inline-trait-and-foreign-items.rs:33:5
|
LL | #[inline]
| ^^^^^^^^^
LL | type T;
| ------- not a function or closure
warning: `#[inline]` is ignored on constants
warning: `#[inline]` is ignored on constants
--> $DIR/inline-trait-and-foreign-items.rs:7:5
--> $DIR/inline-trait-and-foreign-items.rs:7:5
|
|
...
@@ -61,6 +45,22 @@ LL | #[inline]
...
@@ -61,6 +45,22 @@ LL | #[inline]
LL | type U = impl Trait;
LL | type U = impl Trait;
| -------------------- not a function or closure
| -------------------- not a function or closure
error[E0518]: attribute should be applied to function or closure
--> $DIR/inline-trait-and-foreign-items.rs:30:5
|
LL | #[inline]
| ^^^^^^^^^
LL | static X: u32;
| -------------- not a function or closure
error[E0518]: attribute should be applied to function or closure
--> $DIR/inline-trait-and-foreign-items.rs:33:5
|
LL | #[inline]
| ^^^^^^^^^
LL | type T;
| ------- not a function or closure
error: could not find defining uses
error: could not find defining uses
--> $DIR/inline-trait-and-foreign-items.rs:26:14
--> $DIR/inline-trait-and-foreign-items.rs:26:14
|
|
...
...
src/test/ui/lint/warn-unused-inline-on-fn-prototypes.stderr
浏览文件 @
419a9186
error: `#[inline]` is ignored on function prototypes
error: `#[inline]` is ignored on function prototypes
--> $DIR/warn-unused-inline-on-fn-prototypes.rs:
9
:5
--> $DIR/warn-unused-inline-on-fn-prototypes.rs:
4
:5
|
|
LL | #[inline]
LL | #[inline]
| ^^^^^^^^^
| ^^^^^^^^^
...
@@ -11,7 +11,7 @@ LL | #![deny(unused_attributes)]
...
@@ -11,7 +11,7 @@ LL | #![deny(unused_attributes)]
| ^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^^^
error: `#[inline]` is ignored on function prototypes
error: `#[inline]` is ignored on function prototypes
--> $DIR/warn-unused-inline-on-fn-prototypes.rs:
4
:5
--> $DIR/warn-unused-inline-on-fn-prototypes.rs:
9
:5
|
|
LL | #[inline]
LL | #[inline]
| ^^^^^^^^^
| ^^^^^^^^^
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录