Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
9c3c3068
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,发现更多精彩内容 >>
提交
9c3c3068
编写于
2月 14, 2017
作者:
E
Eduard-Mihai Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc_typeck: move the leaves (generics, trait_def, adt_def) to on-demand.
上级
3146ee86
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
288 addition
and
335 deletion
+288
-335
src/librustc/util/ppaux.rs
src/librustc/util/ppaux.rs
+1
-10
src/librustc_driver/driver.rs
src/librustc_driver/driver.rs
+1
-0
src/librustc_typeck/astconv.rs
src/librustc_typeck/astconv.rs
+4
-11
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+0
-8
src/librustc_typeck/collect.rs
src/librustc_typeck/collect.rs
+277
-306
src/librustc_typeck/lib.rs
src/librustc_typeck/lib.rs
+5
-0
未找到文件。
src/librustc/util/ppaux.rs
浏览文件 @
9c3c3068
...
...
@@ -750,16 +750,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
TyInfer
(
infer_ty
)
=>
write!
(
f
,
"{}"
,
infer_ty
),
TyError
=>
write!
(
f
,
"[type error]"
),
TyParam
(
ref
param_ty
)
=>
write!
(
f
,
"{}"
,
param_ty
),
TyAdt
(
def
,
substs
)
=>
{
ty
::
tls
::
with
(|
tcx
|
{
if
def
.did
.is_local
()
&&
!
tcx
.maps.ty
.borrow
()
.contains_key
(
&
def
.did
)
{
write!
(
f
,
"{}<..>"
,
tcx
.item_path_str
(
def
.did
))
}
else
{
parameterized
(
f
,
substs
,
def
.did
,
&
[])
}
})
}
TyAdt
(
def
,
substs
)
=>
parameterized
(
f
,
substs
,
def
.did
,
&
[]),
TyDynamic
(
data
,
r
)
=>
{
write!
(
f
,
"{}"
,
data
)
?
;
let
r
=
r
.to_string
();
...
...
src/librustc_driver/driver.rs
浏览文件 @
9c3c3068
...
...
@@ -873,6 +873,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
let
mut
local_providers
=
ty
::
maps
::
Providers
::
default
();
mir
::
mir_map
::
provide
(
&
mut
local_providers
);
typeck
::
provide
(
&
mut
local_providers
);
let
mut
extern_providers
=
ty
::
maps
::
Providers
::
default
();
cstore
::
provide
(
&
mut
extern_providers
);
...
...
src/librustc_typeck/astconv.rs
浏览文件 @
9c3c3068
...
...
@@ -51,16 +51,9 @@ pub trait AstConv<'gcx, 'tcx> {
/// A cache used for the result of `ast_ty_to_ty_cache`
fn
ast_ty_to_ty_cache
(
&
self
)
->
&
RefCell
<
NodeMap
<
Ty
<
'tcx
>>>
;
/// Returns the generic type and lifetime parameters for an item.
fn
get_generics
(
&
self
,
id
:
DefId
)
->
&
'tcx
ty
::
Generics
;
/// Identify the type for an item, like a type alias, fn, or struct.
fn
get_item_type
(
&
self
,
span
:
Span
,
id
:
DefId
)
->
Ty
<
'tcx
>
;
/// Returns the `TraitDef` for a given trait. This allows you to
/// figure out the set of type parameters defined on the trait.
fn
get_trait_def
(
&
self
,
id
:
DefId
)
->
&
'tcx
ty
::
TraitDef
;
/// Ensure that the super-predicates for the trait with the given
/// id are available and also for the transitive set of
/// super-predicates.
...
...
@@ -248,7 +241,7 @@ fn create_substs_for_ast_path(&self,
// If the type is parameterized by this region, then replace this
// region with the current anon region binding (in other words,
// whatever & would get replaced with).
let
decl_generics
=
self
.get
_generics
(
def_id
);
let
decl_generics
=
tcx
.item
_generics
(
def_id
);
let
expected_num_region_params
=
decl_generics
.regions
.len
();
let
supplied_num_region_params
=
lifetimes
.len
();
if
expected_num_region_params
!=
supplied_num_region_params
{
...
...
@@ -485,7 +478,7 @@ fn create_substs_for_ast_trait_ref(&self,
debug!
(
"create_substs_for_ast_trait_ref(trait_segment={:?})"
,
trait_segment
);
let
trait_def
=
self
.
get
_trait_def
(
trait_def_id
);
let
trait_def
=
self
.
tcx
()
.lookup
_trait_def
(
trait_def_id
);
match
trait_segment
.parameters
{
hir
::
AngleBracketedParameters
(
_
)
=>
{
...
...
@@ -1019,7 +1012,7 @@ pub fn def_to_ty(&self,
let
node_id
=
tcx
.hir
.as_local_node_id
(
did
)
.unwrap
();
let
item_id
=
tcx
.hir
.get_parent_node
(
node_id
);
let
item_def_id
=
tcx
.hir
.local_def_id
(
item_id
);
let
generics
=
self
.get
_generics
(
item_def_id
);
let
generics
=
tcx
.item
_generics
(
item_def_id
);
let
index
=
generics
.type_param_to_index
[
&
tcx
.hir
.local_def_id
(
node_id
)
.index
];
tcx
.mk_param
(
index
,
tcx
.hir
.name
(
node_id
))
}
...
...
@@ -1186,7 +1179,7 @@ pub fn ast_ty_to_ty(&self, ast_ty: &hir::Ty) -> Ty<'tcx> {
// Create the anonymized type.
if
allow
{
let
def_id
=
tcx
.hir
.local_def_id
(
ast_ty
.id
);
self
.get
_generics
(
def_id
);
tcx
.item
_generics
(
def_id
);
let
substs
=
Substs
::
identity_for_item
(
tcx
,
def_id
);
let
ty
=
tcx
.mk_anon
(
tcx
.hir
.local_def_id
(
ast_ty
.id
),
substs
);
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
9c3c3068
...
...
@@ -1353,18 +1353,10 @@ fn ast_ty_to_ty_cache(&self) -> &RefCell<NodeMap<Ty<'tcx>>> {
&
self
.ast_ty_to_ty_cache
}
fn
get_generics
(
&
self
,
id
:
DefId
)
->
&
'tcx
ty
::
Generics
{
self
.tcx
()
.item_generics
(
id
)
}
fn
get_item_type
(
&
self
,
_
:
Span
,
id
:
DefId
)
->
Ty
<
'tcx
>
{
self
.tcx
()
.item_type
(
id
)
}
fn
get_trait_def
(
&
self
,
id
:
DefId
)
->
&
'tcx
ty
::
TraitDef
{
self
.tcx
()
.lookup_trait_def
(
id
)
}
fn
ensure_super_predicates
(
&
self
,
_
:
Span
,
_
:
DefId
)
{
// all super predicates are ensured during collect pass
}
...
...
src/librustc_typeck/collect.rs
浏览文件 @
9c3c3068
此差异已折叠。
点击以展开。
src/librustc_typeck/lib.rs
浏览文件 @
9c3c3068
...
...
@@ -110,6 +110,7 @@
use
rustc
::
infer
::
InferOk
;
use
rustc
::
ty
::
subst
::
Substs
;
use
rustc
::
ty
::{
self
,
Ty
,
TyCtxt
};
use
rustc
::
ty
::
maps
::
Providers
;
use
rustc
::
traits
::{
ObligationCause
,
ObligationCauseCode
,
Reveal
};
use
session
::
config
;
use
util
::
common
::
time
;
...
...
@@ -284,6 +285,10 @@ fn check_for_entry_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
}
}
pub
fn
provide
(
providers
:
&
mut
Providers
)
{
collect
::
provide
(
providers
);
}
pub
fn
check_crate
<
'a
,
'tcx
>
(
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
)
->
Result
<
(),
usize
>
{
let
time_passes
=
tcx
.sess
.time_passes
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录