Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
b640c2b9
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,发现更多精彩内容 >>
提交
b640c2b9
编写于
10月 07, 2017
作者:
J
Jimmy Brisson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
get_vtable_methods => vtable_methods query
上级
4e116e14
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
32 addition
and
8 deletion
+32
-8
src/librustc/dep_graph/dep_node.rs
src/librustc/dep_graph/dep_node.rs
+1
-0
src/librustc/traits/mod.rs
src/librustc/traits/mod.rs
+7
-5
src/librustc/ty/maps/config.rs
src/librustc/ty/maps/config.rs
+6
-0
src/librustc/ty/maps/keys.rs
src/librustc/ty/maps/keys.rs
+9
-0
src/librustc/ty/maps/mod.rs
src/librustc/ty/maps/mod.rs
+6
-0
src/librustc/ty/maps/plumbing.rs
src/librustc/ty/maps/plumbing.rs
+1
-0
src/librustc_trans/collector.rs
src/librustc_trans/collector.rs
+1
-1
src/librustc_trans/meth.rs
src/librustc_trans/meth.rs
+1
-2
未找到文件。
src/librustc/dep_graph/dep_node.rs
浏览文件 @
b640c2b9
...
...
@@ -506,6 +506,7 @@ pub fn fingerprint_needed_for_crate_hash(self) -> bool {
[]
SpecializationGraph
(
DefId
),
[]
ObjectSafety
(
DefId
),
[]
FulfillObligation
{
param_env
:
ParamEnv
<
'tcx
>
,
trait_ref
:
PolyTraitRef
<
'tcx
>
},
[]
VtableMethods
{
trait_ref
:
PolyTraitRef
<
'tcx
>
},
[]
IsCopy
{
param_env
:
ParamEnvAnd
<
'tcx
,
Ty
<
'tcx
>>
},
[]
IsSized
{
param_env
:
ParamEnvAnd
<
'tcx
,
Ty
<
'tcx
>>
},
...
...
src/librustc/traits/mod.rs
浏览文件 @
b640c2b9
...
...
@@ -650,12 +650,12 @@ pub fn normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
/// Given a trait `trait_ref`, iterates the vtable entries
/// that come from `trait_ref`, including its supertraits.
#[inline]
// FIXME(#35870) Avoid closures being unexported due to impl Trait.
pub
fn
get_
vtable_methods
<
'a
,
'tcx
>
(
pub
fn
vtable_methods
<
'a
,
'tcx
>
(
tcx
:
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
trait_ref
:
ty
::
PolyTraitRef
<
'tcx
>
)
->
Vec
<
Option
<
(
DefId
,
&
'tcx
Substs
<
'tcx
>
)
>>
{
debug!
(
"
get_
vtable_methods({:?})"
,
trait_ref
);
debug!
(
"vtable_methods({:?})"
,
trait_ref
);
supertraits
(
tcx
,
trait_ref
)
.flat_map
(
move
|
trait_ref
|
{
let
trait_methods
=
tcx
.associated_items
(
trait_ref
.def_id
())
...
...
@@ -664,12 +664,12 @@ pub fn get_vtable_methods<'a, 'tcx>(
// Now list each method's DefId and Substs (for within its trait).
// If the method can never be called from this object, produce None.
trait_methods
.map
(
move
|
trait_method
|
{
debug!
(
"
get_
vtable_methods: trait_method={:?}"
,
trait_method
);
debug!
(
"vtable_methods: trait_method={:?}"
,
trait_method
);
let
def_id
=
trait_method
.def_id
;
// Some methods cannot be called on an object; skip those.
if
!
tcx
.is_vtable_safe_method
(
trait_ref
.def_id
(),
&
trait_method
)
{
debug!
(
"
get_
vtable_methods: not vtable safe"
);
debug!
(
"vtable_methods: not vtable safe"
);
return
None
;
}
...
...
@@ -690,7 +690,7 @@ pub fn get_vtable_methods<'a, 'tcx>(
// do not want to try and trans it, in that case (see #23435).
let
predicates
=
tcx
.predicates_of
(
def_id
)
.instantiate_own
(
tcx
,
substs
);
if
!
normalize_and_test_predicates
(
tcx
,
predicates
.predicates
)
{
debug!
(
"
get_
vtable_methods: predicates do not hold"
);
debug!
(
"vtable_methods: predicates do not hold"
);
return
None
;
}
...
...
@@ -836,6 +836,7 @@ pub fn provide(providers: &mut ty::maps::Providers) {
specialization_graph_of
:
specialize
::
specialization_graph_provider
,
specializes
:
specialize
::
specializes
,
trans_fulfill_obligation
:
trans
::
trans_fulfill_obligation
,
vtable_methods
,
..*
providers
};
}
...
...
@@ -846,6 +847,7 @@ pub fn provide_extern(providers: &mut ty::maps::Providers) {
specialization_graph_of
:
specialize
::
specialization_graph_provider
,
specializes
:
specialize
::
specializes
,
trans_fulfill_obligation
:
trans
::
trans_fulfill_obligation
,
vtable_methods
,
..*
providers
};
}
src/librustc/ty/maps/config.rs
浏览文件 @
b640c2b9
...
...
@@ -503,6 +503,12 @@ fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
}
}
impl
<
'tcx
>
QueryDescription
for
queries
::
vtable_methods
<
'tcx
>
{
fn
describe
(
tcx
:
TyCtxt
,
key
:
ty
::
PolyTraitRef
<
'tcx
>
)
->
String
{
format!
(
"finding all methods for trait {}"
,
tcx
.item_path_str
(
key
.def_id
()))
}
}
impl
<
'tcx
>
QueryDescription
for
queries
::
has_copy_closures
<
'tcx
>
{
fn
describe
(
_
tcx
:
TyCtxt
,
_
:
CrateNum
)
->
String
{
format!
(
"seeing if the crate has enabled `Copy` closures"
)
...
...
src/librustc/ty/maps/keys.rs
浏览文件 @
b640c2b9
...
...
@@ -143,6 +143,15 @@ fn default_span(&self, tcx: TyCtxt) -> Span {
}
}
impl
<
'tcx
>
Key
for
ty
::
PolyTraitRef
<
'tcx
>
{
fn
map_crate
(
&
self
)
->
CrateNum
{
self
.def_id
()
.krate
}
fn
default_span
(
&
self
,
tcx
:
TyCtxt
)
->
Span
{
tcx
.def_span
(
self
.def_id
())
}
}
impl
<
'tcx
>
Key
for
Ty
<
'tcx
>
{
fn
map_crate
(
&
self
)
->
CrateNum
{
LOCAL_CRATE
...
...
src/librustc/ty/maps/mod.rs
浏览文件 @
b640c2b9
...
...
@@ -228,6 +228,8 @@
[]
fn
item_body_nested_bodies
:
ItemBodyNestedBodies
(
DefId
)
->
ExternBodyNestedBodies
,
[]
fn
const_is_rvalue_promotable_to_static
:
ConstIsRvaluePromotableToStatic
(
DefId
)
->
bool
,
[]
fn
is_mir_available
:
IsMirAvailable
(
DefId
)
->
bool
,
[]
fn
vtable_methods
:
vtable_methods_node
(
ty
::
PolyTraitRef
<
'tcx
>
)
->
Vec
<
Option
<
(
DefId
,
&
'tcx
Substs
<
'tcx
>
)
>>
,
[]
fn
trans_fulfill_obligation
:
fulfill_obligation_dep_node
(
(
ty
::
ParamEnv
<
'tcx
>
,
ty
::
PolyTraitRef
<
'tcx
>
))
->
Vtable
<
'tcx
,
()
>
,
...
...
@@ -470,3 +472,7 @@ fn collect_and_partition_translation_items_node<'tcx>(_: CrateNum) -> DepConstru
fn
output_filenames_node
<
'tcx
>
(
_
:
CrateNum
)
->
DepConstructor
<
'tcx
>
{
DepConstructor
::
OutputFilenames
}
fn
vtable_methods_node
<
'tcx
>
(
trait_ref
:
ty
::
PolyTraitRef
<
'tcx
>
)
->
DepConstructor
<
'tcx
>
{
DepConstructor
::
VtableMethods
{
trait_ref
}
}
src/librustc/ty/maps/plumbing.rs
浏览文件 @
b640c2b9
...
...
@@ -749,6 +749,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
DepKind
::
CodegenUnit
|
DepKind
::
CompileCodegenUnit
|
DepKind
::
FulfillObligation
|
DepKind
::
VtableMethods
|
// These are just odd
DepKind
::
Null
|
...
...
src/librustc_trans/collector.rs
浏览文件 @
b640c2b9
...
...
@@ -849,7 +849,7 @@ fn create_trans_items_for_vtable_methods<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
assert
!
(
!
poly_trait_ref
.has_escaping_regions
());
// Walk all methods of the trait, including those of its supertraits
let
methods
=
t
raits
::
get_vtable_methods
(
tcx
,
poly_trait_ref
);
let
methods
=
t
cx
.vtable_methods
(
poly_trait_ref
);
let
methods
=
methods
.into_iter
()
.filter_map
(|
method
|
method
)
.map
(|(
def_id
,
substs
)|
ty
::
Instance
::
resolve
(
tcx
,
...
...
src/librustc_trans/meth.rs
浏览文件 @
b640c2b9
...
...
@@ -9,7 +9,6 @@
// except according to those terms.
use
llvm
::
ValueRef
;
use
rustc
::
traits
;
use
callee
;
use
common
::
*
;
use
builder
::
Builder
;
...
...
@@ -87,7 +86,7 @@ pub fn get_vtable<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
if
let
Some
(
trait_ref
)
=
trait_ref
{
let
trait_ref
=
trait_ref
.with_self_ty
(
tcx
,
ty
);
let
methods
=
t
raits
::
get_vtable_methods
(
tcx
,
trait_ref
)
.into_iter
()
.map
(|
opt_mth
|
{
let
methods
=
t
cx
.vtable_methods
(
trait_ref
)
.into_iter
()
.map
(|
opt_mth
|
{
opt_mth
.map_or
(
nullptr
,
|(
def_id
,
substs
)|
{
callee
::
resolve_and_get_fn
(
ccx
,
def_id
,
substs
)
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录