Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
1884fe35
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
1884fe35
编写于
8月 08, 2018
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add a `user_substs` map into the typeck tables
上级
61b00727
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
1 deletion
+31
-1
src/librustc/ty/context.rs
src/librustc/ty/context.rs
+28
-1
src/librustc/ty/subst.rs
src/librustc/ty/subst.rs
+3
-0
未找到文件。
src/librustc/ty/context.rs
浏览文件 @
1884fe35
...
...
@@ -33,7 +33,7 @@
use
middle
::
stability
;
use
mir
::{
self
,
Mir
,
interpret
};
use
mir
::
interpret
::
Allocation
;
use
ty
::
subst
::{
Kind
,
Substs
,
Subst
};
use
ty
::
subst
::{
CanonicalSubsts
,
Kind
,
Substs
,
Subst
};
use
ty
::
ReprOptions
;
use
traits
;
use
traits
::{
Clause
,
Clauses
,
Goal
,
Goals
};
...
...
@@ -371,6 +371,18 @@ pub struct TypeckTables<'tcx> {
/// other items.
node_substs
:
ItemLocalMap
<&
'tcx
Substs
<
'tcx
>>
,
/// Stores the substitutions that the user explicit gave (if any)
/// attached to `id`. These will not include any inferred
/// values. The canonical form is used to capture things like `_`
/// or other unspecified values.
///
/// Example:
///
/// If the user wrote `foo.collect::<Vec<_>>()`, then the
/// canonical substitutions would include only `for<X> { Vec<X>
/// }`.
user_substs
:
ItemLocalMap
<
CanonicalSubsts
<
'tcx
>>
,
adjustments
:
ItemLocalMap
<
Vec
<
ty
::
adjustment
::
Adjustment
<
'tcx
>>>
,
/// Stores the actual binding mode for all instances of hir::BindingAnnotation.
...
...
@@ -444,6 +456,7 @@ pub fn empty(local_id_root: Option<DefId>) -> TypeckTables<'tcx> {
user_provided_tys
:
ItemLocalMap
(),
node_types
:
ItemLocalMap
(),
node_substs
:
ItemLocalMap
(),
user_substs
:
ItemLocalMap
(),
adjustments
:
ItemLocalMap
(),
pat_binding_modes
:
ItemLocalMap
(),
pat_adjustments
:
ItemLocalMap
(),
...
...
@@ -561,6 +574,18 @@ pub fn node_substs_opt(&self, id: hir::HirId) -> Option<&'tcx Substs<'tcx>> {
self
.node_substs
.get
(
&
id
.local_id
)
.cloned
()
}
pub
fn
user_substs_mut
(
&
mut
self
)
->
LocalTableInContextMut
<
CanonicalSubsts
<
'tcx
>>
{
LocalTableInContextMut
{
local_id_root
:
self
.local_id_root
,
data
:
&
mut
self
.user_substs
}
}
pub
fn
user_substs
(
&
self
,
id
:
hir
::
HirId
)
->
Option
<
CanonicalSubsts
<
'tcx
>>
{
validate_hir_id_for_typeck_tables
(
self
.local_id_root
,
id
,
false
);
self
.user_substs
.get
(
&
id
.local_id
)
.cloned
()
}
// Returns the type of a pattern as a monotype. Like @expr_ty, this function
// doesn't provide type parameter substitutions.
pub
fn
pat_ty
(
&
self
,
pat
:
&
hir
::
Pat
)
->
Ty
<
'tcx
>
{
...
...
@@ -740,6 +765,7 @@ fn hash_stable<W: StableHasherResult>(&self,
ref
user_provided_tys
,
ref
node_types
,
ref
node_substs
,
ref
user_substs
,
ref
adjustments
,
ref
pat_binding_modes
,
ref
pat_adjustments
,
...
...
@@ -762,6 +788,7 @@ fn hash_stable<W: StableHasherResult>(&self,
user_provided_tys
.hash_stable
(
hcx
,
hasher
);
node_types
.hash_stable
(
hcx
,
hasher
);
node_substs
.hash_stable
(
hcx
,
hasher
);
user_substs
.hash_stable
(
hcx
,
hasher
);
adjustments
.hash_stable
(
hcx
,
hasher
);
pat_binding_modes
.hash_stable
(
hcx
,
hasher
);
pat_adjustments
.hash_stable
(
hcx
,
hasher
);
...
...
src/librustc/ty/subst.rs
浏览文件 @
1884fe35
...
...
@@ -11,6 +11,7 @@
// Type substitutions.
use
hir
::
def_id
::
DefId
;
use
infer
::
canonical
::
Canonical
;
use
ty
::{
self
,
Lift
,
List
,
Ty
,
TyCtxt
};
use
ty
::
fold
::{
TypeFoldable
,
TypeFolder
,
TypeVisitor
};
...
...
@@ -179,6 +180,8 @@ fn decode<D: Decoder>(d: &mut D) -> Result<Kind<'tcx>, D::Error> {
/// A substitution mapping generic parameters to new values.
pub
type
Substs
<
'tcx
>
=
List
<
Kind
<
'tcx
>>
;
pub
type
CanonicalSubsts
<
'gcx
>
=
Canonical
<
'gcx
,
&
'gcx
Substs
<
'gcx
>>
;
impl
<
'a
,
'gcx
,
'tcx
>
Substs
<
'tcx
>
{
/// Creates a Substs that maps each generic parameter to itself.
pub
fn
identity_for_item
(
tcx
:
TyCtxt
<
'a
,
'gcx
,
'tcx
>
,
def_id
:
DefId
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录