Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
acf33f2d
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,发现更多精彩内容 >>
提交
acf33f2d
编写于
11月 28, 2019
作者:
C
Camille GILLOT
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use Arena inside hir::ForeignItem.
上级
abbe6259
变更
26
隐藏空白更改
内联
并排
Showing
26 changed file
with
72 addition
and
63 deletion
+72
-63
src/librustc/arena.rs
src/librustc/arena.rs
+2
-0
src/librustc/hir/check_attr.rs
src/librustc/hir/check_attr.rs
+2
-2
src/librustc/hir/intravisit.rs
src/librustc/hir/intravisit.rs
+5
-5
src/librustc/hir/lowering/item.rs
src/librustc/hir/lowering/item.rs
+8
-7
src/librustc/hir/map/collector.rs
src/librustc/hir/map/collector.rs
+1
-1
src/librustc/hir/map/mod.rs
src/librustc/hir/map/mod.rs
+2
-2
src/librustc/hir/mod.rs
src/librustc/hir/mod.rs
+11
-11
src/librustc/hir/print.rs
src/librustc/hir/print.rs
+3
-3
src/librustc/lint/context.rs
src/librustc/lint/context.rs
+1
-1
src/librustc/lint/mod.rs
src/librustc/lint/mod.rs
+3
-3
src/librustc/middle/resolve_lifetime.rs
src/librustc/middle/resolve_lifetime.rs
+1
-1
src/librustc/middle/stability.rs
src/librustc/middle/stability.rs
+2
-2
src/librustc/middle/weak_lang_items.rs
src/librustc/middle/weak_lang_items.rs
+1
-1
src/librustc_lint/builtin.rs
src/librustc_lint/builtin.rs
+1
-1
src/librustc_lint/types.rs
src/librustc_lint/types.rs
+1
-1
src/librustc_metadata/rmeta/encoder.rs
src/librustc_metadata/rmeta/encoder.rs
+3
-3
src/librustc_passes/dead.rs
src/librustc_passes/dead.rs
+2
-2
src/librustc_passes/hir_stats.rs
src/librustc_passes/hir_stats.rs
+1
-1
src/librustc_privacy/lib.rs
src/librustc_privacy/lib.rs
+4
-4
src/librustc_typeck/check/intrinsic.rs
src/librustc_typeck/check/intrinsic.rs
+3
-3
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+10
-4
src/librustc_typeck/collect.rs
src/librustc_typeck/collect.rs
+1
-1
src/librustc_typeck/variance/constraints.rs
src/librustc_typeck/variance/constraints.rs
+1
-1
src/librustc_typeck/variance/terms.rs
src/librustc_typeck/variance/terms.rs
+1
-1
src/librustdoc/doctree.rs
src/librustdoc/doctree.rs
+1
-1
src/librustdoc/visit_ast.rs
src/librustdoc/visit_ast.rs
+1
-1
未找到文件。
src/librustc/arena.rs
浏览文件 @
acf33f2d
...
...
@@ -126,6 +126,8 @@
[
few
]
hir_forest
:
rustc
::
hir
::
map
::
Forest
<
$tcx
>
,
[]
attribute
:
syntax
::
ast
::
Attribute
,
[]
global_asm
:
rustc
::
hir
::
GlobalAsm
,
[]
fn_decl
:
rustc
::
hir
::
FnDecl
,
[]
foreign_item
:
rustc
::
hir
::
ForeignItem
<
$tcx
>
,
[]
impl_item_ref
:
rustc
::
hir
::
ImplItemRef
,
[]
macro_def
:
rustc
::
hir
::
MacroDef
<
$tcx
>
,
[]
path
:
rustc
::
hir
::
Path
,
...
...
src/librustc/hir/check_attr.rs
浏览文件 @
acf33f2d
...
...
@@ -120,7 +120,7 @@ fn from_trait_item(trait_item: &TraitItem) -> Target {
}
}
fn
from_foreign_item
(
foreign_item
:
&
hir
::
ForeignItem
)
->
Target
{
fn
from_foreign_item
(
foreign_item
:
&
hir
::
ForeignItem
<
'_
>
)
->
Target
{
match
foreign_item
.kind
{
hir
::
ForeignItemKind
::
Fn
(
..
)
=>
Target
::
ForeignFn
,
hir
::
ForeignItemKind
::
Static
(
..
)
=>
Target
::
ForeignStatic
,
...
...
@@ -504,7 +504,7 @@ fn visit_trait_item(&mut self, trait_item: &'tcx TraitItem) {
intravisit
::
walk_trait_item
(
self
,
trait_item
)
}
fn
visit_foreign_item
(
&
mut
self
,
f_item
:
&
'tcx
hir
::
ForeignItem
)
{
fn
visit_foreign_item
(
&
mut
self
,
f_item
:
&
'tcx
hir
::
ForeignItem
<
'tcx
>
)
{
let
target
=
Target
::
from_foreign_item
(
f_item
);
self
.check_attributes
(
f_item
.hir_id
,
&
f_item
.attrs
,
&
f_item
.span
,
target
,
None
);
intravisit
::
walk_foreign_item
(
self
,
f_item
)
...
...
src/librustc/hir/intravisit.rs
浏览文件 @
acf33f2d
...
...
@@ -250,7 +250,7 @@ fn visit_ident(&mut self, ident: Ident) {
fn
visit_mod
(
&
mut
self
,
m
:
&
'v
Mod
,
_
s
:
Span
,
n
:
HirId
)
{
walk_mod
(
self
,
m
,
n
)
}
fn
visit_foreign_item
(
&
mut
self
,
i
:
&
'v
ForeignItem
)
{
fn
visit_foreign_item
(
&
mut
self
,
i
:
&
'v
ForeignItem
<
'v
>
)
{
walk_foreign_item
(
self
,
i
)
}
fn
visit_local
(
&
mut
self
,
l
:
&
'v
Local
)
{
...
...
@@ -498,7 +498,7 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) {
}
ItemKind
::
ForeignMod
(
ref
foreign_module
)
=>
{
visitor
.visit_id
(
item
.hir_id
);
walk_list!
(
visitor
,
visit_foreign_item
,
&
foreign_module
.items
);
walk_list!
(
visitor
,
visit_foreign_item
,
foreign_module
.items
);
}
ItemKind
::
GlobalAsm
(
_
)
=>
{
visitor
.visit_id
(
item
.hir_id
);
...
...
@@ -735,13 +735,13 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
}
}
pub
fn
walk_foreign_item
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
foreign_item
:
&
'v
ForeignItem
)
{
pub
fn
walk_foreign_item
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
foreign_item
:
&
'v
ForeignItem
<
'v
>
)
{
visitor
.visit_id
(
foreign_item
.hir_id
);
visitor
.visit_vis
(
&
foreign_item
.vis
);
visitor
.visit_ident
(
foreign_item
.ident
);
match
foreign_item
.kind
{
ForeignItemKind
::
Fn
(
ref
function_declaration
,
ref
param_names
,
ref
generics
)
=>
{
ForeignItemKind
::
Fn
(
ref
function_declaration
,
param_names
,
ref
generics
)
=>
{
visitor
.visit_generics
(
generics
);
visitor
.visit_fn_decl
(
function_declaration
);
for
&
param_name
in
param_names
{
...
...
@@ -752,7 +752,7 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(visitor: &mut V, foreign_item: &'v
ForeignItemKind
::
Type
=>
(),
}
walk_list!
(
visitor
,
visit_attribute
,
&
foreign_item
.attrs
);
walk_list!
(
visitor
,
visit_attribute
,
foreign_item
.attrs
);
}
pub
fn
walk_param_bound
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
bound
:
&
'v
GenericBound
)
{
...
...
src/librustc/hir/lowering/item.rs
浏览文件 @
acf33f2d
...
...
@@ -706,12 +706,12 @@ fn rebuild_vis(&mut self, vis: &hir::Visibility) -> hir::Visibility {
respan
(
vis
.span
,
vis_kind
)
}
fn
lower_foreign_item
(
&
mut
self
,
i
:
&
ForeignItem
)
->
hir
::
ForeignItem
{
fn
lower_foreign_item
(
&
mut
self
,
i
:
&
ForeignItem
)
->
hir
::
ForeignItem
<
'hir
>
{
let
def_id
=
self
.resolver
.definitions
()
.local_def_id
(
i
.id
);
hir
::
ForeignItem
{
hir_id
:
self
.lower_node_id
(
i
.id
),
ident
:
i
.ident
,
attrs
:
self
.lower_attrs
(
&
i
.attrs
),
attrs
:
self
.lower_attrs
_arena
(
&
i
.attrs
),
kind
:
match
i
.kind
{
ForeignItemKind
::
Fn
(
ref
fdec
,
ref
generics
)
=>
{
let
(
generics
,
(
fn_dec
,
fn_args
))
=
self
.add_in_band_defs
(
...
...
@@ -726,12 +726,14 @@ fn lower_foreign_item(&mut self, i: &ForeignItem) -> hir::ForeignItem {
)
},
);
let
fn_dec
=
self
.arena
.alloc
(
fn_dec
.into_inner
());
let
fn_args
=
self
.arena
.alloc_from_iter
(
fn_args
.into_iter
());
hir
::
ForeignItemKind
::
Fn
(
fn_dec
,
fn_args
,
generics
)
}
ForeignItemKind
::
Static
(
ref
t
,
m
)
=>
{
hir
::
ForeignItemKind
::
Static
(
self
.
lower_ty
(
t
,
ImplTraitContext
::
disallowed
()),
m
)
self
.
arena
.alloc
(
self
.lower_ty
(
t
,
ImplTraitContext
::
disallowed
())
.into_inner
()),
m
)
}
ForeignItemKind
::
Ty
=>
hir
::
ForeignItemKind
::
Type
,
ForeignItemKind
::
Macro
(
_
)
=>
panic!
(
"macro shouldn't exist here"
),
...
...
@@ -741,13 +743,12 @@ fn lower_foreign_item(&mut self, i: &ForeignItem) -> hir::ForeignItem {
}
}
fn
lower_foreign_mod
(
&
mut
self
,
fm
:
&
ForeignMod
)
->
hir
::
ForeignMod
{
fn
lower_foreign_mod
(
&
mut
self
,
fm
:
&
ForeignMod
)
->
hir
::
ForeignMod
<
'hir
>
{
hir
::
ForeignMod
{
abi
:
fm
.abi
.map_or
(
abi
::
Abi
::
C
,
|
abi
|
self
.lower_abi
(
abi
)),
items
:
fm
.items
items
:
self
.arena
.alloc_from_iter
(
fm
.items
.iter
()
.map
(|
x
|
self
.lower_foreign_item
(
x
))
.collect
(),
.map
(|
x
|
self
.lower_foreign_item
(
x
))),
}
}
...
...
src/librustc/hir/map/collector.rs
浏览文件 @
acf33f2d
...
...
@@ -385,7 +385,7 @@ fn visit_item(&mut self, i: &'hir Item<'hir>) {
});
}
fn
visit_foreign_item
(
&
mut
self
,
foreign_item
:
&
'hir
ForeignItem
)
{
fn
visit_foreign_item
(
&
mut
self
,
foreign_item
:
&
'hir
ForeignItem
<
'hir
>
)
{
self
.insert
(
foreign_item
.span
,
foreign_item
.hir_id
,
Node
::
ForeignItem
(
foreign_item
));
self
.with_parent
(
foreign_item
.hir_id
,
|
this
|
{
...
...
src/librustc/hir/map/mod.rs
浏览文件 @
acf33f2d
...
...
@@ -1002,7 +1002,7 @@ pub fn expect_variant(&self, id: HirId) -> &'hir Variant {
}
}
pub
fn
expect_foreign_item
(
&
self
,
id
:
HirId
)
->
&
'hir
ForeignItem
{
pub
fn
expect_foreign_item
(
&
self
,
id
:
HirId
)
->
&
'hir
ForeignItem
<
'hir
>
{
match
self
.find
(
id
)
{
Some
(
Node
::
ForeignItem
(
item
))
=>
item
,
_
=>
bug!
(
"expected foreign item, found {}"
,
self
.node_to_string
(
id
))
...
...
@@ -1249,7 +1249,7 @@ trait Named {
impl
<
T
:
Named
>
Named
for
Spanned
<
T
>
{
fn
name
(
&
self
)
->
Name
{
self
.node
.name
()
}
}
impl
Named
for
Item
<
'_
>
{
fn
name
(
&
self
)
->
Name
{
self
.ident.name
}
}
impl
Named
for
ForeignItem
{
fn
name
(
&
self
)
->
Name
{
self
.ident.name
}
}
impl
Named
for
ForeignItem
<
'_
>
{
fn
name
(
&
self
)
->
Name
{
self
.ident.name
}
}
impl
Named
for
Variant
{
fn
name
(
&
self
)
->
Name
{
self
.ident.name
}
}
impl
Named
for
StructField
{
fn
name
(
&
self
)
->
Name
{
self
.ident.name
}
}
impl
Named
for
TraitItem
{
fn
name
(
&
self
)
->
Name
{
self
.ident.name
}
}
...
...
src/librustc/hir/mod.rs
浏览文件 @
acf33f2d
...
...
@@ -2252,9 +2252,9 @@ pub struct Mod {
}
#[derive(RustcEncodable,
RustcDecodable,
Debug,
HashStable)]
pub
struct
ForeignMod
{
pub
struct
ForeignMod
<
'hir
>
{
pub
abi
:
Abi
,
pub
items
:
HirVec
<
ForeignItem
>
,
pub
items
:
&
'hir
[
ForeignItem
<
'hir
>
]
,
}
#[derive(RustcEncodable,
RustcDecodable,
Debug,
HashStable)]
...
...
@@ -2491,7 +2491,7 @@ pub enum ItemKind<'hir> {
/// A module.
Mod
(
Mod
),
/// An external module, e.g. `extern { .. }`.
ForeignMod
(
ForeignMod
),
ForeignMod
(
ForeignMod
<
'hir
>
),
/// Module-level inline assembly (from `global_asm!`).
GlobalAsm
(
&
'hir
GlobalAsm
),
/// A type alias, e.g., `type Foo = Bar<u8>`.
...
...
@@ -2607,11 +2607,11 @@ pub enum AssocItemKind {
}
#[derive(RustcEncodable,
RustcDecodable,
Debug,
HashStable)]
pub
struct
ForeignItem
{
pub
struct
ForeignItem
<
'hir
>
{
#[stable_hasher(project(name))]
pub
ident
:
Ident
,
pub
attrs
:
HirVec
<
Attribute
>
,
pub
kind
:
ForeignItemKind
,
pub
attrs
:
&
'hir
[
Attribute
]
,
pub
kind
:
ForeignItemKind
<
'hir
>
,
pub
hir_id
:
HirId
,
pub
span
:
Span
,
pub
vis
:
Visibility
,
...
...
@@ -2619,16 +2619,16 @@ pub struct ForeignItem {
/// An item within an `extern` block.
#[derive(RustcEncodable,
RustcDecodable,
Debug,
HashStable)]
pub
enum
ForeignItemKind
{
pub
enum
ForeignItemKind
<
'hir
>
{
/// A foreign function.
Fn
(
P
<
FnDecl
>
,
HirVec
<
Ident
>
,
Generics
),
Fn
(
&
'hir
FnDecl
,
&
'hir
[
Ident
]
,
Generics
),
/// A foreign static item (`static ext: u8`).
Static
(
P
<
Ty
>
,
Mutability
),
Static
(
&
'hir
Ty
,
Mutability
),
/// A foreign type.
Type
,
}
impl
ForeignItemKind
{
impl
ForeignItemKind
<
'hir
>
{
pub
fn
descriptive_variant
(
&
self
)
->
&
str
{
match
*
self
{
ForeignItemKind
::
Fn
(
..
)
=>
"foreign function"
,
...
...
@@ -2788,7 +2788,7 @@ pub fn contains_extern_indicator(&self) -> bool {
pub
enum
Node
<
'hir
>
{
Param
(
&
'hir
Param
),
Item
(
&
'hir
Item
<
'hir
>
),
ForeignItem
(
&
'hir
ForeignItem
),
ForeignItem
(
&
'hir
ForeignItem
<
'hir
>
),
TraitItem
(
&
'hir
TraitItem
),
ImplItem
(
&
'hir
ImplItem
),
Variant
(
&
'hir
Variant
),
...
...
src/librustc/hir/print.rs
浏览文件 @
acf33f2d
...
...
@@ -267,11 +267,11 @@ pub fn print_mod(&mut self, _mod: &hir::Mod, attrs: &[ast::Attribute]) {
}
pub
fn
print_foreign_mod
(
&
mut
self
,
nmod
:
&
hir
::
ForeignMod
,
nmod
:
&
hir
::
ForeignMod
<
'_
>
,
attrs
:
&
[
ast
::
Attribute
])
{
self
.print_inner_attributes
(
attrs
);
for
item
in
&
nmod
.items
{
for
item
in
nmod
.items
{
self
.print_foreign_item
(
item
);
}
}
...
...
@@ -361,7 +361,7 @@ pub fn print_type(&mut self, ty: &hir::Ty) {
self
.end
()
}
pub
fn
print_foreign_item
(
&
mut
self
,
item
:
&
hir
::
ForeignItem
)
{
pub
fn
print_foreign_item
(
&
mut
self
,
item
:
&
hir
::
ForeignItem
<
'_
>
)
{
self
.hardbreak_if_not_bol
();
self
.maybe_print_comment
(
item
.span
.lo
());
self
.print_outer_attributes
(
&
item
.attrs
);
...
...
src/librustc/lint/context.rs
浏览文件 @
acf33f2d
...
...
@@ -943,7 +943,7 @@ fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) {
self
.context.generics
=
generics
;
}
fn
visit_foreign_item
(
&
mut
self
,
it
:
&
'tcx
hir
::
ForeignItem
)
{
fn
visit_foreign_item
(
&
mut
self
,
it
:
&
'tcx
hir
::
ForeignItem
<
'tcx
>
)
{
self
.with_lint_attrs
(
it
.hir_id
,
&
it
.attrs
,
|
cx
|
{
cx
.with_param_env
(
it
.hir_id
,
|
cx
|
{
lint_callback!
(
cx
,
check_foreign_item
,
it
);
...
...
src/librustc/lint/mod.rs
浏览文件 @
acf33f2d
...
...
@@ -94,8 +94,8 @@ pub fn get_lints() -> LintArray { $crate::lint_array!($($lint),*) }
fn
check_crate_post
(
a
:
&
$hir
hir
::
Crate
<
$hir
>
);
fn
check_mod
(
a
:
&
$hir
hir
::
Mod
,
b
:
Span
,
c
:
hir
::
HirId
);
fn
check_mod_post
(
a
:
&
$hir
hir
::
Mod
,
b
:
Span
,
c
:
hir
::
HirId
);
fn
check_foreign_item
(
a
:
&
$hir
hir
::
ForeignItem
);
fn
check_foreign_item_post
(
a
:
&
$hir
hir
::
ForeignItem
);
fn
check_foreign_item
(
a
:
&
$hir
hir
::
ForeignItem
<
$hir
>
);
fn
check_foreign_item_post
(
a
:
&
$hir
hir
::
ForeignItem
<
$hir
>
);
fn
check_item
(
a
:
&
$hir
hir
::
Item
<
$hir
>
);
fn
check_item_post
(
a
:
&
$hir
hir
::
Item
<
$hir
>
);
fn
check_local
(
a
:
&
$hir
hir
::
Local
);
...
...
@@ -610,7 +610,7 @@ fn visit_item(&mut self, it: &'tcx hir::Item<'tcx>) {
});
}
fn
visit_foreign_item
(
&
mut
self
,
it
:
&
'tcx
hir
::
ForeignItem
)
{
fn
visit_foreign_item
(
&
mut
self
,
it
:
&
'tcx
hir
::
ForeignItem
<
'tcx
>
)
{
self
.with_lint_attrs
(
it
.hir_id
,
&
it
.attrs
,
|
builder
|
{
intravisit
::
walk_foreign_item
(
builder
,
it
);
})
...
...
src/librustc/middle/resolve_lifetime.rs
浏览文件 @
acf33f2d
...
...
@@ -536,7 +536,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
}
}
fn
visit_foreign_item
(
&
mut
self
,
item
:
&
'tcx
hir
::
ForeignItem
)
{
fn
visit_foreign_item
(
&
mut
self
,
item
:
&
'tcx
hir
::
ForeignItem
<
'tcx
>
)
{
match
item
.kind
{
hir
::
ForeignItemKind
::
Fn
(
ref
decl
,
_
,
ref
generics
)
=>
{
self
.visit_early_late
(
None
,
decl
,
generics
,
|
this
|
{
...
...
src/librustc/middle/stability.rs
浏览文件 @
acf33f2d
...
...
@@ -318,7 +318,7 @@ fn visit_struct_field(&mut self, s: &'tcx StructField) {
});
}
fn
visit_foreign_item
(
&
mut
self
,
i
:
&
'tcx
hir
::
ForeignItem
)
{
fn
visit_foreign_item
(
&
mut
self
,
i
:
&
'tcx
hir
::
ForeignItem
<
'tcx
>
)
{
self
.annotate
(
i
.hir_id
,
&
i
.attrs
,
i
.span
,
AnnotationKind
::
Required
,
|
v
|
{
intravisit
::
walk_foreign_item
(
v
,
i
);
});
...
...
@@ -392,7 +392,7 @@ fn visit_struct_field(&mut self, s: &'tcx StructField) {
intravisit
::
walk_struct_field
(
self
,
s
);
}
fn
visit_foreign_item
(
&
mut
self
,
i
:
&
'tcx
hir
::
ForeignItem
)
{
fn
visit_foreign_item
(
&
mut
self
,
i
:
&
'tcx
hir
::
ForeignItem
<
'tcx
>
)
{
self
.check_missing_stability
(
i
.hir_id
,
i
.span
,
i
.kind
.descriptive_variant
());
intravisit
::
walk_foreign_item
(
self
,
i
);
}
...
...
src/librustc/middle/weak_lang_items.rs
浏览文件 @
acf33f2d
...
...
@@ -136,7 +136,7 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'v> {
NestedVisitorMap
::
None
}
fn
visit_foreign_item
(
&
mut
self
,
i
:
&
hir
::
ForeignItem
)
{
fn
visit_foreign_item
(
&
mut
self
,
i
:
&
hir
::
ForeignItem
<
'_
>
)
{
if
let
Some
((
lang_item
,
_
))
=
lang_items
::
extract
(
&
i
.attrs
)
{
self
.register
(
lang_item
,
i
.span
);
}
...
...
src/librustc_lint/builtin.rs
浏览文件 @
acf33f2d
...
...
@@ -996,7 +996,7 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item<'_>) {
self
.perform_lint
(
cx
,
"item"
,
item
.hir_id
,
&
item
.vis
,
item
.span
,
true
);
}
fn
check_foreign_item
(
&
mut
self
,
cx
:
&
LateContext
<
'_
,
'_
>
,
foreign_item
:
&
hir
::
ForeignItem
)
{
fn
check_foreign_item
(
&
mut
self
,
cx
:
&
LateContext
<
'_
,
'_
>
,
foreign_item
:
&
hir
::
ForeignItem
<
'tcx
>
)
{
self
.perform_lint
(
cx
,
"item"
,
foreign_item
.hir_id
,
&
foreign_item
.vis
,
foreign_item
.span
,
true
);
}
...
...
src/librustc_lint/types.rs
浏览文件 @
acf33f2d
...
...
@@ -1009,7 +1009,7 @@ fn check_foreign_static(&mut self, id: hir::HirId, span: Span) {
}
impl
<
'a
,
'tcx
>
LateLintPass
<
'a
,
'tcx
>
for
ImproperCTypes
{
fn
check_foreign_item
(
&
mut
self
,
cx
:
&
LateContext
<
'_
,
'_
>
,
it
:
&
hir
::
ForeignItem
)
{
fn
check_foreign_item
(
&
mut
self
,
cx
:
&
LateContext
<
'_
,
'_
>
,
it
:
&
hir
::
ForeignItem
<
'_
>
)
{
let
mut
vis
=
ImproperCTypesVisitor
{
cx
};
let
abi
=
cx
.tcx
.hir
()
.get_foreign_abi
(
it
.hir_id
);
if
let
Abi
::
Rust
|
Abi
::
RustCall
|
Abi
::
RustIntrinsic
|
Abi
::
PlatformIntrinsic
=
abi
{
...
...
src/librustc_metadata/rmeta/encoder.rs
浏览文件 @
acf33f2d
...
...
@@ -1525,7 +1525,7 @@ fn encode_dylib_dependency_formats(&mut self) -> Lazy<[Option<LinkagePreference>
fn
encode_info_for_foreign_item
(
&
mut
self
,
def_id
:
DefId
,
nitem
:
&
hir
::
ForeignItem
,
nitem
:
&
hir
::
ForeignItem
<
'_
>
,
)
{
let
tcx
=
self
.tcx
;
...
...
@@ -1551,7 +1551,7 @@ fn encode_info_for_foreign_item(
record!
(
self
.per_def.visibility
[
def_id
]
<-
ty
::
Visibility
::
from_hir
(
&
nitem
.vis
,
nitem
.hir_id
,
self
.tcx
));
record!
(
self
.per_def.span
[
def_id
]
<-
nitem
.span
);
record!
(
self
.per_def.attributes
[
def_id
]
<-
&
nitem
.attrs
);
record!
(
self
.per_def.attributes
[
def_id
]
<-
nitem
.attrs
);
self
.encode_stability
(
def_id
);
self
.encode_const_stability
(
def_id
);
self
.encode_deprecation
(
def_id
);
...
...
@@ -1590,7 +1590,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
}
self
.encode_addl_info_for_item
(
item
);
}
fn
visit_foreign_item
(
&
mut
self
,
ni
:
&
'tcx
hir
::
ForeignItem
)
{
fn
visit_foreign_item
(
&
mut
self
,
ni
:
&
'tcx
hir
::
ForeignItem
<
'tcx
>
)
{
intravisit
::
walk_foreign_item
(
self
,
ni
);
let
def_id
=
self
.tcx
.hir
()
.local_def_id
(
ni
.hir_id
);
self
.encode_info_for_foreign_item
(
def_id
,
ni
);
...
...
src/librustc_passes/dead.rs
浏览文件 @
acf33f2d
...
...
@@ -510,7 +510,7 @@ fn should_warn_about_variant(&mut self, variant: &hir::Variant) -> bool {
&
variant
.attrs
)
}
fn
should_warn_about_foreign_item
(
&
mut
self
,
fi
:
&
hir
::
ForeignItem
)
->
bool
{
fn
should_warn_about_foreign_item
(
&
mut
self
,
fi
:
&
hir
::
ForeignItem
<
'_
>
)
->
bool
{
!
self
.symbol_is_live
(
fi
.hir_id
)
&&
!
has_allow_dead_code_or_lang_attr
(
self
.tcx
,
fi
.hir_id
,
&
fi
.attrs
)
}
...
...
@@ -621,7 +621,7 @@ fn visit_variant(&mut self,
}
}
fn
visit_foreign_item
(
&
mut
self
,
fi
:
&
'tcx
hir
::
ForeignItem
)
{
fn
visit_foreign_item
(
&
mut
self
,
fi
:
&
'tcx
hir
::
ForeignItem
<
'tcx
>
)
{
if
self
.should_warn_about_foreign_item
(
fi
)
{
self
.warn_dead_code
(
fi
.hir_id
,
fi
.span
,
fi
.ident.name
,
fi
.kind
.descriptive_variant
(),
"used"
);
...
...
src/librustc_passes/hir_stats.rs
浏览文件 @
acf33f2d
...
...
@@ -133,7 +133,7 @@ fn visit_mod(&mut self, m: &'v hir::Mod, _s: Span, n: hir::HirId) {
hir_visit
::
walk_mod
(
self
,
m
,
n
)
}
fn
visit_foreign_item
(
&
mut
self
,
i
:
&
'v
hir
::
ForeignItem
)
{
fn
visit_foreign_item
(
&
mut
self
,
i
:
&
'v
hir
::
ForeignItem
<
'v
>
)
{
self
.record
(
"ForeignItem"
,
Id
::
Node
(
i
.hir_id
),
i
);
hir_visit
::
walk_foreign_item
(
self
,
i
)
}
...
...
src/librustc_privacy/lib.rs
浏览文件 @
acf33f2d
...
...
@@ -708,7 +708,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
}
}
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
()
{
self
.update
(
foreign_item
.hir_id
,
item_level
);
}
...
...
@@ -812,7 +812,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
}
// Visit everything, but foreign items have their own levels.
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
);
if
foreign_item_level
.is_some
()
{
self
.reach
(
foreign_item
.hir_id
,
foreign_item_level
)
...
...
@@ -1621,7 +1621,7 @@ fn visit_generics(&mut self, generics: &'tcx hir::Generics) {
}
}
fn
visit_foreign_item
(
&
mut
self
,
item
:
&
'tcx
hir
::
ForeignItem
)
{
fn
visit_foreign_item
(
&
mut
self
,
item
:
&
'tcx
hir
::
ForeignItem
<
'tcx
>
)
{
if
self
.access_levels
.is_reachable
(
item
.hir_id
)
{
intravisit
::
walk_foreign_item
(
self
,
item
)
}
...
...
@@ -1898,7 +1898,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
}
// Subitems of foreign modules have their own publicity.
hir
::
ItemKind
::
ForeignMod
(
ref
foreign_mod
)
=>
{
for
foreign_item
in
&
foreign_mod
.items
{
for
foreign_item
in
foreign_mod
.items
{
let
vis
=
ty
::
Visibility
::
from_hir
(
&
foreign_item
.vis
,
item
.hir_id
,
tcx
);
self
.check
(
foreign_item
.hir_id
,
vis
)
.generics
()
.predicates
()
.ty
();
}
...
...
src/librustc_typeck/check/intrinsic.rs
浏览文件 @
acf33f2d
...
...
@@ -17,7 +17,7 @@
fn
equate_intrinsic_type
<
'tcx
>
(
tcx
:
TyCtxt
<
'tcx
>
,
it
:
&
hir
::
ForeignItem
,
it
:
&
hir
::
ForeignItem
<
'_
>
,
n_tps
:
usize
,
abi
:
Abi
,
safety
:
hir
::
Unsafety
,
...
...
@@ -83,7 +83,7 @@ pub fn intrinsic_operation_unsafety(intrinsic: &str) -> hir::Unsafety {
/// Remember to add all intrinsics here, in librustc_codegen_llvm/intrinsic.rs,
/// and in libcore/intrinsics.rs
pub
fn
check_intrinsic_type
(
tcx
:
TyCtxt
<
'_
>
,
it
:
&
hir
::
ForeignItem
)
{
pub
fn
check_intrinsic_type
(
tcx
:
TyCtxt
<
'_
>
,
it
:
&
hir
::
ForeignItem
<
'_
>
)
{
let
param
=
|
n
|
tcx
.mk_ty_param
(
n
,
Symbol
::
intern
(
&
format!
(
"P{}"
,
n
)));
let
name
=
it
.ident
.as_str
();
...
...
@@ -399,7 +399,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem) {
}
/// Type-check `extern "platform-intrinsic" { ... }` functions.
pub
fn
check_platform_intrinsic_type
(
tcx
:
TyCtxt
<
'_
>
,
it
:
&
hir
::
ForeignItem
)
{
pub
fn
check_platform_intrinsic_type
(
tcx
:
TyCtxt
<
'_
>
,
it
:
&
hir
::
ForeignItem
<
'_
>
)
{
let
param
=
|
n
|
{
let
name
=
Symbol
::
intern
(
&
format!
(
"P{}"
,
n
));
tcx
.mk_ty_param
(
n
,
name
)
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
acf33f2d
...
...
@@ -1766,15 +1766,15 @@ pub fn check_item_type<'tcx>(tcx: TyCtxt<'tcx>, it: &'tcx hir::Item<'tcx>) {
check_abi
(
tcx
,
it
.span
,
m
.abi
);
if
m
.abi
==
Abi
::
RustIntrinsic
{
for
item
in
&
m
.items
{
for
item
in
m
.items
{
intrinsic
::
check_intrinsic_type
(
tcx
,
item
);
}
}
else
if
m
.abi
==
Abi
::
PlatformIntrinsic
{
for
item
in
&
m
.items
{
for
item
in
m
.items
{
intrinsic
::
check_platform_intrinsic_type
(
tcx
,
item
);
}
}
else
{
for
item
in
&
m
.items
{
for
item
in
m
.items
{
let
generics
=
tcx
.generics_of
(
tcx
.hir
()
.local_def_id
(
item
.hir_id
));
let
own_counts
=
generics
.own_counts
();
if
generics
.params
.len
()
-
own_counts
.lifetimes
!=
0
{
...
...
@@ -4689,7 +4689,13 @@ fn suggest_fn_call(
Some
(
Node
::
ForeignItem
(
hir
::
ForeignItem
{
kind
:
hir
::
ForeignItemKind
::
Fn
(
_
,
idents
,
_
),
..
}))
|
}))
=>
sugg_call
=
idents
.iter
()
.map
(|
ident
|
if
ident
.name
!=
kw
::
SelfLower
{
ident
.to_string
()
}
else
{
"_"
.to_string
()
})
.collect
::
<
Vec
<
_
>>
()
.join
(
", "
),
Some
(
Node
::
TraitItem
(
hir
::
TraitItem
{
kind
:
hir
::
TraitItemKind
::
Method
(
..
,
hir
::
TraitMethod
::
Required
(
idents
)),
..
...
...
src/librustc_typeck/collect.rs
浏览文件 @
acf33f2d
...
...
@@ -417,7 +417,7 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::HirId) {
|
hir
::
ItemKind
::
Mod
(
_
)
|
hir
::
ItemKind
::
GlobalAsm
(
_
)
=>
{}
hir
::
ItemKind
::
ForeignMod
(
ref
foreign_mod
)
=>
{
for
item
in
&
foreign_mod
.items
{
for
item
in
foreign_mod
.items
{
let
def_id
=
tcx
.hir
()
.local_def_id
(
item
.hir_id
);
tcx
.generics_of
(
def_id
);
tcx
.type_of
(
def_id
);
...
...
src/librustc_typeck/variance/constraints.rs
浏览文件 @
acf33f2d
...
...
@@ -93,7 +93,7 @@ fn visit_item(&mut self, item: &hir::Item<'_>) {
}
hir
::
ItemKind
::
ForeignMod
(
ref
foreign_mod
)
=>
{
for
foreign_item
in
&
foreign_mod
.items
{
for
foreign_item
in
foreign_mod
.items
{
if
let
hir
::
ForeignItemKind
::
Fn
(
..
)
=
foreign_item
.kind
{
self
.visit_node_helper
(
foreign_item
.hir_id
);
}
...
...
src/librustc_typeck/variance/terms.rs
浏览文件 @
acf33f2d
...
...
@@ -156,7 +156,7 @@ fn visit_item(&mut self, item: &hir::Item<'_>) {
}
hir
::
ItemKind
::
ForeignMod
(
ref
foreign_mod
)
=>
{
for
foreign_item
in
&
foreign_mod
.items
{
for
foreign_item
in
foreign_mod
.items
{
if
let
hir
::
ForeignItemKind
::
Fn
(
..
)
=
foreign_item
.kind
{
self
.add_inferreds_for_item
(
foreign_item
.hir_id
);
}
...
...
src/librustdoc/doctree.rs
浏览文件 @
acf33f2d
...
...
@@ -217,7 +217,7 @@ pub struct ForeignItem<'hir> {
pub
vis
:
&
'hir
hir
::
Visibility
,
pub
id
:
hir
::
HirId
,
pub
name
:
Name
,
pub
kind
:
&
'hir
hir
::
ForeignItemKind
,
pub
kind
:
&
'hir
hir
::
ForeignItemKind
<
'hir
>
,
pub
attrs
:
&
'hir
[
ast
::
Attribute
],
pub
whence
:
Span
,
}
...
...
src/librustdoc/visit_ast.rs
浏览文件 @
acf33f2d
...
...
@@ -363,7 +363,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item,
match
item
.kind
{
hir
::
ItemKind
::
ForeignMod
(
ref
fm
)
=>
{
for
item
in
&
fm
.items
{
for
item
in
fm
.items
{
self
.visit_foreign_item
(
item
,
None
,
om
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录