Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
00b74e5e
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,发现更多精彩内容 >>
提交
00b74e5e
编写于
2月 18, 2019
作者:
L
ljedrz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
hir: remove NodeId from Lifetime and Ty
上级
904a91c4
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
71 addition
and
82 deletion
+71
-82
src/librustc/hir/lowering.rs
src/librustc/hir/lowering.rs
+11
-19
src/librustc/hir/mod.rs
src/librustc/hir/mod.rs
+4
-6
src/librustc/ich/impls_hir.rs
src/librustc/ich/impls_hir.rs
+0
-2
src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs
.../error_reporting/nice_region_error/different_lifetimes.rs
+1
-1
src/librustc/middle/resolve_lifetime.rs
src/librustc/middle/resolve_lifetime.rs
+33
-30
src/librustc_save_analysis/lib.rs
src/librustc_save_analysis/lib.rs
+1
-1
src/librustc_typeck/astconv.rs
src/librustc_typeck/astconv.rs
+8
-8
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+2
-1
src/librustc_typeck/collect.rs
src/librustc_typeck/collect.rs
+1
-1
src/librustc_typeck/lib.rs
src/librustc_typeck/lib.rs
+2
-2
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+7
-7
src/librustdoc/core.rs
src/librustdoc/core.rs
+0
-3
src/librustdoc/test.rs
src/librustdoc/test.rs
+1
-1
未找到文件。
src/librustc/hir/lowering.rs
浏览文件 @
00b74e5e
...
...
@@ -1350,9 +1350,8 @@ fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext<'_>) -> hir::T
TyKind
::
Mac
(
_
)
=>
panic!
(
"TyMac should have been expanded by now."
),
};
let
LoweredNodeId
{
node_id
,
hir_id
}
=
self
.lower_node_id
(
t
.id
);
let
LoweredNodeId
{
node_id
:
_
,
hir_id
}
=
self
.lower_node_id
(
t
.id
);
hir
::
Ty
{
id
:
node_id
,
node
:
kind
,
span
:
t
.span
,
hir_id
,
...
...
@@ -1533,9 +1532,8 @@ fn visit_lifetime(&mut self, lifetime: &'v hir::Lifetime) {
&&
!
self
.already_defined_lifetimes
.contains
(
&
name
)
{
self
.already_defined_lifetimes
.insert
(
name
);
let
LoweredNodeId
{
node_id
,
hir_id
}
=
self
.context
.next_id
();
let
LoweredNodeId
{
node_id
:
_
,
hir_id
}
=
self
.context
.next_id
();
self
.output_lifetimes
.push
(
hir
::
GenericArg
::
Lifetime
(
hir
::
Lifetime
{
id
:
node_id
,
hir_id
,
span
:
lifetime
.span
,
name
,
...
...
@@ -1980,8 +1978,8 @@ fn lower_parenthesized_parameter_data(
.map
(|
ty
|
this
.lower_ty_direct
(
ty
,
ImplTraitContext
::
disallowed
()))
.collect
();
let
mk_tup
=
|
this
:
&
mut
Self
,
tys
,
span
|
{
let
LoweredNodeId
{
node_id
,
hir_id
}
=
this
.next_id
();
hir
::
Ty
{
node
:
hir
::
TyKind
::
Tup
(
tys
),
id
:
node_id
,
hir_id
,
span
}
let
LoweredNodeId
{
node_id
:
_
,
hir_id
}
=
this
.next_id
();
hir
::
Ty
{
node
:
hir
::
TyKind
::
Tup
(
tys
),
hir_id
,
span
}
};
let
LoweredNodeId
{
node_id
,
hir_id
}
=
this
.next_id
();
...
...
@@ -2318,9 +2316,8 @@ fn visit_lifetime(&mut self, lifetime: &'v hir::Lifetime) {
this
.lower_ty
(
ty
,
ImplTraitContext
::
Existential
(
Some
(
fn_def_id
)))
}
FunctionRetTy
::
Default
(
span
)
=>
{
let
LoweredNodeId
{
node_id
,
hir_id
}
=
this
.next_id
();
let
LoweredNodeId
{
node_id
:
_
,
hir_id
}
=
this
.next_id
();
P
(
hir
::
Ty
{
id
:
node_id
,
hir_id
,
node
:
hir
::
TyKind
::
Tup
(
hir_vec!
[]),
span
:
*
span
,
...
...
@@ -2362,17 +2359,16 @@ fn visit_lifetime(&mut self, lifetime: &'v hir::Lifetime) {
];
if
let
Some
((
name
,
span
))
=
bound_lifetime
{
let
LoweredNodeId
{
node_id
,
hir_id
}
=
this
.next_id
();
let
LoweredNodeId
{
node_id
:
_
,
hir_id
}
=
this
.next_id
();
bounds
.push
(
hir
::
GenericBound
::
Outlives
(
hir
::
Lifetime
{
id
:
node_id
,
hir_id
,
name
,
span
}));
hir
::
Lifetime
{
hir_id
,
name
,
span
}));
}
hir
::
HirVec
::
from
(
bounds
)
});
let
LoweredNodeId
{
node_id
,
hir_id
}
=
self
.next_id
();
let
LoweredNodeId
{
node_id
:
_
,
hir_id
}
=
self
.next_id
();
let
impl_trait_ty
=
P
(
hir
::
Ty
{
id
:
node_id
,
node
:
impl_trait_ty
,
span
,
hir_id
,
...
...
@@ -2431,10 +2427,9 @@ fn new_named_lifetime(
span
:
Span
,
name
:
hir
::
LifetimeName
,
)
->
hir
::
Lifetime
{
let
LoweredNodeId
{
node_id
,
hir_id
}
=
self
.lower_node_id
(
id
);
let
LoweredNodeId
{
node_id
:
_
,
hir_id
}
=
self
.lower_node_id
(
id
);
hir
::
Lifetime
{
id
:
node_id
,
hir_id
,
span
,
name
:
name
,
...
...
@@ -5108,7 +5103,6 @@ fn ty_path(&mut self, id: LoweredNodeId, span: Span, qpath: hir::QPath) -> hir::
_
=>
hir
::
TyKind
::
Path
(
qpath
),
};
hir
::
Ty
{
id
:
id
.node_id
,
hir_id
:
id
.hir_id
,
node
,
span
,
...
...
@@ -5124,9 +5118,8 @@ fn elided_ref_lifetime(&mut self, span: Span) -> hir::Lifetime {
// `'f`.
AnonymousLifetimeMode
::
CreateParameter
=>
{
let
fresh_name
=
self
.collect_fresh_in_band_lifetime
(
span
);
let
LoweredNodeId
{
node_id
,
hir_id
}
=
self
.next_id
();
let
LoweredNodeId
{
node_id
:
_
,
hir_id
}
=
self
.next_id
();
hir
::
Lifetime
{
id
:
node_id
,
hir_id
,
span
,
name
:
hir
::
LifetimeName
::
Param
(
fresh_name
),
...
...
@@ -5227,10 +5220,9 @@ fn elided_dyn_bound(&mut self, span: Span) -> hir::Lifetime {
}
fn
new_implicit_lifetime
(
&
mut
self
,
span
:
Span
)
->
hir
::
Lifetime
{
let
LoweredNodeId
{
node_id
,
hir_id
}
=
self
.next_id
();
let
LoweredNodeId
{
node_id
:
_
,
hir_id
}
=
self
.next_id
();
hir
::
Lifetime
{
id
:
node_id
,
hir_id
,
span
,
name
:
hir
::
LifetimeName
::
Implicit
,
...
...
src/librustc/hir/mod.rs
浏览文件 @
00b74e5e
...
...
@@ -151,7 +151,6 @@ pub struct ItemLocalId { .. }
#[derive(Clone,
RustcEncodable,
RustcDecodable,
Copy)]
pub
struct
Lifetime
{
pub
id
:
NodeId
,
pub
hir_id
:
HirId
,
pub
span
:
Span
,
...
...
@@ -272,7 +271,7 @@ impl fmt::Debug for Lifetime {
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
<
'_
>
)
->
fmt
::
Result
{
write!
(
f
,
"lifetime({}: {})"
,
self
.id
,
self
.
hir_
id
,
print
::
to_string
(
print
::
NO_ANN
,
|
s
|
s
.print_lifetime
(
self
)))
}
}
...
...
@@ -417,10 +416,10 @@ pub fn span(&self) -> Span {
}
}
pub
fn
id
(
&
self
)
->
Node
Id
{
pub
fn
id
(
&
self
)
->
Hir
Id
{
match
self
{
GenericArg
::
Lifetime
(
l
)
=>
l
.id
,
GenericArg
::
Type
(
t
)
=>
t
.id
,
GenericArg
::
Lifetime
(
l
)
=>
l
.
hir_
id
,
GenericArg
::
Type
(
t
)
=>
t
.
hir_
id
,
GenericArg
::
Const
(
c
)
=>
c
.value.id
,
}
}
...
...
@@ -1760,7 +1759,6 @@ pub struct TypeBinding {
#[derive(Clone,
RustcEncodable,
RustcDecodable)]
pub
struct
Ty
{
pub
id
:
NodeId
,
pub
node
:
TyKind
,
pub
span
:
Span
,
pub
hir_id
:
HirId
,
...
...
src/librustc/ich/impls_hir.rs
浏览文件 @
00b74e5e
...
...
@@ -158,7 +158,6 @@ fn hash_stable<W: StableHasherResult>(&self,
});
impl_stable_hash_for!
(
struct
hir
::
Lifetime
{
id
,
hir_id
,
span
,
name
...
...
@@ -318,7 +317,6 @@ fn hash_stable<W: StableHasherResult>(&self,
hasher
:
&
mut
StableHasher
<
W
>
)
{
hcx
.while_hashing_hir_bodies
(
true
,
|
hcx
|
{
let
hir
::
Ty
{
id
:
_
,
hir_id
:
_
,
ref
node
,
ref
span
,
...
...
src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs
浏览文件 @
00b74e5e
...
...
@@ -101,7 +101,7 @@ pub(super) fn try_report_anon_anon_conflict(&self) -> Option<ErrorReported> {
let
(
span_1
,
span_2
,
main_label
,
span_label
)
=
match
(
sup_is_ret_type
,
sub_is_ret_type
)
{
(
None
,
None
)
=>
{
let
(
main_label_1
,
span_label_1
)
=
if
ty_sup
.
id
==
ty_sub
.
id
{
let
(
main_label_1
,
span_label_1
)
=
if
ty_sup
.
hir_id
==
ty_sub
.hir_
id
{
(
"this type is declared with multiple lifetimes..."
.to_owned
(),
"...but data with one lifetime flows into the other here"
.to_owned
()
...
...
src/librustc/middle/resolve_lifetime.rs
浏览文件 @
00b74e5e
...
...
@@ -13,7 +13,7 @@
use
crate
::
rustc
::
lint
;
use
crate
::
session
::
Session
;
use
crate
::
util
::
nodemap
::{
DefIdMap
,
FxHashMap
,
FxHashSet
,
NodeMap
,
NodeSet
};
use
crate
::
util
::
nodemap
::{
DefIdMap
,
FxHashMap
,
FxHashSet
,
HirIdMap
,
NodeMap
,
NodeSet
};
use
errors
::{
Applicability
,
DiagnosticBuilder
};
use
rustc_data_structures
::
sync
::
Lrc
;
use
std
::
borrow
::
Cow
;
...
...
@@ -151,7 +151,7 @@ fn subst<'a, L>(self, mut params: L, map: &NamedRegionMap) -> Option<Region>
if
let
Region
::
EarlyBound
(
index
,
_
,
_
)
=
self
{
params
.nth
(
index
as
usize
)
.and_then
(|
lifetime
|
map
.defs
.get
(
&
lifetime
.id
)
.cloned
())
.and_then
(|
lifetime
|
map
.defs
.get
(
&
lifetime
.
hir_
id
)
.cloned
())
}
else
{
Some
(
self
)
}
...
...
@@ -195,7 +195,7 @@ pub fn insert(&mut self, value: T) {
struct
NamedRegionMap
{
// maps from every use of a named (not anonymous) lifetime to a
// `Region` describing how that region is bound
pub
defs
:
Node
Map
<
Region
>
,
pub
defs
:
HirId
Map
<
Region
>
,
// the set of lifetime def ids that are late-bound; a region can
// be late-bound if (a) it does NOT appear in a where-clause and
...
...
@@ -385,8 +385,7 @@ fn resolve_lifetimes<'tcx>(
let
mut
rl
=
ResolveLifetimes
::
default
();
for
(
k
,
v
)
in
named_region_map
.defs
{
let
hir_id
=
tcx
.hir
()
.node_to_hir_id
(
k
);
for
(
hir_id
,
v
)
in
named_region_map
.defs
{
let
map
=
rl
.defs
.entry
(
hir_id
.owner_local_def_id
())
.or_default
();
Lrc
::
get_mut
(
map
)
.unwrap
()
.insert
(
hir_id
.local_id
,
v
);
}
...
...
@@ -570,7 +569,7 @@ fn visit_foreign_item(&mut self, item: &'tcx hir::ForeignItem) {
}
fn
visit_ty
(
&
mut
self
,
ty
:
&
'tcx
hir
::
Ty
)
{
debug!
(
"visit_ty: id={:?} ty={:?}"
,
ty
.id
,
ty
);
debug!
(
"visit_ty: id={:?} ty={:?}"
,
ty
.
hir_
id
,
ty
);
match
ty
.node
{
hir
::
TyKind
::
BareFn
(
ref
c
)
=>
{
let
next_early_index
=
self
.next_early_index
();
...
...
@@ -629,7 +628,7 @@ fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
hir
::
TyKind
::
Rptr
(
ref
lifetime_ref
,
ref
mt
)
=>
{
self
.visit_lifetime
(
lifetime_ref
);
let
scope
=
Scope
::
ObjectLifetimeDefault
{
lifetime
:
self
.map.defs
.get
(
&
lifetime_ref
.id
)
.cloned
(),
lifetime
:
self
.map.defs
.get
(
&
lifetime_ref
.
hir_
id
)
.cloned
(),
s
:
self
.scope
,
};
self
.with
(
scope
,
|
_
,
this
|
this
.visit_ty
(
&
mt
.ty
));
...
...
@@ -672,7 +671,7 @@ fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
// and ban them. Type variables instantiated inside binders aren't
// well-supported at the moment, so this doesn't work.
// In the future, this should be fixed and this error should be removed.
let
def
=
self
.map.defs
.get
(
&
lifetime
.id
)
.cloned
();
let
def
=
self
.map.defs
.get
(
&
lifetime
.
hir_
id
)
.cloned
();
if
let
Some
(
Region
::
LateBound
(
_
,
def_id
,
_
))
=
def
{
if
let
Some
(
node_id
)
=
self
.tcx
.hir
()
.as_local_node_id
(
def_id
)
{
// Ensure that the parent of the def is an item, not HRTB
...
...
@@ -1501,8 +1500,10 @@ fn suggest_eliding_single_use_lifetime(
}
}
};
if
let
Node
::
Lifetime
(
hir_lifetime
)
=
self
.tcx
.hir
()
.get
(
lifetime
.id
)
{
if
let
Some
(
parent
)
=
self
.tcx
.hir
()
.find
(
self
.tcx
.hir
()
.get_parent
(
hir_lifetime
.id
))
{
if
let
Node
::
Lifetime
(
hir_lifetime
)
=
self
.tcx
.hir
()
.get_by_hir_id
(
lifetime
.hir_id
)
{
if
let
Some
(
parent
)
=
self
.tcx
.hir
()
.find_by_hir_id
(
self
.tcx
.hir
()
.get_parent_item
(
hir_lifetime
.hir_id
))
{
match
parent
{
Node
::
Item
(
item
)
=>
{
if
let
hir
::
ItemKind
::
Fn
(
decl
,
_
,
_
,
_
)
=
&
item
.node
{
...
...
@@ -1582,22 +1583,22 @@ fn check_uses_for_lifetimes_defined_by_scope(&mut self) {
debug!
(
"node id first={:?}"
,
node_id
);
if
let
Some
((
id
,
span
,
name
))
=
match
self
.tcx
.hir
()
.get
(
node_id
)
{
Node
::
Lifetime
(
hir_lifetime
)
=>
Some
((
hir_lifetime
.id
,
hir_lifetime
.
hir_
id
,
hir_lifetime
.span
,
hir_lifetime
.name
.ident
(),
)),
Node
::
GenericParam
(
param
)
=>
{
Some
((
param
.id
,
param
.span
,
param
.name
.ident
()))
Some
((
param
.
hir_
id
,
param
.span
,
param
.name
.ident
()))
}
_
=>
None
,
}
{
debug!
(
"id = {:?} span = {:?} name = {:?}"
,
node_
id
,
span
,
name
);
debug!
(
"id = {:?} span = {:?} name = {:?}"
,
id
,
span
,
name
);
if
name
==
keywords
::
UnderscoreLifetime
.ident
()
{
continue
;
}
let
mut
err
=
self
.tcx
.struct_span_lint_
node
(
let
mut
err
=
self
.tcx
.struct_span_lint_
hir
(
lint
::
builtin
::
SINGLE_USE_LIFETIMES
,
id
,
span
,
...
...
@@ -1622,17 +1623,17 @@ fn check_uses_for_lifetimes_defined_by_scope(&mut self) {
let
node_id
=
self
.tcx
.hir
()
.as_local_node_id
(
def_id
)
.unwrap
();
if
let
Some
((
id
,
span
,
name
))
=
match
self
.tcx
.hir
()
.get
(
node_id
)
{
Node
::
Lifetime
(
hir_lifetime
)
=>
Some
((
hir_lifetime
.id
,
hir_lifetime
.
hir_
id
,
hir_lifetime
.span
,
hir_lifetime
.name
.ident
(),
)),
Node
::
GenericParam
(
param
)
=>
{
Some
((
param
.id
,
param
.span
,
param
.name
.ident
()))
Some
((
param
.
hir_
id
,
param
.span
,
param
.name
.ident
()))
}
_
=>
None
,
}
{
debug!
(
"id ={:?} span = {:?} name = {:?}"
,
node_
id
,
span
,
name
);
let
mut
err
=
self
.tcx
.struct_span_lint_
node
(
debug!
(
"id ={:?} span = {:?} name = {:?}"
,
id
,
span
,
name
);
let
mut
err
=
self
.tcx
.struct_span_lint_
hir
(
lint
::
builtin
::
UNUSED_LIFETIMES
,
id
,
span
,
...
...
@@ -2049,8 +2050,8 @@ fn visit_fn_like_elision(&mut self, inputs: &'tcx [hir::Ty], output: Option<&'tc
// and whether there's a `self` argument (treated specially).
let
mut
assoc_item_kind
=
None
;
let
mut
impl_self
=
None
;
let
parent
=
self
.tcx
.hir
()
.get_parent_node
(
output
.
id
);
let
body
=
match
self
.tcx
.hir
()
.get
(
parent
)
{
let
parent
=
self
.tcx
.hir
()
.get_parent_node
_by_hir_id
(
output
.hir_
id
);
let
body
=
match
self
.tcx
.hir
()
.get
_by_hir_id
(
parent
)
{
// `fn` definitions and methods.
Node
::
Item
(
&
hir
::
Item
{
node
:
hir
::
ItemKind
::
Fn
(
..
,
body
),
...
...
@@ -2063,12 +2064,13 @@ fn visit_fn_like_elision(&mut self, inputs: &'tcx [hir::Ty], output: Option<&'tc
})
=>
{
if
let
hir
::
ItemKind
::
Trait
(
..
,
ref
trait_items
)
=
self
.tcx
.hir
()
.expect_item
(
self
.tcx
.hir
()
.get_parent
(
parent
))
.expect_item
_by_hir_id
(
self
.tcx
.hir
()
.get_parent_item
(
parent
))
.node
{
let
parent_node_id
=
self
.tcx
.hir
()
.hir_to_node_id
(
parent
);
assoc_item_kind
=
trait_items
.iter
()
.find
(|
ti
|
ti
.id.node_id
==
parent
)
.find
(|
ti
|
ti
.id.node_id
==
parent
_node_id
)
.map
(|
ti
|
ti
.kind
);
}
match
*
m
{
...
...
@@ -2083,13 +2085,14 @@ fn visit_fn_like_elision(&mut self, inputs: &'tcx [hir::Ty], output: Option<&'tc
})
=>
{
if
let
hir
::
ItemKind
::
Impl
(
..
,
ref
self_ty
,
ref
impl_items
)
=
self
.tcx
.hir
()
.expect_item
(
self
.tcx
.hir
()
.get_parent
(
parent
))
.expect_item
_by_hir_id
(
self
.tcx
.hir
()
.get_parent_item
(
parent
))
.node
{
impl_self
=
Some
(
self_ty
);
let
parent_node_id
=
self
.tcx
.hir
()
.hir_to_node_id
(
parent
);
assoc_item_kind
=
impl_items
.iter
()
.find
(|
ii
|
ii
.id.node_id
==
parent
)
.find
(|
ii
|
ii
.id.node_id
==
parent
_node_id
)
.map
(|
ii
|
ii
.kind
);
}
Some
(
body
)
...
...
@@ -2143,7 +2146,7 @@ fn visit_fn_like_elision(&mut self, inputs: &'tcx [hir::Ty], output: Option<&'tc
if
let
hir
::
TyKind
::
Rptr
(
lifetime_ref
,
ref
mt
)
=
inputs
[
0
]
.node
{
if
let
hir
::
TyKind
::
Path
(
hir
::
QPath
::
Resolved
(
None
,
ref
path
))
=
mt
.ty.node
{
if
is_self_ty
(
path
.def
)
{
if
let
Some
(
&
lifetime
)
=
self
.map.defs
.get
(
&
lifetime_ref
.id
)
{
if
let
Some
(
&
lifetime
)
=
self
.map.defs
.get
(
&
lifetime_ref
.
hir_
id
)
{
let
scope
=
Scope
::
Elision
{
elide
:
Elide
::
Exact
(
lifetime
),
s
:
self
.scope
,
...
...
@@ -2262,7 +2265,7 @@ fn visit_poly_trait_ref(
}
fn
visit_lifetime
(
&
mut
self
,
lifetime_ref
:
&
hir
::
Lifetime
)
{
if
let
Some
(
&
lifetime
)
=
self
.map.defs
.get
(
&
lifetime_ref
.id
)
{
if
let
Some
(
&
lifetime
)
=
self
.map.defs
.get
(
&
lifetime_ref
.
hir_
id
)
{
match
lifetime
{
Region
::
LateBound
(
debruijn
,
_
,
_
)
|
Region
::
LateBoundAnon
(
debruijn
,
_
)
if
debruijn
<
self
.outer_index
=>
...
...
@@ -2653,7 +2656,7 @@ fn track_lifetime_uses(&self) -> bool {
}
fn
insert_lifetime
(
&
mut
self
,
lifetime_ref
:
&
'tcx
hir
::
Lifetime
,
def
:
Region
)
{
if
lifetime_ref
.
id
==
ast
::
DUMMY_NODE
_ID
{
if
lifetime_ref
.
hir_id
==
hir
::
DUMMY_HIR
_ID
{
span_bug!
(
lifetime_ref
.span
,
"lifetime reference not renumbered,
\
...
...
@@ -2663,11 +2666,11 @@ fn insert_lifetime(&mut self, lifetime_ref: &'tcx hir::Lifetime, def: Region) {
debug!
(
"insert_lifetime: {} resolved to {:?} span={:?}"
,
self
.tcx
.hir
()
.
node_to_string
(
lifetime_ref
.
id
),
self
.tcx
.hir
()
.
hir_to_string
(
lifetime_ref
.hir_
id
),
def
,
self
.tcx.sess
.source_map
()
.span_to_string
(
lifetime_ref
.span
)
);
self
.map.defs
.insert
(
lifetime_ref
.id
,
def
);
self
.map.defs
.insert
(
lifetime_ref
.
hir_
id
,
def
);
match
def
{
Region
::
LateBoundAnon
(
..
)
|
Region
::
Static
=>
{
...
...
@@ -2699,7 +2702,7 @@ fn insert_lifetime(&mut self, lifetime_ref: &'tcx hir::Lifetime, def: Region) {
/// error (esp. around impl trait). In that case, we remove the
/// entry into `map.defs` so as not to confuse later code.
fn
uninsert_lifetime_on_error
(
&
mut
self
,
lifetime_ref
:
&
'tcx
hir
::
Lifetime
,
bad_def
:
Region
)
{
let
old_value
=
self
.map.defs
.remove
(
&
lifetime_ref
.id
);
let
old_value
=
self
.map.defs
.remove
(
&
lifetime_ref
.
hir_
id
);
assert_eq!
(
old_value
,
Some
(
bad_def
));
}
}
...
...
src/librustc_save_analysis/lib.rs
浏览文件 @
00b74e5e
...
...
@@ -397,7 +397,7 @@ pub fn get_method_data(&self, id: ast::NodeId, ident: ast::Ident, span: Span) ->
Some
(
Node
::
Item
(
item
))
=>
match
item
.node
{
hir
::
ItemKind
::
Impl
(
..
,
ref
ty
,
_
)
=>
{
let
mut
qualname
=
String
::
from
(
"<"
);
qualname
.push_str
(
&
self
.tcx
.hir
()
.
node_to_pretty_string
(
ty
.
id
));
qualname
.push_str
(
&
self
.tcx
.hir
()
.
hir_to_pretty_string
(
ty
.hir_
id
));
let
trait_id
=
self
.tcx
.trait_id_of_impl
(
impl_id
);
let
mut
decl_id
=
None
;
...
...
src/librustc_typeck/astconv.rs
浏览文件 @
00b74e5e
...
...
@@ -304,8 +304,8 @@ fn check_generic_arg_count(
}
else
{
let
mut
multispan
=
MultiSpan
::
from_span
(
span
);
multispan
.push_span_label
(
span_late
,
note
.to_string
());
tcx
.lint_
node
(
lint
::
builtin
::
LATE_BOUND_LIFETIME_ARGUMENTS
,
args
.args
[
0
]
.id
(),
multispan
,
msg
);
tcx
.lint_
hir
(
lint
::
builtin
::
LATE_BOUND_LIFETIME_ARGUMENTS
,
args
.args
[
0
]
.id
(),
multispan
,
msg
);
return
(
false
,
None
);
}
}
...
...
@@ -1267,7 +1267,7 @@ fn one_bound_for_assoc_type<I>(&self,
// parameter or `Self`.
pub
fn
associated_path_to_ty
(
&
self
,
ref_id
:
ast
::
Node
Id
,
hir_ref_id
:
hir
::
Hir
Id
,
span
:
Span
,
qself_ty
:
Ty
<
'tcx
>
,
qself_def
:
Def
,
...
...
@@ -1276,6 +1276,7 @@ pub fn associated_path_to_ty(
)
->
(
Ty
<
'tcx
>
,
Def
)
{
let
tcx
=
self
.tcx
();
let
assoc_ident
=
assoc_segment
.ident
;
let
ref_id
=
tcx
.hir
()
.hir_to_node_id
(
hir_ref_id
);
debug!
(
"associated_path_to_ty: {:?}::{}"
,
qself_ty
,
assoc_ident
);
...
...
@@ -1370,7 +1371,6 @@ pub fn associated_path_to_ty(
};
let
trait_did
=
bound
.def_id
();
let
hir_ref_id
=
self
.tcx
()
.hir
()
.node_to_hir_id
(
ref_id
);
let
(
assoc_ident
,
def_scope
)
=
tcx
.adjust_ident
(
assoc_ident
,
trait_did
,
hir_ref_id
);
let
item
=
tcx
.associated_items
(
trait_did
)
.find
(|
i
|
{
Namespace
::
from
(
i
.kind
)
==
Namespace
::
Type
&&
...
...
@@ -1388,9 +1388,9 @@ pub fn associated_path_to_ty(
tcx
.check_stability
(
item
.def_id
,
Some
(
ref_id
),
span
);
if
let
Some
(
variant_def
)
=
variant_resolution
{
let
mut
err
=
tcx
.struct_span_lint_
node
(
let
mut
err
=
tcx
.struct_span_lint_
hir
(
AMBIGUOUS_ASSOCIATED_ITEMS
,
ref_id
,
hir_
ref_id
,
span
,
"ambiguous associated item"
,
);
...
...
@@ -1742,7 +1742,7 @@ pub fn def_to_ty(&self,
/// internal notion of a type.
pub
fn
ast_ty_to_ty
(
&
self
,
ast_ty
:
&
hir
::
Ty
)
->
Ty
<
'tcx
>
{
debug!
(
"ast_ty_to_ty(id={:?}, ast_ty={:?} ty_ty={:?})"
,
ast_ty
.id
,
ast_ty
,
ast_ty
.node
);
ast_ty
.
hir_
id
,
ast_ty
,
ast_ty
.node
);
let
tcx
=
self
.tcx
();
...
...
@@ -1795,7 +1795,7 @@ pub fn ast_ty_to_ty(&self, ast_ty: &hir::Ty) -> Ty<'tcx> {
}
else
{
Def
::
Err
};
self
.associated_path_to_ty
(
ast_ty
.id
,
ast_ty
.span
,
ty
,
def
,
segment
,
false
)
.0
self
.associated_path_to_ty
(
ast_ty
.
hir_
id
,
ast_ty
.span
,
ty
,
def
,
segment
,
false
)
.0
}
hir
::
TyKind
::
Array
(
ref
ty
,
ref
length
)
=>
{
let
length_def_id
=
tcx
.hir
()
.local_def_id
(
length
.id
);
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
00b74e5e
...
...
@@ -4734,7 +4734,8 @@ fn finish_resolving_struct_path(&self,
}
else
{
Def
::
Err
};
let
(
ty
,
def
)
=
AstConv
::
associated_path_to_ty
(
self
,
node_id
,
path_span
,
let
hir_id
=
self
.tcx
.hir
()
.node_to_hir_id
(
node_id
);
let
(
ty
,
def
)
=
AstConv
::
associated_path_to_ty
(
self
,
hir_id
,
path_span
,
ty
,
def
,
segment
,
true
);
// Write back the new resolution.
...
...
src/librustc_typeck/collect.rs
浏览文件 @
00b74e5e
...
...
@@ -2224,7 +2224,7 @@ fn compute_sig_of_foreign_fn_decl<'a, 'tcx>(
&
format!
(
"use of SIMD type `{}` in FFI is highly experimental and
\
may result in invalid code"
,
tcx
.hir
()
.
node_to_pretty_string
(
ast_ty
.
id
)
tcx
.hir
()
.
hir_to_pretty_string
(
ast_ty
.hir_
id
)
),
)
.help
(
"add #![feature(simd_ffi)] to the crate attributes to enable"
)
...
...
src/librustc_typeck/lib.rs
浏览文件 @
00b74e5e
...
...
@@ -373,8 +373,8 @@ pub fn hir_ty_to_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir_ty: &hir::Ty) ->
// In case there are any projections etc, find the "environment"
// def-id that will be used to determine the traits/predicates in
// scope. This is derived from the enclosing item-like thing.
let
env_node_id
=
tcx
.hir
()
.get_parent
(
hir_ty
.
id
);
let
env_def_id
=
tcx
.hir
()
.local_def_id
(
env_node_id
);
let
env_node_id
=
tcx
.hir
()
.get_parent
_item
(
hir_ty
.hir_
id
);
let
env_def_id
=
tcx
.hir
()
.local_def_id
_from_hir_id
(
env_node_id
);
let
item_cx
=
self
::
collect
::
ItemCtxt
::
new
(
tcx
,
env_def_id
);
astconv
::
AstConv
::
ast_ty_to_ty
(
&
item_cx
,
hir_ty
)
...
...
src/librustdoc/clean/mod.rs
浏览文件 @
00b74e5e
...
...
@@ -1219,7 +1219,7 @@ pub fn statik() -> Lifetime {
impl
Clean
<
Lifetime
>
for
hir
::
Lifetime
{
fn
clean
(
&
self
,
cx
:
&
DocContext
<
'_
,
'_
,
'_
>
)
->
Lifetime
{
if
self
.
id
!=
ast
::
DUMMY_NODE
_ID
{
if
self
.
hir_id
!=
hir
::
DUMMY_HIR
_ID
{
let
def
=
cx
.tcx
.named_region
(
self
.hir_id
);
match
def
{
Some
(
rl
::
Region
::
EarlyBound
(
_
,
node_id
,
_
))
|
...
...
@@ -1986,7 +1986,7 @@ fn clean(&self, _: &DocContext<'_, '_, '_>) -> bool {
impl
Clean
<
Type
>
for
hir
::
TraitRef
{
fn
clean
(
&
self
,
cx
:
&
DocContext
<
'_
,
'_
,
'_
>
)
->
Type
{
resolve_type
(
cx
,
self
.path
.clean
(
cx
),
self
.ref_id
)
resolve_type
(
cx
,
self
.path
.clean
(
cx
),
self
.
hir_
ref_id
)
}
}
...
...
@@ -2654,7 +2654,7 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Type {
});
return
cx
.enter_alias
(
ty_substs
,
lt_substs
,
const_substs
,
||
ty
.clean
(
cx
));
}
resolve_type
(
cx
,
path
.clean
(
cx
),
self
.id
)
resolve_type
(
cx
,
path
.clean
(
cx
),
self
.
hir_
id
)
}
TyKind
::
Path
(
hir
::
QPath
::
Resolved
(
Some
(
ref
qself
),
ref
p
))
=>
{
let
mut
segments
:
Vec
<
_
>
=
p
.segments
.clone
()
.into
();
...
...
@@ -2667,7 +2667,7 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Type {
Type
::
QPath
{
name
:
p
.segments
.last
()
.expect
(
"segments were empty"
)
.ident.name
.clean
(
cx
),
self_type
:
box
qself
.clean
(
cx
),
trait_
:
box
resolve_type
(
cx
,
trait_path
.clean
(
cx
),
self
.id
)
trait_
:
box
resolve_type
(
cx
,
trait_path
.clean
(
cx
),
self
.
hir_
id
)
}
}
TyKind
::
Path
(
hir
::
QPath
::
TypeRelative
(
ref
qself
,
ref
segment
))
=>
{
...
...
@@ -2684,7 +2684,7 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Type {
Type
::
QPath
{
name
:
segment
.ident.name
.clean
(
cx
),
self_type
:
box
qself
.clean
(
cx
),
trait_
:
box
resolve_type
(
cx
,
trait_path
.clean
(
cx
),
self
.id
)
trait_
:
box
resolve_type
(
cx
,
trait_path
.clean
(
cx
),
self
.
hir_
id
)
}
}
TyKind
::
TraitObject
(
ref
bounds
,
ref
lifetime
)
=>
{
...
...
@@ -3907,8 +3907,8 @@ fn print_const_expr(cx: &DocContext<'_, '_, '_>, body: hir::BodyId) -> String {
/// Given a type Path, resolve it to a Type using the TyCtxt
fn
resolve_type
(
cx
:
&
DocContext
<
'_
,
'_
,
'_
>
,
path
:
Path
,
id
:
ast
::
Node
Id
)
->
Type
{
if
id
==
ast
::
DUMMY_NODE
_ID
{
id
:
hir
::
Hir
Id
)
->
Type
{
if
id
==
hir
::
DUMMY_HIR
_ID
{
debug!
(
"resolve_type({:?})"
,
path
);
}
else
{
debug!
(
"resolve_type({:?},{:?})"
,
path
,
id
);
...
...
src/librustdoc/core.rs
浏览文件 @
00b74e5e
...
...
@@ -193,7 +193,6 @@ pub fn get_real_ty<F>(&self,
};
hir
::
Ty
{
id
:
ast
::
DUMMY_NODE_ID
,
node
:
hir
::
TyKind
::
Path
(
hir
::
QPath
::
Resolved
(
None
,
P
(
new_path
))),
span
:
DUMMY_SP
,
hir_id
:
hir
::
DUMMY_HIR_ID
,
...
...
@@ -213,7 +212,6 @@ pub fn generics_to_path_params(&self, generics: ty::Generics) -> hir::GenericArg
};
args
.push
(
hir
::
GenericArg
::
Lifetime
(
hir
::
Lifetime
{
id
:
ast
::
DUMMY_NODE_ID
,
hir_id
:
hir
::
DUMMY_HIR_ID
,
span
:
DUMMY_SP
,
name
:
hir
::
LifetimeName
::
Param
(
name
),
...
...
@@ -235,7 +233,6 @@ pub fn generics_to_path_params(&self, generics: ty::Generics) -> hir::GenericArg
pub
fn
ty_param_to_ty
(
&
self
,
param
:
ty
::
GenericParamDef
)
->
hir
::
Ty
{
debug!
(
"ty_param_to_ty({:?}) {:?}"
,
param
,
param
.def_id
);
hir
::
Ty
{
id
:
ast
::
DUMMY_NODE_ID
,
node
:
hir
::
TyKind
::
Path
(
hir
::
QPath
::
Resolved
(
None
,
P
(
hir
::
Path
{
...
...
src/librustdoc/test.rs
浏览文件 @
00b74e5e
...
...
@@ -868,7 +868,7 @@ fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'thi
fn
visit_item
(
&
mut
self
,
item
:
&
'hir
hir
::
Item
)
{
let
name
=
if
let
hir
::
ItemKind
::
Impl
(
..
,
ref
ty
,
_
)
=
item
.node
{
self
.map
.
node_to_pretty_string
(
ty
.
id
)
self
.map
.
hir_to_pretty_string
(
ty
.hir_
id
)
}
else
{
item
.ident
.to_string
()
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录