Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
91aa9960
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,发现更多精彩内容 >>
提交
91aa9960
编写于
8月 07, 2017
作者:
S
scalexm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Do not store `ty`
上级
91e99a32
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
16 addition
and
28 deletion
+16
-28
src/librustc/traits/mod.rs
src/librustc/traits/mod.rs
+2
-5
src/librustc/traits/select.rs
src/librustc/traits/select.rs
+4
-5
src/librustc/traits/structural_impls.rs
src/librustc/traits/structural_impls.rs
+4
-12
src/librustc_mir/shim.rs
src/librustc_mir/shim.rs
+4
-4
src/librustc_trans/monomorphize.rs
src/librustc_trans/monomorphize.rs
+2
-2
未找到文件。
src/librustc/traits/mod.rs
浏览文件 @
91aa9960
...
...
@@ -301,7 +301,7 @@ pub enum Vtable<'tcx, N> {
VtableObject
(
VtableObjectData
<
'tcx
,
N
>
),
/// Successful resolution for a builtin trait.
VtableBuiltin
(
VtableBuiltinData
<
'tcx
,
N
>
),
VtableBuiltin
(
VtableBuiltinData
<
N
>
),
/// Vtable automatically generated for a closure. The def ID is the ID
/// of the closure expression. This is a `VtableImpl` in spirit, but the
...
...
@@ -345,9 +345,7 @@ pub struct VtableDefaultImplData<N> {
}
#[derive(Clone)]
pub
struct
VtableBuiltinData
<
'tcx
,
N
>
{
/// `ty` can be used for generating shim for builtin implementations like `Clone::clone`.
pub
ty
:
ty
::
Ty
<
'tcx
>
,
pub
struct
VtableBuiltinData
<
N
>
{
pub
nested
:
Vec
<
N
>
}
...
...
@@ -771,7 +769,6 @@ pub fn map<M, F>(self, f: F) -> Vtable<'tcx, M> where F: FnMut(N) -> M {
}),
VtableParam
(
n
)
=>
VtableParam
(
n
.into_iter
()
.map
(
f
)
.collect
()),
VtableBuiltin
(
i
)
=>
VtableBuiltin
(
VtableBuiltinData
{
ty
:
i
.ty
,
nested
:
i
.nested
.into_iter
()
.map
(
f
)
.collect
(),
}),
VtableObject
(
o
)
=>
VtableObject
(
VtableObjectData
{
...
...
src/librustc/traits/select.rs
浏览文件 @
91aa9960
...
...
@@ -2265,7 +2265,7 @@ fn confirm_param_candidate(&mut self,
fn
confirm_builtin_candidate
(
&
mut
self
,
obligation
:
&
TraitObligation
<
'tcx
>
,
has_nested
:
bool
)
->
VtableBuiltinData
<
'tcx
,
PredicateObligation
<
'tcx
>>
->
VtableBuiltinData
<
PredicateObligation
<
'tcx
>>
{
debug!
(
"confirm_builtin_candidate({:?}, {:?})"
,
obligation
,
has_nested
);
...
...
@@ -2303,8 +2303,7 @@ fn confirm_builtin_candidate(&mut self,
debug!
(
"confirm_builtin_candidate: obligations={:?}"
,
obligations
);
let
self_ty
=
self
.infcx
.shallow_resolve
(
obligation
.predicate
.skip_binder
()
.self_ty
());
VtableBuiltinData
{
ty
:
self_ty
,
nested
:
obligations
}
VtableBuiltinData
{
nested
:
obligations
}
}
/// This handles the case where a `impl Foo for ..` impl is being used.
...
...
@@ -2611,7 +2610,7 @@ fn confirm_poly_trait_refs(&mut self,
fn
confirm_builtin_unsize_candidate
(
&
mut
self
,
obligation
:
&
TraitObligation
<
'tcx
>
,)
->
Result
<
VtableBuiltinData
<
'tcx
,
PredicateObligation
<
'tcx
>>
,
SelectionError
<
'tcx
>>
->
Result
<
VtableBuiltinData
<
PredicateObligation
<
'tcx
>>
,
SelectionError
<
'tcx
>>
{
let
tcx
=
self
.tcx
();
...
...
@@ -2814,7 +2813,7 @@ fn confirm_builtin_unsize_candidate(&mut self,
_
=>
bug!
()
};
Ok
(
VtableBuiltinData
{
ty
:
source
,
nested
:
nested
})
Ok
(
VtableBuiltinData
{
nested
:
nested
})
}
///////////////////////////////////////////////////////////////////////////
...
...
src/librustc/traits/structural_impls.rs
浏览文件 @
91aa9960
...
...
@@ -86,9 +86,9 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
}
}
impl
<
'tcx
,
N
:
fmt
::
Debug
>
fmt
::
Debug
for
traits
::
VtableBuiltinData
<
'tcx
,
N
>
{
impl
<
'tcx
,
N
:
fmt
::
Debug
>
fmt
::
Debug
for
traits
::
VtableBuiltinData
<
N
>
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
write!
(
f
,
"VtableBuiltin(
ty={:?}, nested={:?})"
,
self
.ty
,
self
.nested
)
write!
(
f
,
"VtableBuiltin(
nested={:?})"
,
self
.nested
)
}
}
...
...
@@ -300,14 +300,7 @@ fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lif
})
}
traits
::
VtableParam
(
n
)
=>
Some
(
traits
::
VtableParam
(
n
)),
traits
::
VtableBuiltin
(
traits
::
VtableBuiltinData
{
ty
,
nested
})
=>
{
tcx
.lift
(
&
ty
)
.map
(|
ty
|
{
traits
::
VtableBuiltin
(
traits
::
VtableBuiltinData
{
ty
,
nested
,
})
})
}
traits
::
VtableBuiltin
(
n
)
=>
Some
(
traits
::
VtableBuiltin
(
n
)),
traits
::
VtableObject
(
traits
::
VtableObjectData
{
upcast_trait_ref
,
vtable_base
,
...
...
@@ -385,10 +378,9 @@ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
}
}
impl
<
'tcx
,
N
:
TypeFoldable
<
'tcx
>>
TypeFoldable
<
'tcx
>
for
traits
::
VtableBuiltinData
<
'tcx
,
N
>
{
impl
<
'tcx
,
N
:
TypeFoldable
<
'tcx
>>
TypeFoldable
<
'tcx
>
for
traits
::
VtableBuiltinData
<
N
>
{
fn
super_fold_with
<
'gcx
:
'tcx
,
F
:
TypeFolder
<
'gcx
,
'tcx
>>
(
&
self
,
folder
:
&
mut
F
)
->
Self
{
traits
::
VtableBuiltinData
{
ty
:
self
.ty
.fold_with
(
folder
),
nested
:
self
.nested
.fold_with
(
folder
),
}
}
...
...
src/librustc_mir/shim.rs
浏览文件 @
91aa9960
...
...
@@ -275,7 +275,7 @@ fn downcast_subpath(&self, _path: Self::Path, _variant: usize) -> Option<Self::P
/// Build a `Clone::clone` shim for `recvr_ty`. Here, `def_id` is `Clone::clone`.
fn
build_clone_shim
<
'a
,
'tcx
>
(
tcx
:
ty
::
TyCtxt
<
'a
,
'tcx
,
'tcx
>
,
def_id
:
DefId
,
r
e
cvr_ty
:
ty
::
Ty
<
'tcx
>
)
rcvr_ty
:
ty
::
Ty
<
'tcx
>
)
->
Mir
<
'tcx
>
{
let
sig
=
tcx
.fn_sig
(
def_id
);
...
...
@@ -348,7 +348,7 @@ fn build_clone_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
loc
};
match
r
e
cvr_ty
.sty
{
match
rcvr_ty
.sty
{
ty
::
TyArray
(
ty
,
len
)
=>
{
let
mut
returns
=
Vec
::
new
();
for
i
in
0
..
len
{
...
...
@@ -374,7 +374,7 @@ fn build_clone_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
Lvalue
::
Local
(
RETURN_POINTER
),
Rvalue
::
Aggregate
(
box
AggregateKind
::
Array
(
ty
),
returns
.into_iter
()
.map
(
|
loc
|
Operand
::
Consume
(
loc
)
)
.collect
()
returns
.into_iter
()
.map
(
Operand
::
Consume
)
.collect
()
)
)
};
...
...
@@ -396,7 +396,7 @@ fn build_clone_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
Lvalue
::
Local
(
RETURN_POINTER
),
Rvalue
::
Aggregate
(
box
AggregateKind
::
Tuple
,
returns
.into_iter
()
.map
(
|
loc
|
Operand
::
Consume
(
loc
)
)
.collect
()
returns
.into_iter
()
.map
(
Operand
::
Consume
)
.collect
()
)
)
};
...
...
src/librustc_trans/monomorphize.rs
浏览文件 @
91aa9960
...
...
@@ -143,9 +143,9 @@ fn resolve_associated_item<'a, 'tcx>(
substs
:
rcvr_substs
}
}
traits
::
VtableBuiltin
(
ref
data
)
=>
{
traits
::
VtableBuiltin
(
..
)
=>
{
Instance
{
def
:
ty
::
InstanceDef
::
BuiltinShim
(
def_id
,
data
.ty
),
def
:
ty
::
InstanceDef
::
BuiltinShim
(
def_id
,
trait_ref
.self_ty
()
),
substs
:
rcvr_substs
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录