Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
83516670
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,发现更多精彩内容 >>
提交
83516670
编写于
1月 07, 2020
作者:
M
Mazdak Farrokhzad
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
intravisit: abstract over HIR Map
上级
62e9ccbe
变更
41
隐藏空白更改
内联
并排
Showing
41 changed file
with
258 addition
and
89 deletion
+258
-89
src/librustc/hir/check_attr.rs
src/librustc/hir/check_attr.rs
+4
-1
src/librustc/hir/intravisit.rs
src/librustc/hir/intravisit.rs
+21
-21
src/librustc/hir/map/collector.rs
src/librustc/hir/map/collector.rs
+4
-2
src/librustc/hir/map/hir_id_validator.rs
src/librustc/hir/map/hir_id_validator.rs
+3
-1
src/librustc/hir/map/mod.rs
src/librustc/hir/map/mod.rs
+18
-0
src/librustc/hir/upvars.rs
src/librustc/hir/upvars.rs
+7
-2
src/librustc/infer/error_reporting/need_type_info.rs
src/librustc/infer/error_reporting/need_type_info.rs
+3
-1
src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs
...infer/error_reporting/nice_region_error/find_anon_type.rs
+7
-2
src/librustc/middle/weak_lang_items.rs
src/librustc/middle/weak_lang_items.rs
+4
-1
src/librustc_ast_lowering/lib.rs
src/librustc_ast_lowering/lib.rs
+5
-2
src/librustc_incremental/assert_dep_graph.rs
src/librustc_incremental/assert_dep_graph.rs
+4
-1
src/librustc_incremental/persist/dirty_clean.rs
src/librustc_incremental/persist/dirty_clean.rs
+4
-1
src/librustc_lint/builtin.rs
src/librustc_lint/builtin.rs
+4
-1
src/librustc_lint/late.rs
src/librustc_lint/late.rs
+4
-1
src/librustc_lint/levels.rs
src/librustc_lint/levels.rs
+4
-1
src/librustc_metadata/rmeta/encoder.rs
src/librustc_metadata/rmeta/encoder.rs
+4
-1
src/librustc_mir/hair/pattern/check_match.rs
src/librustc_mir/hair/pattern/check_match.rs
+7
-2
src/librustc_mir/transform/check_unsafety.rs
src/librustc_mir/transform/check_unsafety.rs
+4
-1
src/librustc_mir/transform/mod.rs
src/librustc_mir/transform/mod.rs
+3
-1
src/librustc_passes/check_const.rs
src/librustc_passes/check_const.rs
+3
-1
src/librustc_passes/dead.rs
src/librustc_passes/dead.rs
+7
-2
src/librustc_passes/hir_stats.rs
src/librustc_passes/hir_stats.rs
+4
-1
src/librustc_passes/intrinsicck.rs
src/librustc_passes/intrinsicck.rs
+9
-5
src/librustc_passes/lib_features.rs
src/librustc_passes/lib_features.rs
+4
-1
src/librustc_passes/liveness.rs
src/librustc_passes/liveness.rs
+7
-2
src/librustc_passes/loops.rs
src/librustc_passes/loops.rs
+3
-1
src/librustc_passes/reachable.rs
src/librustc_passes/reachable.rs
+4
-1
src/librustc_passes/region.rs
src/librustc_passes/region.rs
+4
-1
src/librustc_passes/stability.rs
src/librustc_passes/stability.rs
+10
-3
src/librustc_privacy/lib.rs
src/librustc_privacy/lib.rs
+22
-7
src/librustc_resolve/lifetimes.rs
src/librustc_resolve/lifetimes.rs
+18
-6
src/librustc_traits/lowering/mod.rs
src/librustc_traits/lowering/mod.rs
+4
-1
src/librustc_typeck/check/compare_method.rs
src/librustc_typeck/check/compare_method.rs
+5
-3
src/librustc_typeck/check/generator_interior.rs
src/librustc_typeck/check/generator_interior.rs
+4
-1
src/librustc_typeck/check/method/suggest.rs
src/librustc_typeck/check/method/suggest.rs
+4
-1
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+4
-1
src/librustc_typeck/check/regionck.rs
src/librustc_typeck/check/regionck.rs
+4
-1
src/librustc_typeck/check/upvar.rs
src/librustc_typeck/check/upvar.rs
+4
-1
src/librustc_typeck/check/writeback.rs
src/librustc_typeck/check/writeback.rs
+4
-1
src/librustc_typeck/collect.rs
src/librustc_typeck/collect.rs
+13
-4
src/librustdoc/test.rs
src/librustdoc/test.rs
+3
-1
未找到文件。
src/librustc/hir/check_attr.rs
浏览文件 @
83516670
...
...
@@ -5,6 +5,7 @@
//! item.
use
crate
::
hir
::
intravisit
::{
self
,
NestedVisitorMap
,
Visitor
};
use
crate
::
hir
::
map
::
Map
;
use
crate
::
lint
::
builtin
::
UNUSED_ATTRIBUTES
;
use
crate
::
ty
::
query
::
Providers
;
use
crate
::
ty
::
TyCtxt
;
...
...
@@ -519,7 +520,9 @@ fn check_used(&self, attrs: &'hir [Attribute], target: Target) {
}
impl
Visitor
<
'tcx
>
for
CheckAttrVisitor
<
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
Self
::
Map
>
{
NestedVisitorMap
::
OnlyBodies
(
&
self
.tcx
.hir
())
}
...
...
src/librustc/hir/intravisit.rs
浏览文件 @
83516670
...
...
@@ -31,8 +31,6 @@
//! This order consistency is required in a few places in rustc, for
//! example generator inference, and possibly also HIR borrowck.
use
crate
::
hir
::
map
::
Map
;
use
rustc_hir
::
itemlikevisit
::{
ItemLikeVisitor
,
ParItemLikeVisitor
};
use
rustc_hir
::
*
;
use
rustc_span
::
Span
;
...
...
@@ -42,10 +40,7 @@ pub struct DeepVisitor<'v, V> {
visitor
:
&
'v
mut
V
,
}
impl
<
'v
,
'hir
,
V
>
DeepVisitor
<
'v
,
V
>
where
V
:
Visitor
<
'hir
>
+
'v
,
{
impl
<
'v
,
V
>
DeepVisitor
<
'v
,
V
>
{
pub
fn
new
(
base
:
&
'v
mut
V
)
->
Self
{
DeepVisitor
{
visitor
:
base
}
}
...
...
@@ -122,6 +117,14 @@ pub fn header(&self) -> Option<&FnHeader> {
}
}
/// An abstract representation of the HIR `rustc::hir::map::Map`.
pub
trait
Map
<
'hir
>
{
fn
body
(
&
self
,
id
:
BodyId
)
->
&
'hir
Body
<
'hir
>
;
fn
item
(
&
self
,
id
:
HirId
)
->
&
'hir
Item
<
'hir
>
;
fn
trait_item
(
&
self
,
id
:
TraitItemId
)
->
&
'hir
TraitItem
<
'hir
>
;
fn
impl_item
(
&
self
,
id
:
ImplItemId
)
->
&
'hir
ImplItem
<
'hir
>
;
}
/// Specifies what nested things a visitor wants to visit. The most
/// common choice is `OnlyBodies`, which will cause the visitor to
/// visit fn bodies for fns that it encounters, but skip over nested
...
...
@@ -129,7 +132,7 @@ pub fn header(&self) -> Option<&FnHeader> {
///
/// See the comments on `ItemLikeVisitor` for more details on the overall
/// visit strategy.
pub
enum
NestedVisitorMap
<
'this
,
'tcx
>
{
pub
enum
NestedVisitorMap
<
'this
,
M
>
{
/// Do not visit any nested things. When you add a new
/// "non-nested" thing, you will want to audit such uses to see if
/// they remain valid.
...
...
@@ -146,20 +149,20 @@ pub enum NestedVisitorMap<'this, 'tcx> {
/// to use `visit_all_item_likes()` as an outer loop,
/// and to have the visitor that visits the contents of each item
/// using this setting.
OnlyBodies
(
&
'this
M
ap
<
'tcx
>
),
OnlyBodies
(
&
'this
M
),
/// Visits all nested things, including item-likes.
///
/// **This is an unusual choice.** It is used when you want to
/// process everything within their lexical context. Typically you
/// kick off the visit by doing `walk_krate()`.
All
(
&
'this
M
ap
<
'tcx
>
),
All
(
&
'this
M
),
}
impl
<
'this
,
'tcx
>
NestedVisitorMap
<
'this
,
'tcx
>
{
impl
<
'this
,
M
>
NestedVisitorMap
<
'this
,
M
>
{
/// Returns the map to use for an "intra item-like" thing (if any).
/// E.g., function body.
fn
intra
(
self
)
->
Option
<&
'this
M
ap
<
'tcx
>
>
{
fn
intra
(
self
)
->
Option
<&
'this
M
>
{
match
self
{
NestedVisitorMap
::
None
=>
None
,
NestedVisitorMap
::
OnlyBodies
(
map
)
=>
Some
(
map
),
...
...
@@ -169,7 +172,7 @@ fn intra(self) -> Option<&'this Map<'tcx>> {
/// Returns the map to use for an "item-like" thing (if any).
/// E.g., item, impl-item.
fn
inter
(
self
)
->
Option
<&
'this
M
ap
<
'tcx
>
>
{
fn
inter
(
self
)
->
Option
<&
'this
M
>
{
match
self
{
NestedVisitorMap
::
None
=>
None
,
NestedVisitorMap
::
OnlyBodies
(
_
)
=>
None
,
...
...
@@ -195,6 +198,8 @@ fn inter(self) -> Option<&'this Map<'tcx>> {
/// to monitor future changes to `Visitor` in case a new method with a
/// new default implementation gets introduced.)
pub
trait
Visitor
<
'v
>
:
Sized
{
type
Map
:
Map
<
'v
>
;
///////////////////////////////////////////////////////////////////////////
// Nested items.
...
...
@@ -214,7 +219,7 @@ pub trait Visitor<'v>: Sized {
/// `panic!()`. This way, if a new `visit_nested_XXX` variant is
/// added in the future, we will see the panic in your code and
/// fix it appropriately.
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
'v
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
;
/// Invoked when a nested item is encountered. By default does
/// nothing unless you override `nested_visit_map` to return other than
...
...
@@ -496,21 +501,16 @@ pub fn walk_lifetime<'v, V: Visitor<'v>>(visitor: &mut V, lifetime: &'v Lifetime
}
}
pub
fn
walk_poly_trait_ref
<
'v
,
V
>
(
pub
fn
walk_poly_trait_ref
<
'v
,
V
:
Visitor
<
'v
>
>
(
visitor
:
&
mut
V
,
trait_ref
:
&
'v
PolyTraitRef
<
'v
>
,
_
modifier
:
TraitBoundModifier
,
)
where
V
:
Visitor
<
'v
>
,
{
)
{
walk_list!
(
visitor
,
visit_generic_param
,
trait_ref
.bound_generic_params
);
visitor
.visit_trait_ref
(
&
trait_ref
.trait_ref
);
}
pub
fn
walk_trait_ref
<
'v
,
V
>
(
visitor
:
&
mut
V
,
trait_ref
:
&
'v
TraitRef
<
'v
>
)
where
V
:
Visitor
<
'v
>
,
{
pub
fn
walk_trait_ref
<
'v
,
V
:
Visitor
<
'v
>>
(
visitor
:
&
mut
V
,
trait_ref
:
&
'v
TraitRef
<
'v
>
)
{
visitor
.visit_id
(
trait_ref
.hir_ref_id
);
visitor
.visit_path
(
&
trait_ref
.path
,
trait_ref
.hir_ref_id
)
}
...
...
src/librustc/hir/map/collector.rs
浏览文件 @
83516670
use
crate
::
dep_graph
::{
DepGraph
,
DepKind
,
DepNode
,
DepNodeIndex
};
use
crate
::
hir
::
intravisit
::{
self
,
NestedVisitorMap
,
Visitor
};
use
crate
::
hir
::
map
::
definitions
::{
self
,
DefPathHash
};
use
crate
::
hir
::
map
::{
Entry
,
HirEntryMap
};
use
crate
::
hir
::
map
::{
Entry
,
HirEntryMap
,
Map
};
use
crate
::
ich
::
StableHashingContext
;
use
crate
::
middle
::
cstore
::
CrateStore
;
use
rustc_data_structures
::
fingerprint
::
Fingerprint
;
...
...
@@ -336,11 +336,13 @@ fn with_dep_node_owner<
}
impl
<
'a
,
'hir
>
Visitor
<
'hir
>
for
NodeCollector
<
'a
,
'hir
>
{
type
Map
=
Map
<
'hir
>
;
/// Because we want to track parent items and so forth, enable
/// deep walking so that we walk nested items in the context of
/// their outer items.
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'hir
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
Self
::
Map
>
{
panic!
(
"`visit_nested_xxx` must be manually implemented in this visitor"
);
}
...
...
src/librustc/hir/map/hir_id_validator.rs
浏览文件 @
83516670
...
...
@@ -133,7 +133,9 @@ fn check<F: FnOnce(&mut HirIdValidator<'a, 'hir>)>(&mut self, hir_id: HirId, wal
}
impl
<
'a
,
'hir
>
intravisit
::
Visitor
<
'hir
>
for
HirIdValidator
<
'a
,
'hir
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
intravisit
::
NestedVisitorMap
<
'this
,
'hir
>
{
type
Map
=
Map
<
'hir
>
;
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
intravisit
::
NestedVisitorMap
<
'this
,
Self
::
Map
>
{
intravisit
::
NestedVisitorMap
::
OnlyBodies
(
self
.hir_map
)
}
...
...
src/librustc/hir/map/mod.rs
浏览文件 @
83516670
...
...
@@ -1093,6 +1093,24 @@ pub fn hir_to_pretty_string(&self, id: HirId) -> String {
}
}
impl
<
'hir
>
intravisit
::
Map
<
'hir
>
for
Map
<
'hir
>
{
fn
body
(
&
self
,
id
:
BodyId
)
->
&
'hir
Body
<
'hir
>
{
self
.body
(
id
)
}
fn
item
(
&
self
,
id
:
HirId
)
->
&
'hir
Item
<
'hir
>
{
self
.item
(
id
)
}
fn
trait_item
(
&
self
,
id
:
TraitItemId
)
->
&
'hir
TraitItem
<
'hir
>
{
self
.trait_item
(
id
)
}
fn
impl_item
(
&
self
,
id
:
ImplItemId
)
->
&
'hir
ImplItem
<
'hir
>
{
self
.impl_item
(
id
)
}
}
pub
struct
NodesMatchingSuffix
<
'a
>
{
map
:
&
'a
Map
<
'a
>
,
item_name
:
&
'a
String
,
...
...
src/librustc/hir/upvars.rs
浏览文件 @
83516670
//! Upvar (closure capture) collection from cross-body HIR uses of `Res::Local`s.
use
crate
::
hir
::
intravisit
::{
self
,
NestedVisitorMap
,
Visitor
};
use
crate
::
hir
::
map
::
Map
;
use
crate
::
ty
::
query
::
Providers
;
use
crate
::
ty
::
TyCtxt
;
use
rustc_data_structures
::
fx
::{
FxHashSet
,
FxIndexMap
};
...
...
@@ -43,7 +44,9 @@ struct LocalCollector {
}
impl
Visitor
<
'tcx
>
for
LocalCollector
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
Self
::
Map
>
{
NestedVisitorMap
::
None
}
...
...
@@ -70,7 +73,9 @@ fn visit_local_use(&mut self, var_id: HirId, span: Span) {
}
impl
Visitor
<
'tcx
>
for
CaptureCollector
<
'a
,
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
Self
::
Map
>
{
NestedVisitorMap
::
None
}
...
...
src/librustc/infer/error_reporting/need_type_info.rs
浏览文件 @
83516670
...
...
@@ -66,7 +66,9 @@ fn node_matches_type(&mut self, hir_id: HirId) -> Option<Ty<'tcx>> {
}
impl
<
'a
,
'tcx
>
Visitor
<
'tcx
>
for
FindLocalByTypeVisitor
<
'a
,
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
Self
::
Map
>
{
NestedVisitorMap
::
OnlyBodies
(
&
self
.hir_map
)
}
...
...
src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs
浏览文件 @
83516670
use
crate
::
hir
::
intravisit
::{
self
,
NestedVisitorMap
,
Visitor
};
use
crate
::
hir
::
map
::
Map
;
use
crate
::
infer
::
error_reporting
::
nice_region_error
::
NiceRegionError
;
use
crate
::
middle
::
resolve_lifetime
as
rl
;
use
crate
::
ty
::{
self
,
Region
,
TyCtxt
};
...
...
@@ -90,7 +91,9 @@ struct FindNestedTypeVisitor<'tcx> {
}
impl
Visitor
<
'tcx
>
for
FindNestedTypeVisitor
<
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
Self
::
Map
>
{
NestedVisitorMap
::
OnlyBodies
(
&
self
.tcx
.hir
())
}
...
...
@@ -207,7 +210,9 @@ struct TyPathVisitor<'tcx> {
}
impl
Visitor
<
'tcx
>
for
TyPathVisitor
<
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
Map
<
'tcx
>>
{
NestedVisitorMap
::
OnlyBodies
(
&
self
.tcx
.hir
())
}
...
...
src/librustc/middle/weak_lang_items.rs
浏览文件 @
83516670
...
...
@@ -5,6 +5,7 @@
use
crate
::
hir
::
intravisit
;
use
crate
::
hir
::
intravisit
::{
NestedVisitorMap
,
Visitor
};
use
crate
::
hir
::
map
::
Map
;
use
crate
::
ty
::
TyCtxt
;
use
errors
::
struct_span_err
;
use
rustc_data_structures
::
fx
::
FxHashSet
;
...
...
@@ -136,7 +137,9 @@ fn register(&mut self, name: Symbol, span: Span) {
}
impl
<
'a
,
'tcx
,
'v
>
Visitor
<
'v
>
for
Context
<
'a
,
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'v
>
{
type
Map
=
Map
<
'v
>
;
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
Map
<
'v
>>
{
NestedVisitorMap
::
None
}
...
...
src/librustc_ast_lowering/lib.rs
浏览文件 @
83516670
...
...
@@ -37,7 +37,8 @@
use
rustc
::
arena
::
Arena
;
use
rustc
::
dep_graph
::
DepGraph
;
use
rustc
::
hir
::
intravisit
;
use
rustc
::
hir
::
map
::{
DefKey
,
DefPathData
,
Definitions
};
use
rustc
::
hir
::
map
::
definitions
::{
DefKey
,
DefPathData
,
Definitions
};
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
lint
;
use
rustc
::
lint
::
builtin
::{
self
,
ELIDED_LIFETIMES_IN_PATHS
};
use
rustc
::
middle
::
cstore
::
CrateStore
;
...
...
@@ -1484,7 +1485,9 @@ struct ImplTraitLifetimeCollector<'r, 'a, 'hir> {
}
impl
<
'r
,
'a
,
'v
,
'hir
>
intravisit
::
Visitor
<
'v
>
for
ImplTraitLifetimeCollector
<
'r
,
'a
,
'hir
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
intravisit
::
NestedVisitorMap
<
'this
,
'v
>
{
type
Map
=
Map
<
'v
>
;
fn
nested_visit_map
(
&
mut
self
)
->
intravisit
::
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
intravisit
::
NestedVisitorMap
::
None
}
...
...
src/librustc_incremental/assert_dep_graph.rs
浏览文件 @
83516670
...
...
@@ -37,6 +37,7 @@
use
rustc
::
dep_graph
::
debug
::{
DepNodeFilter
,
EdgeFilter
};
use
rustc
::
dep_graph
::{
DepGraphQuery
,
DepKind
,
DepNode
};
use
rustc
::
hir
::
intravisit
::{
self
,
NestedVisitorMap
,
Visitor
};
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
ty
::
TyCtxt
;
use
rustc_data_structures
::
fx
::
FxHashSet
;
use
rustc_data_structures
::
graph
::
implementation
::{
Direction
,
NodeIndex
,
INCOMING
,
OUTGOING
};
...
...
@@ -159,7 +160,9 @@ fn process_attrs(&mut self, hir_id: hir::HirId, attrs: &[ast::Attribute]) {
}
impl
Visitor
<
'tcx
>
for
IfThisChanged
<
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
Self
::
Map
>
{
NestedVisitorMap
::
OnlyBodies
(
&
self
.tcx
.hir
())
}
...
...
src/librustc_incremental/persist/dirty_clean.rs
浏览文件 @
83516670
...
...
@@ -15,6 +15,7 @@
use
rustc
::
dep_graph
::{
label_strs
,
DepNode
};
use
rustc
::
hir
::
intravisit
;
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
ty
::
TyCtxt
;
use
rustc_data_structures
::
fingerprint
::
Fingerprint
;
use
rustc_data_structures
::
fx
::
FxHashSet
;
...
...
@@ -547,7 +548,9 @@ fn report_unchecked_attrs(&self, checked_attrs: &FxHashSet<ast::AttrId>) {
}
impl
intravisit
::
Visitor
<
'tcx
>
for
FindAllAttrs
<
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
intravisit
::
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
intravisit
::
NestedVisitorMap
<
'this
,
Self
::
Map
>
{
intravisit
::
NestedVisitorMap
::
All
(
&
self
.tcx
.hir
())
}
...
...
src/librustc_lint/builtin.rs
浏览文件 @
83516670
...
...
@@ -25,6 +25,7 @@
use
lint
::{
EarlyContext
,
EarlyLintPass
,
LateLintPass
,
LintPass
};
use
lint
::{
LateContext
,
LintArray
,
LintContext
};
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
lint
;
use
rustc
::
lint
::
FutureIncompatibleInfo
;
use
rustc
::
traits
::
misc
::
can_type_implement_copy
;
...
...
@@ -1093,7 +1094,9 @@ struct WalkAssocTypes<'a, 'db> {
err
:
&
'a
mut
DiagnosticBuilder
<
'db
>
,
}
impl
<
'a
,
'db
,
'v
>
Visitor
<
'v
>
for
WalkAssocTypes
<
'a
,
'db
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
intravisit
::
NestedVisitorMap
<
'this
,
'v
>
{
type
Map
=
Map
<
'v
>
;
fn
nested_visit_map
(
&
mut
self
)
->
intravisit
::
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
intravisit
::
NestedVisitorMap
::
None
}
...
...
src/librustc_lint/late.rs
浏览文件 @
83516670
...
...
@@ -16,6 +16,7 @@
use
rustc
::
hir
::
intravisit
as
hir_visit
;
use
rustc
::
hir
::
intravisit
::
Visitor
;
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
lint
::
LateContext
;
use
rustc
::
lint
::
LintPass
;
use
rustc
::
lint
::{
LateLintPass
,
LateLintPassObject
};
...
...
@@ -86,10 +87,12 @@ fn exit_attrs(&mut self, attrs: &'tcx [ast::Attribute]) {
impl
<
'a
,
'tcx
,
T
:
LateLintPass
<
'a
,
'tcx
>>
hir_visit
::
Visitor
<
'tcx
>
for
LateContextAndPass
<
'a
,
'tcx
,
T
>
{
type
Map
=
Map
<
'tcx
>
;
/// Because lints are scoped lexically, we want to walk nested
/// items in the context of the outer item, so enable
/// deep-walking.
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
hir_visit
::
NestedVisitorMap
<
'this
,
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
hir_visit
::
NestedVisitorMap
<
'this
,
Self
::
Map
>
{
hir_visit
::
NestedVisitorMap
::
All
(
&
self
.context.tcx
.hir
())
}
...
...
src/librustc_lint/levels.rs
浏览文件 @
83516670
use
rustc
::
hir
::
intravisit
;
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
lint
::{
LintLevelMap
,
LintLevelSets
,
LintLevelsBuilder
,
LintStore
};
use
rustc
::
ty
::
query
::
Providers
;
use
rustc
::
ty
::
TyCtxt
;
...
...
@@ -50,7 +51,9 @@ fn with_lint_attrs<F>(&mut self, id: hir::HirId, attrs: &[ast::Attribute], f: F)
}
impl
<
'tcx
>
intravisit
::
Visitor
<
'tcx
>
for
LintLevelMapBuilder
<
'_
,
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
intravisit
::
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
intravisit
::
NestedVisitorMap
<
'this
,
Self
::
Map
>
{
intravisit
::
NestedVisitorMap
::
All
(
&
self
.tcx
.hir
())
}
...
...
src/librustc_metadata/rmeta/encoder.rs
浏览文件 @
83516670
...
...
@@ -2,6 +2,7 @@
use
crate
::
rmeta
::
*
;
use
rustc
::
hir
::
map
::
definitions
::
DefPathTable
;
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
middle
::
cstore
::{
EncodedMetadata
,
ForeignModule
,
LinkagePreference
,
NativeLibrary
};
use
rustc
::
middle
::
dependency_format
::
Linkage
;
use
rustc
::
middle
::
exported_symbols
::{
metadata_symbol_name
,
ExportedSymbol
,
SymbolExportLevel
};
...
...
@@ -1520,7 +1521,9 @@ fn encode_info_for_foreign_item(&mut self, def_id: DefId, nitem: &hir::ForeignIt
// FIXME(eddyb) make metadata encoding walk over all definitions, instead of HIR.
impl
Visitor
<
'tcx
>
for
EncodeContext
<
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
OnlyBodies
(
&
self
.tcx
.hir
())
}
fn
visit_expr
(
&
mut
self
,
ex
:
&
'tcx
hir
::
Expr
<
'tcx
>
)
{
...
...
src/librustc_mir/hair/pattern/check_match.rs
浏览文件 @
83516670
...
...
@@ -5,6 +5,7 @@
use
super
::{
PatCtxt
,
PatKind
,
PatternError
};
use
rustc
::
hir
::
intravisit
::{
self
,
NestedVisitorMap
,
Visitor
};
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
lint
;
use
rustc
::
session
::
Session
;
use
rustc
::
ty
::
subst
::{
InternalSubsts
,
SubstsRef
};
...
...
@@ -49,7 +50,9 @@ struct MatchVisitor<'a, 'tcx> {
}
impl
<
'tcx
>
Visitor
<
'tcx
>
for
MatchVisitor
<
'_
,
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
None
}
...
...
@@ -730,7 +733,9 @@ struct AtBindingPatternVisitor<'a, 'b, 'tcx> {
}
impl
<
'v
>
Visitor
<
'v
>
for
AtBindingPatternVisitor
<
'_
,
'_
,
'_
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'v
>
{
type
Map
=
Map
<
'v
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
None
}
...
...
src/librustc_mir/transform/check_unsafety.rs
浏览文件 @
83516670
use
rustc
::
hir
::
intravisit
;
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
lint
::
builtin
::{
SAFE_PACKED_BORROWS
,
UNUSED_UNSAFE
};
use
rustc
::
mir
::
visit
::{
MutatingUseContext
,
PlaceContext
,
Visitor
};
use
rustc
::
mir
::
*
;
...
...
@@ -475,7 +476,9 @@ struct UnusedUnsafeVisitor<'a> {
}
impl
<
'a
,
'tcx
>
intravisit
::
Visitor
<
'tcx
>
for
UnusedUnsafeVisitor
<
'a
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
intravisit
::
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
intravisit
::
NestedVisitorMap
<
'this
,
Self
::
Map
>
{
intravisit
::
NestedVisitorMap
::
None
}
...
...
src/librustc_mir/transform/mod.rs
浏览文件 @
83516670
use
crate
::{
build
,
shim
};
use
rustc
::
hir
::
intravisit
::{
self
,
NestedVisitorMap
,
Visitor
};
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
mir
::{
BodyAndCache
,
ConstQualifs
,
MirPhase
,
Promoted
};
use
rustc
::
ty
::
query
::
Providers
;
use
rustc
::
ty
::
steal
::
Steal
;
...
...
@@ -85,7 +86,8 @@ fn visit_variant_data(
}
intravisit
::
walk_struct_def
(
self
,
v
)
}
fn
nested_visit_map
<
'b
>
(
&
'b
mut
self
)
->
NestedVisitorMap
<
'b
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
<
'b
>
(
&
'b
mut
self
)
->
NestedVisitorMap
<
'b
,
Self
::
Map
>
{
NestedVisitorMap
::
None
}
}
...
...
src/librustc_passes/check_const.rs
浏览文件 @
83516670
...
...
@@ -200,7 +200,9 @@ fn recurse_into(&mut self, kind: Option<ConstKind>, f: impl FnOnce(&mut Self)) {
}
impl
<
'tcx
>
Visitor
<
'tcx
>
for
CheckConstVisitor
<
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
intravisit
::
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
OnlyBodies
(
&
self
.tcx
.hir
())
}
...
...
src/librustc_passes/dead.rs
浏览文件 @
83516670
...
...
@@ -3,6 +3,7 @@
// from live codes are live, and everything else is dead.
use
rustc
::
hir
::
intravisit
::{
self
,
NestedVisitorMap
,
Visitor
};
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
lint
;
use
rustc
::
middle
::
codegen_fn_attrs
::
CodegenFnAttrFlags
;
use
rustc
::
middle
::
privacy
;
...
...
@@ -210,7 +211,9 @@ fn mark_as_used_if_union(&mut self, adt: &ty::AdtDef, fields: &[hir::Field<'_>])
}
impl
<
'a
,
'tcx
>
Visitor
<
'tcx
>
for
MarkSymbolVisitor
<
'a
,
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
intravisit
::
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
None
}
...
...
@@ -563,11 +566,13 @@ fn warn_dead_code(
}
impl
Visitor
<
'tcx
>
for
DeadVisitor
<
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
/// Walk nested items in place so that we don't report dead-code
/// on inner functions when the outer function is already getting
/// an error. We could do this also by checking the parents, but
/// this is how the code is setup and it seems harmless enough.
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
All
(
&
self
.tcx
.hir
())
}
...
...
src/librustc_passes/hir_stats.rs
浏览文件 @
83516670
...
...
@@ -3,6 +3,7 @@
// completely accurate (some things might be counted twice, others missed).
use
rustc
::
hir
::
intravisit
as
hir_visit
;
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
util
::
common
::
to_readable_str
;
use
rustc_data_structures
::
fx
::{
FxHashMap
,
FxHashSet
};
use
rustc_hir
as
hir
;
...
...
@@ -92,7 +93,9 @@ fn visit_param(&mut self, param: &'v hir::Param<'v>) {
hir_visit
::
walk_param
(
self
,
param
)
}
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
hir_visit
::
NestedVisitorMap
<
'this
,
'v
>
{
type
Map
=
Map
<
'v
>
;
fn
nested_visit_map
(
&
mut
self
)
->
hir_visit
::
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
panic!
(
"visit_nested_xxx must be manually implemented in this visitor"
)
}
...
...
src/librustc_passes/intrinsicck.rs
浏览文件 @
83516670
use
errors
::
struct_span_err
;
use
rustc
::
hir
::
intravisit
::{
self
,
NestedVisitorMap
,
Visitor
};
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
ty
::
layout
::{
LayoutError
,
Pointer
,
SizeSkeleton
,
VariantIdx
};
use
rustc
::
ty
::
query
::
Providers
;
use
rustc
::
ty
::{
self
,
Ty
,
TyCtxt
};
use
rustc_hir
as
hir
;
use
rustc_hir
::
def
::{
DefKind
,
Res
};
use
rustc_hir
::
def_id
::
DefId
;
use
rustc
::
hir
::
intravisit
::{
self
,
NestedVisitorMap
,
Visitor
};
use
rustc_hir
as
hir
;
use
rustc_index
::
vec
::
Idx
;
use
rustc_span
::{
sym
,
Span
};
use
rustc_target
::
spec
::
abi
::
Abi
::
RustIntrinsic
;
...
...
@@ -124,7 +124,9 @@ fn check_transmute(&self, span: Span, from: Ty<'tcx>, to: Ty<'tcx>) {
}
impl
Visitor
<
'tcx
>
for
ItemVisitor
<
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
None
}
...
...
@@ -139,7 +141,9 @@ fn visit_nested_body(&mut self, body_id: hir::BodyId) {
}
impl
Visitor
<
'tcx
>
for
ExprVisitor
<
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
None
}
...
...
src/librustc_passes/lib_features.rs
浏览文件 @
83516670
...
...
@@ -6,6 +6,7 @@
use
errors
::
struct_span_err
;
use
rustc
::
hir
::
intravisit
::{
self
,
NestedVisitorMap
,
Visitor
};
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
middle
::
lib_features
::
LibFeatures
;
use
rustc
::
ty
::
query
::
Providers
;
use
rustc
::
ty
::
TyCtxt
;
...
...
@@ -113,7 +114,9 @@ fn span_feature_error(&self, span: Span, msg: &str) {
}
impl
Visitor
<
'tcx
>
for
LibFeatureCollector
<
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
All
(
&
self
.tcx
.hir
())
}
...
...
src/librustc_passes/liveness.rs
浏览文件 @
83516670
...
...
@@ -98,6 +98,7 @@
use
errors
::
Applicability
;
use
rustc
::
hir
::
intravisit
::{
self
,
FnKind
,
NestedVisitorMap
,
Visitor
};
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
lint
;
use
rustc
::
ty
::
query
::
Providers
;
use
rustc
::
ty
::{
self
,
TyCtxt
};
...
...
@@ -153,7 +154,9 @@ fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt<'_>) -> String {
}
impl
<
'tcx
>
Visitor
<
'tcx
>
for
IrMaps
<
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
OnlyBodies
(
&
self
.tcx
.hir
())
}
...
...
@@ -1348,7 +1351,9 @@ fn propagate_through_loop(
// Checking for error conditions
impl
<
'a
,
'tcx
>
Visitor
<
'tcx
>
for
Liveness
<
'a
,
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
None
}
...
...
src/librustc_passes/loops.rs
浏览文件 @
83516670
...
...
@@ -44,7 +44,9 @@ pub(crate) fn provide(providers: &mut Providers<'_>) {
}
impl
<
'a
,
'hir
>
Visitor
<
'hir
>
for
CheckLoopVisitor
<
'a
,
'hir
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'hir
>
{
type
Map
=
Map
<
'hir
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
OnlyBodies
(
&
self
.hir_map
)
}
...
...
src/librustc_passes/reachable.rs
浏览文件 @
83516670
...
...
@@ -7,6 +7,7 @@
use
rustc
::
hir
::
intravisit
;
use
rustc
::
hir
::
intravisit
::{
NestedVisitorMap
,
Visitor
};
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
middle
::
codegen_fn_attrs
::{
CodegenFnAttrFlags
,
CodegenFnAttrs
};
use
rustc
::
middle
::
privacy
;
use
rustc
::
session
::
config
;
...
...
@@ -82,7 +83,9 @@ struct ReachableContext<'a, 'tcx> {
}
impl
<
'a
,
'tcx
>
Visitor
<
'tcx
>
for
ReachableContext
<
'a
,
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
None
}
...
...
src/librustc_passes/region.rs
浏览文件 @
83516670
...
...
@@ -7,6 +7,7 @@
//! [rustc guide]: https://rust-lang.github.io/rustc-guide/mir/borrowck.html
use
rustc
::
hir
::
intravisit
::{
self
,
NestedVisitorMap
,
Visitor
};
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
middle
::
region
::
*
;
use
rustc
::
ty
::
query
::
Providers
;
use
rustc
::
ty
::
TyCtxt
;
...
...
@@ -695,7 +696,9 @@ fn enter_node_scope_with_dtor(&mut self, id: hir::ItemLocalId) {
}
impl
<
'tcx
>
Visitor
<
'tcx
>
for
RegionResolutionVisitor
<
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
None
}
...
...
src/librustc_passes/stability.rs
浏览文件 @
83516670
...
...
@@ -3,6 +3,7 @@
use
errors
::
struct_span_err
;
use
rustc
::
hir
::
intravisit
::{
self
,
NestedVisitorMap
,
Visitor
};
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
lint
;
use
rustc
::
middle
::
privacy
::
AccessLevels
;
use
rustc
::
middle
::
stability
::{
DeprecationEntry
,
Index
};
...
...
@@ -204,7 +205,9 @@ impl<'a, 'tcx> Visitor<'tcx> for Annotator<'a, 'tcx> {
/// Because stability levels are scoped lexically, we want to walk
/// nested items in the context of the outer item, so enable
/// deep-walking.
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
All
(
&
self
.tcx
.hir
())
}
...
...
@@ -293,7 +296,9 @@ fn check_missing_stability(&self, hir_id: HirId, span: Span, name: &str) {
}
impl
<
'a
,
'tcx
>
Visitor
<
'tcx
>
for
MissingStabilityAnnotations
<
'a
,
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
OnlyBodies
(
&
self
.tcx
.hir
())
}
...
...
@@ -429,10 +434,12 @@ struct Checker<'tcx> {
}
impl
Visitor
<
'tcx
>
for
Checker
<
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
/// Because stability levels are scoped lexically, we want to walk
/// nested items in the context of the outer item, so enable
/// deep-walking.
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
OnlyBodies
(
&
self
.tcx
.hir
())
}
...
...
src/librustc_privacy/lib.rs
浏览文件 @
83516670
...
...
@@ -5,6 +5,7 @@
use
rustc
::
bug
;
use
rustc
::
hir
::
intravisit
::{
self
,
DeepVisitor
,
NestedVisitorMap
,
Visitor
};
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
lint
;
use
rustc
::
middle
::
privacy
::{
AccessLevel
,
AccessLevels
};
use
rustc
::
ty
::
fold
::
TypeVisitor
;
...
...
@@ -372,7 +373,9 @@ struct PubRestrictedVisitor<'tcx> {
}
impl
Visitor
<
'tcx
>
for
PubRestrictedVisitor
<
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
All
(
&
self
.tcx
.hir
())
}
fn
visit_vis
(
&
mut
self
,
vis
:
&
'tcx
hir
::
Visibility
<
'tcx
>
)
{
...
...
@@ -670,9 +673,11 @@ fn update_visibility_of_intermediate_use_statements(
}
impl
Visitor
<
'tcx
>
for
EmbargoVisitor
<
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
/// We want to visit items in the context of their containing
/// module and so forth, so supply a crate for doing a deep walk.
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
All
(
&
self
.tcx
.hir
())
}
...
...
@@ -1039,9 +1044,11 @@ fn check_field(
}
impl
<
'a
,
'tcx
>
Visitor
<
'tcx
>
for
NamePrivacyVisitor
<
'a
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
/// We want to visit items in the context of their containing
/// module and so forth, so supply a crate for doing a deep walk.
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
All
(
&
self
.tcx
.hir
())
}
...
...
@@ -1179,9 +1186,11 @@ fn check_def_id(&mut self, def_id: DefId, kind: &str, descr: &dyn fmt::Display)
}
impl
<
'a
,
'tcx
>
Visitor
<
'tcx
>
for
TypePrivacyVisitor
<
'a
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
/// We want to visit items in the context of their containing
/// module and so forth, so supply a crate for doing a deep walk.
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
All
(
&
self
.tcx
.hir
())
}
...
...
@@ -1437,7 +1446,9 @@ fn item_is_public(&self, id: &hir::HirId, vis: &hir::Visibility<'_>) -> bool {
}
impl
<
'a
,
'b
,
'tcx
,
'v
>
Visitor
<
'v
>
for
ObsoleteCheckTypeForPrivatenessVisitor
<
'a
,
'b
,
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'v
>
{
type
Map
=
Map
<
'v
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
None
}
...
...
@@ -1463,9 +1474,11 @@ fn visit_expr(&mut self, _: &hir::Expr<'_>) {}
}
impl
<
'a
,
'tcx
>
Visitor
<
'tcx
>
for
ObsoleteVisiblePrivateTypesVisitor
<
'a
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
/// We want to visit items in the context of their containing
/// module and so forth, so supply a crate for doing a deep walk.
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
All
(
&
self
.tcx
.hir
())
}
...
...
@@ -1906,7 +1919,9 @@ fn check_assoc_item(
}
impl
<
'a
,
'tcx
>
Visitor
<
'tcx
>
for
PrivateItemsInPublicInterfacesVisitor
<
'a
,
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
OnlyBodies
(
&
self
.tcx
.hir
())
}
...
...
src/librustc_resolve/lifetimes.rs
浏览文件 @
83516670
...
...
@@ -361,7 +361,9 @@ fn sub_items_have_self_param(node: &hir::ItemKind<'_>) -> bool {
}
impl
<
'a
,
'tcx
>
Visitor
<
'tcx
>
for
LifetimeContext
<
'a
,
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
All
(
&
self
.tcx
.hir
())
}
...
...
@@ -1086,7 +1088,9 @@ struct GatherLabels<'a, 'tcx> {
gather
.visit_body
(
body
);
impl
<
'v
,
'a
,
'tcx
>
Visitor
<
'v
>
for
GatherLabels
<
'a
,
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'v
>
{
type
Map
=
Map
<
'v
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
None
}
...
...
@@ -2129,7 +2133,9 @@ fn is_self_ty(&self, res: Res) -> bool {
}
impl
<
'a
>
Visitor
<
'a
>
for
SelfVisitor
<
'a
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'a
>
{
type
Map
=
Map
<
'a
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
None
}
...
...
@@ -2217,7 +2223,9 @@ struct GatherLifetimes<'a> {
}
impl
<
'v
,
'a
>
Visitor
<
'v
>
for
GatherLifetimes
<
'a
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'v
>
{
type
Map
=
Map
<
'v
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
None
}
...
...
@@ -2802,7 +2810,9 @@ struct ConstrainedCollector {
}
impl
<
'v
>
Visitor
<
'v
>
for
ConstrainedCollector
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'v
>
{
type
Map
=
Map
<
'v
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
None
}
...
...
@@ -2843,7 +2853,9 @@ struct AllCollector {
}
impl
<
'v
>
Visitor
<
'v
>
for
AllCollector
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'v
>
{
type
Map
=
Map
<
'v
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
None
}
...
...
src/librustc_traits/lowering/mod.rs
浏览文件 @
83516670
...
...
@@ -2,6 +2,7 @@
use
rustc
::
hir
::
intravisit
::{
self
,
NestedVisitorMap
,
Visitor
};
use
rustc
::
hir
::
map
::
definitions
::
DefPathData
;
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
traits
::{
Clause
,
Clauses
,
DomainGoal
,
FromEnv
,
GoalKind
,
PolyDomainGoal
,
ProgramClause
,
ProgramClauseCategory
,
WellFormed
,
WhereClause
,
...
...
@@ -600,7 +601,9 @@ fn process_attrs(&mut self, hir_id: hir::HirId, attrs: &[ast::Attribute]) {
}
impl
Visitor
<
'tcx
>
for
ClauseDumper
<
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
Self
::
Map
>
{
NestedVisitorMap
::
OnlyBodies
(
&
self
.tcx
.hir
())
}
...
...
src/librustc_typeck/check/compare_method.rs
浏览文件 @
83516670
use
errors
::{
pluralize
,
struct_span_err
,
Applicability
,
DiagnosticId
};
use
rustc
::
hir
::
intravisit
;
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
infer
::{
self
,
InferOk
};
use
rustc
::
traits
::{
self
,
ObligationCause
,
ObligationCauseCode
,
Reveal
};
use
rustc
::
ty
::
error
::{
ExpectedFound
,
TypeError
};
...
...
@@ -890,9 +891,10 @@ fn visit_ty(&mut self, ty: &'v hir::Ty<'v>) {
}
}
}
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
,
)
->
intravisit
::
NestedVisitorMap
<
'this
,
'v
>
type
Map
=
Map
<
'v
>
;
fn
nested_visit_map
(
&
mut
self
,
)
->
intravisit
::
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
intravisit
::
NestedVisitorMap
::
None
}
...
...
src/librustc_typeck/check/generator_interior.rs
浏览文件 @
83516670
...
...
@@ -5,6 +5,7 @@
use
super
::
FnCtxt
;
use
rustc
::
hir
::
intravisit
::{
self
,
NestedVisitorMap
,
Visitor
};
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
middle
::
region
::{
self
,
YieldData
};
use
rustc
::
ty
::{
self
,
Ty
};
use
rustc_data_structures
::
fx
::
FxHashMap
;
...
...
@@ -193,7 +194,9 @@ pub fn resolve_interior<'a, 'tcx>(
// librustc/middle/region.rs since `expr_count` is compared against the results
// there.
impl
<
'a
,
'tcx
>
Visitor
<
'tcx
>
for
InteriorVisitor
<
'a
,
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
None
}
...
...
src/librustc_typeck/check/method/suggest.rs
浏览文件 @
83516670
...
...
@@ -7,6 +7,7 @@
use
errors
::{
pluralize
,
struct_span_err
,
Applicability
,
DiagnosticBuilder
};
use
rustc
::
hir
::
intravisit
;
use
rustc
::
hir
::
map
as
hir_map
;
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
infer
::
type_variable
::{
TypeVariableOrigin
,
TypeVariableOriginKind
};
use
rustc
::
traits
::
Obligation
;
use
rustc
::
ty
::
print
::
with_crate_prefix
;
...
...
@@ -1124,7 +1125,9 @@ fn visit_mod(&mut self, module: &'tcx hir::Mod<'tcx>, _: Span, hir_id: hir::HirI
}
}
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
intravisit
::
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
intravisit
::
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
intravisit
::
NestedVisitorMap
::
None
}
}
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
83516670
...
...
@@ -92,6 +92,7 @@
use
crate
::
namespace
::
Namespace
;
use
errors
::{
pluralize
,
struct_span_err
,
Applicability
,
DiagnosticBuilder
,
DiagnosticId
};
use
rustc
::
hir
::
intravisit
::{
self
,
NestedVisitorMap
,
Visitor
};
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
infer
::
canonical
::{
Canonical
,
OriginalQueryValues
,
QueryResponse
};
use
rustc
::
infer
::
error_reporting
::
TypeAnnotationNeeded
::
E0282
;
use
rustc
::
infer
::
opaque_types
::
OpaqueTypeDecl
;
...
...
@@ -1170,7 +1171,9 @@ fn assign(&mut self, span: Span, nid: hir::HirId, ty_opt: Option<LocalTy<'tcx>>)
}
impl
<
'a
,
'tcx
>
Visitor
<
'tcx
>
for
GatherLocalsVisitor
<
'a
,
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
None
}
...
...
src/librustc_typeck/check/regionck.rs
浏览文件 @
83516670
...
...
@@ -77,6 +77,7 @@
use
crate
::
mem_categorization
as
mc
;
use
crate
::
middle
::
region
;
use
rustc
::
hir
::
intravisit
::{
self
,
NestedVisitorMap
,
Visitor
};
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
infer
::
outlives
::
env
::
OutlivesEnvironment
;
use
rustc
::
infer
::{
self
,
RegionObligation
,
SuppressRegionErrors
};
use
rustc
::
ty
::
adjustment
;
...
...
@@ -414,7 +415,9 @@ impl<'a, 'tcx> Visitor<'tcx> for RegionCtxt<'a, 'tcx> {
// hierarchy, and in particular the relationships between free
// regions, until regionck, as described in #3238.
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
None
}
...
...
src/librustc_typeck/check/upvar.rs
浏览文件 @
83516670
...
...
@@ -36,6 +36,7 @@
use
crate
::
mem_categorization
as
mc
;
use
crate
::
mem_categorization
::
PlaceBase
;
use
rustc
::
hir
::
intravisit
::{
self
,
NestedVisitorMap
,
Visitor
};
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
infer
::
UpvarRegion
;
use
rustc
::
ty
::{
self
,
Ty
,
TyCtxt
,
UpvarSubsts
};
use
rustc_data_structures
::
fx
::
FxIndexMap
;
...
...
@@ -59,7 +60,9 @@ struct InferBorrowKindVisitor<'a, 'tcx> {
}
impl
<
'a
,
'tcx
>
Visitor
<
'tcx
>
for
InferBorrowKindVisitor
<
'a
,
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
None
}
...
...
src/librustc_typeck/check/writeback.rs
浏览文件 @
83516670
...
...
@@ -5,6 +5,7 @@
use
crate
::
check
::
FnCtxt
;
use
rustc
::
hir
::
intravisit
::{
self
,
NestedVisitorMap
,
Visitor
};
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
infer
::
error_reporting
::
TypeAnnotationNeeded
::
E0282
;
use
rustc
::
infer
::
InferCtxt
;
use
rustc
::
ty
::
adjustment
::{
Adjust
,
Adjustment
,
PointerCast
};
...
...
@@ -242,7 +243,9 @@ fn fix_index_builtin_expr(&mut self, e: &hir::Expr<'_>) {
// traffic in node-ids or update tables in the type context etc.
impl
<
'cx
,
'tcx
>
Visitor
<
'tcx
>
for
WritebackCx
<
'cx
,
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
None
}
...
...
src/librustc_typeck/collect.rs
浏览文件 @
83516670
...
...
@@ -22,6 +22,7 @@
use
crate
::
middle
::
weak_lang_items
;
use
errors
::{
struct_span_err
,
Applicability
,
StashKey
};
use
rustc
::
hir
::
intravisit
::{
self
,
NestedVisitorMap
,
Visitor
};
use
rustc
::
hir
::
map
::
Map
;
use
rustc
::
middle
::
codegen_fn_attrs
::{
CodegenFnAttrFlags
,
CodegenFnAttrs
};
use
rustc
::
mir
::
mono
::
Linkage
;
use
rustc
::
traits
;
...
...
@@ -104,7 +105,9 @@ pub struct ItemCtxt<'tcx> {
crate
struct
PlaceholderHirTyCollector
(
crate
Vec
<
Span
>
);
impl
<
'v
>
Visitor
<
'v
>
for
PlaceholderHirTyCollector
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'v
>
{
type
Map
=
Map
<
'v
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
None
}
fn
visit_ty
(
&
mut
self
,
t
:
&
'v
hir
::
Ty
<
'v
>
)
{
...
...
@@ -185,7 +188,9 @@ fn reject_placeholder_type_signatures_in_item(tcx: TyCtxt<'tcx>, item: &'tcx hir
}
impl
Visitor
<
'tcx
>
for
CollectItemTypesVisitor
<
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
OnlyBodies
(
&
self
.tcx
.hir
())
}
...
...
@@ -885,7 +890,9 @@ struct LateBoundRegionsDetector<'tcx> {
}
impl
Visitor
<
'tcx
>
for
LateBoundRegionsDetector
<
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
NestedVisitorMap
::
None
}
...
...
@@ -1715,7 +1722,9 @@ fn check(&mut self, def_id: DefId) {
}
impl
<
'tcx
>
intravisit
::
Visitor
<
'tcx
>
for
ConstraintLocator
<
'tcx
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
intravisit
::
NestedVisitorMap
<
'this
,
'tcx
>
{
type
Map
=
Map
<
'tcx
>
;
fn
nested_visit_map
(
&
mut
self
)
->
intravisit
::
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
intravisit
::
NestedVisitorMap
::
All
(
&
self
.tcx
.hir
())
}
fn
visit_item
(
&
mut
self
,
it
:
&
'tcx
Item
<
'tcx
>
)
{
...
...
src/librustdoc/test.rs
浏览文件 @
83516670
...
...
@@ -899,7 +899,9 @@ fn visit_testable<F: FnOnce(&mut Self)>(
}
impl
<
'a
,
'hir
>
intravisit
::
Visitor
<
'hir
>
for
HirCollector
<
'a
,
'hir
>
{
fn
nested_visit_map
<
'this
>
(
&
'this
mut
self
)
->
intravisit
::
NestedVisitorMap
<
'this
,
'hir
>
{
type
Map
=
Map
<
'hir
>
;
fn
nested_visit_map
(
&
mut
self
)
->
intravisit
::
NestedVisitorMap
<
'_
,
Self
::
Map
>
{
intravisit
::
NestedVisitorMap
::
All
(
&
self
.map
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录