Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
82787c22
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,发现更多精彩内容 >>
提交
82787c22
编写于
12月 26, 2014
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Convert to use `Rc<TraitRef>` in object types (finally!).
上级
4404592f
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
43 addition
and
79 deletion
+43
-79
src/librustc/metadata/decoder.rs
src/librustc/metadata/decoder.rs
+5
-5
src/librustc/metadata/tydecode.rs
src/librustc/metadata/tydecode.rs
+7
-7
src/librustc/metadata/tyencode.rs
src/librustc/metadata/tyencode.rs
+2
-2
src/librustc/middle/astencode.rs
src/librustc/middle/astencode.rs
+6
-6
src/librustc/middle/infer/combine.rs
src/librustc/middle/infer/combine.rs
+2
-2
src/librustc/middle/traits/fulfill.rs
src/librustc/middle/traits/fulfill.rs
+2
-2
src/librustc/middle/ty.rs
src/librustc/middle/ty.rs
+8
-33
src/librustc/middle/ty_fold.rs
src/librustc/middle/ty_fold.rs
+0
-9
src/librustc_typeck/astconv.rs
src/librustc_typeck/astconv.rs
+9
-11
src/librustc_typeck/check/assoc.rs
src/librustc_typeck/check/assoc.rs
+1
-1
src/librustc_typeck/collect.rs
src/librustc_typeck/collect.rs
+1
-1
未找到文件。
src/librustc/metadata/decoder.rs
浏览文件 @
82787c22
...
...
@@ -245,13 +245,13 @@ pub fn item_type<'tcx>(_item_id: ast::DefId, item: rbml::Doc,
}
fn
doc_trait_ref
<
'tcx
>
(
doc
:
rbml
::
Doc
,
tcx
:
&
ty
::
ctxt
<
'tcx
>
,
cdata
:
Cmd
)
->
ty
::
TraitRef
<
'tcx
>
{
->
Rc
<
ty
::
TraitRef
<
'tcx
>
>
{
parse_trait_ref_data
(
doc
.data
,
cdata
.cnum
,
doc
.start
,
tcx
,
|
_
,
did
|
translate_def_id
(
cdata
,
did
))
}
fn
item_trait_ref
<
'tcx
>
(
doc
:
rbml
::
Doc
,
tcx
:
&
ty
::
ctxt
<
'tcx
>
,
cdata
:
Cmd
)
->
ty
::
TraitRef
<
'tcx
>
{
->
Rc
<
ty
::
TraitRef
<
'tcx
>
>
{
let
tp
=
reader
::
get_doc
(
doc
,
tag_item_trait_ref
);
doc_trait_ref
(
tp
,
tcx
,
cdata
)
}
...
...
@@ -394,7 +394,7 @@ pub fn get_trait_def<'tcx>(cdata: Cmd,
unsafety
:
unsafety
,
generics
:
generics
,
bounds
:
bounds
,
trait_ref
:
Rc
::
new
(
item_trait_ref
(
item_doc
,
tcx
,
cdata
)
),
trait_ref
:
item_trait_ref
(
item_doc
,
tcx
,
cdata
),
associated_type_names
:
associated_type_names
,
}
}
...
...
@@ -441,7 +441,7 @@ pub fn get_impl_trait<'tcx>(cdata: Cmd,
{
let
item_doc
=
lookup_item
(
id
,
cdata
.data
());
reader
::
maybe_get_doc
(
item_doc
,
tag_item_trait_ref
)
.map
(|
tp
|
{
Rc
::
new
(
doc_trait_ref
(
tp
,
tcx
,
cdata
)
)
doc_trait_ref
(
tp
,
tcx
,
cdata
)
})
}
...
...
@@ -937,7 +937,7 @@ pub fn get_supertraits<'tcx>(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt<'tcx>)
// FIXME(#8559): The builtin bounds shouldn't be encoded in the first place.
let
trait_ref
=
doc_trait_ref
(
trait_doc
,
tcx
,
cdata
);
if
tcx
.lang_items
.to_builtin_kind
(
trait_ref
.def_id
)
.is_none
()
{
results
.push
(
Rc
::
new
(
trait_ref
)
);
results
.push
(
trait_ref
);
}
true
});
...
...
src/librustc/metadata/tydecode.rs
浏览文件 @
82787c22
...
...
@@ -180,7 +180,7 @@ pub fn parse_bare_fn_ty_data<'tcx>(data: &[u8], crate_num: ast::CrateNum, pos: u
pub
fn
parse_trait_ref_data
<
'tcx
>
(
data
:
&
[
u8
],
crate_num
:
ast
::
CrateNum
,
pos
:
uint
,
tcx
:
&
ty
::
ctxt
<
'tcx
>
,
conv
:
conv_did
)
->
ty
::
TraitRef
<
'tcx
>
{
->
Rc
<
ty
::
TraitRef
<
'tcx
>
>
{
debug!
(
"parse_trait_ref_data {}"
,
data_log_string
(
data
,
pos
));
let
mut
st
=
parse_state_from_data
(
data
,
crate_num
,
pos
,
tcx
);
parse_trait_ref
(
&
mut
st
,
conv
)
...
...
@@ -377,10 +377,10 @@ fn parse_str(st: &mut PState, term: char) -> String {
}
fn
parse_trait_ref
<
'a
,
'tcx
>
(
st
:
&
mut
PState
<
'a
,
'tcx
>
,
conv
:
conv_did
)
->
ty
::
TraitRef
<
'tcx
>
{
->
Rc
<
ty
::
TraitRef
<
'tcx
>
>
{
let
def
=
parse_def
(
st
,
NominalType
,
|
x
,
y
|
conv
(
x
,
y
));
let
substs
=
parse_substs
(
st
,
|
x
,
y
|
conv
(
x
,
y
));
ty
::
TraitRef
{
def_id
:
def
,
substs
:
st
.tcx
.mk_substs
(
substs
)}
let
substs
=
st
.tcx
.mk_substs
(
parse_substs
(
st
,
|
x
,
y
|
conv
(
x
,
y
)
));
Rc
::
new
(
ty
::
TraitRef
{
def_id
:
def
,
substs
:
substs
})
}
fn
parse_ty
<
'a
,
'tcx
>
(
st
:
&
mut
PState
<
'a
,
'tcx
>
,
conv
:
conv_did
)
->
Ty
<
'tcx
>
{
...
...
@@ -689,7 +689,7 @@ pub fn parse_predicate<'a,'tcx>(st: &mut PState<'a, 'tcx>,
->
ty
::
Predicate
<
'tcx
>
{
match
next
(
st
)
{
't'
=>
ty
::
Binder
(
Rc
::
new
(
parse_trait_ref
(
st
,
conv
)
))
.as_predicate
(),
't'
=>
ty
::
Binder
(
parse_trait_ref
(
st
,
conv
))
.as_predicate
(),
'e'
=>
ty
::
Binder
(
ty
::
EquatePredicate
(
parse_ty
(
st
,
|
x
,
y
|
conv
(
x
,
y
)),
parse_ty
(
st
,
|
x
,
y
|
conv
(
x
,
y
))))
.as_predicate
(),
'r'
=>
ty
::
Binder
(
ty
::
OutlivesPredicate
(
parse_region
(
st
,
|
x
,
y
|
conv
(
x
,
y
)),
...
...
@@ -708,7 +708,7 @@ fn parse_projection_predicate<'a,'tcx>(
{
ty
::
ProjectionPredicate
{
projection_ty
:
ty
::
ProjectionTy
{
trait_ref
:
Rc
::
new
(
parse_trait_ref
(
st
,
|
x
,
y
|
conv
(
x
,
y
)
)),
trait_ref
:
parse_trait_ref
(
st
,
|
x
,
y
|
conv
(
x
,
y
)),
item_name
:
token
::
str_to_ident
(
parse_str
(
st
,
'|'
)
.as_slice
())
.name
,
},
ty
:
parse_ty
(
st
,
|
x
,
y
|
conv
(
x
,
y
)),
...
...
@@ -795,7 +795,7 @@ fn parse_bounds<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did)
}
'I'
=>
{
param_bounds
.trait_bounds
.push
(
ty
::
Binder
(
Rc
::
new
(
parse_trait_ref
(
st
,
|
x
,
y
|
conv
(
x
,
y
)
))));
ty
::
Binder
(
parse_trait_ref
(
st
,
|
x
,
y
|
conv
(
x
,
y
))));
}
'P'
=>
{
param_bounds
.projection_bounds
.push
(
...
...
src/librustc/metadata/tyencode.rs
浏览文件 @
82787c22
...
...
@@ -91,7 +91,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>, t: Ty<'t
ty
::
ty_trait
(
box
ty
::
TyTrait
{
ref
principal
,
ref
bounds
})
=>
{
mywrite!
(
w
,
"x["
);
enc_trait_ref
(
w
,
cx
,
&
principal
.0
);
enc_trait_ref
(
w
,
cx
,
&
*
principal
.0
);
enc_existential_bounds
(
w
,
cx
,
bounds
);
mywrite!
(
w
,
"]"
);
}
...
...
@@ -151,7 +151,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>, t: Ty<'t
}
ty
::
ty_projection
(
ref
data
)
=>
{
mywrite!
(
w
,
"P["
);
enc_trait_ref
(
w
,
cx
,
&
data
.trait_ref
);
enc_trait_ref
(
w
,
cx
,
&
*
data
.trait_ref
);
mywrite!
(
w
,
"{}]"
,
token
::
get_name
(
data
.item_name
));
}
ty
::
ty_err
=>
{
...
...
src/librustc/middle/astencode.rs
浏览文件 @
82787c22
...
...
@@ -1120,7 +1120,7 @@ fn emit_unsize_kind<'b>(&mut self, ecx: &e::EncodeContext<'b, 'tcx>,
this
.emit_enum_variant
(
"UnsizeVtable"
,
2
,
4
,
|
this
|
{
this
.emit_enum_variant_arg
(
0
,
|
this
|
{
try!
(
this
.emit_struct_field
(
"principal"
,
0
,
|
this
|
{
Ok
(
this
.emit_trait_ref
(
ecx
,
&
principal
.0
))
Ok
(
this
.emit_trait_ref
(
ecx
,
&
*
principal
.0
))
}));
this
.emit_struct_field
(
"bounds"
,
1
,
|
this
|
{
Ok
(
this
.emit_existential_bounds
(
ecx
,
b
))
...
...
@@ -1546,7 +1546,7 @@ fn read_tys<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>)
fn
read_trait_ref
<
'b
,
'c
>
(
&
mut
self
,
dcx
:
&
DecodeContext
<
'b
,
'c
,
'tcx
>
)
->
Rc
<
ty
::
TraitRef
<
'tcx
>>
{
Rc
::
new
(
self
.read_opaque
(|
this
,
doc
|
{
self
.read_opaque
(|
this
,
doc
|
{
let
ty
=
tydecode
::
parse_trait_ref_data
(
doc
.data
,
dcx
.cdata.cnum
,
...
...
@@ -1554,12 +1554,12 @@ fn read_trait_ref<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>)
dcx
.tcx
,
|
s
,
a
|
this
.convert_def_id
(
dcx
,
s
,
a
));
Ok
(
ty
)
})
.unwrap
()
)
})
.unwrap
()
}
fn
read_poly_trait_ref
<
'b
,
'c
>
(
&
mut
self
,
dcx
:
&
DecodeContext
<
'b
,
'c
,
'tcx
>
)
->
ty
::
PolyTraitRef
<
'tcx
>
{
ty
::
Binder
(
Rc
::
new
(
self
.read_opaque
(|
this
,
doc
|
{
ty
::
Binder
(
self
.read_opaque
(|
this
,
doc
|
{
let
ty
=
tydecode
::
parse_trait_ref_data
(
doc
.data
,
dcx
.cdata.cnum
,
...
...
@@ -1567,7 +1567,7 @@ fn read_poly_trait_ref<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>)
dcx
.tcx
,
|
s
,
a
|
this
.convert_def_id
(
dcx
,
s
,
a
));
Ok
(
ty
)
})
.unwrap
())
)
})
.unwrap
())
}
fn
read_type_param_def
<
'b
,
'c
>
(
&
mut
self
,
dcx
:
&
DecodeContext
<
'b
,
'c
,
'tcx
>
)
...
...
@@ -1786,7 +1786,7 @@ fn read_unsize_kind<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>)
Ok
(
this
.read_poly_trait_ref
(
dcx
))
}));
Ok
(
ty
::
TyTrait
{
principal
:
ty
::
Binder
((
*
principal
.0
)
.clone
())
,
principal
:
principal
,
bounds
:
try!
(
this
.read_struct_field
(
"bounds"
,
1
,
|
this
|
{
Ok
(
this
.read_existential_bounds
(
dcx
))
})),
...
...
src/librustc/middle/infer/combine.rs
浏览文件 @
82787c22
...
...
@@ -596,8 +596,8 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C,
(
&
ty
::
ty_projection
(
ref
a_data
),
&
ty
::
ty_projection
(
ref
b_data
))
=>
{
if
a_data
.item_name
==
b_data
.item_name
{
let
trait_ref
=
try!
(
this
.trait_refs
(
&
a_data
.trait_ref
,
&
b_data
.trait_ref
));
Ok
(
ty
::
mk_projection
(
tcx
,
trait_ref
,
a_data
.item_name
))
let
trait_ref
=
try!
(
this
.trait_refs
(
&
*
a_data
.trait_ref
,
&*
b_data
.trait_ref
));
Ok
(
ty
::
mk_projection
(
tcx
,
Rc
::
new
(
trait_ref
)
,
a_data
.item_name
))
}
else
{
Err
(
ty
::
terr_sorts
(
expected_found
(
this
,
a
,
b
)))
}
...
...
src/librustc/middle/traits/fulfill.rs
浏览文件 @
82787c22
...
...
@@ -422,8 +422,8 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
// somewhat constrained, and we cannot verify
// that constraint, so yield an error.
let
ty_projection
=
ty
::
mk_projection
(
tcx
,
(
*
trait_ref
.0
)
.clone
(),
data
.0
.projection_ty.item_name
);
trait_ref
.0
.clone
(),
data
.0
.projection_ty.item_name
);
debug!
(
"process_predicate: falling back to projection {}"
,
ty_projection
.repr
(
selcx
.tcx
()));
...
...
src/librustc/middle/ty.rs
浏览文件 @
82787c22
...
...
@@ -1352,13 +1352,13 @@ pub enum sty<'tcx> {
ty_closure
(
Box
<
ClosureTy
<
'tcx
>>
),
ty_trait
(
Box
<
TyTrait
<
'tcx
>>
),
ty_struct
(
DefId
,
&
'tcx
Substs
<
'tcx
>
),
ty_struct
(
DefId
,
Substs
<
'tcx
>
),
ty_unboxed_closure
(
DefId
,
&
'tcx
Region
,
&
'tcx
Substs
<
'tcx
>
),
ty_tup
(
Vec
<
Ty
<
'tcx
>>
),
ty_projection
(
Box
<
TyProjection
<
'tcx
>
>
),
ty_projection
(
ProjectionTy
<
'tcx
>
),
ty_param
(
ParamTy
),
// type parameter
ty_open
(
Ty
<
'tcx
>
),
// A deref'ed fat pointer, i.e., a dynamically sized value
...
...
@@ -1375,8 +1375,7 @@ pub enum sty<'tcx> {
#[deriving(Clone,
PartialEq,
Eq,
Hash,
Show)]
pub
struct
TyTrait
<
'tcx
>
{
// Principal trait reference.
pub
principal
:
ty
::
Binder
<
TraitRef
<
'tcx
>>
,
pub
principal
:
ty
::
PolyTraitRef
<
'tcx
>
,
pub
bounds
:
ExistentialBounds
}
...
...
@@ -1448,12 +1447,6 @@ pub fn to_poly_trait_predicate(&self) -> PolyTraitPredicate<'tcx> {
// Note that we preserve binding levels
Binder
(
TraitPredicate
{
trait_ref
:
self
.0
.clone
()
})
}
pub
fn
remove_rc
(
&
self
)
->
ty
::
Binder
<
ty
::
TraitRef
<
'tcx
>>
{
// Annoyingly, we can't easily put a `Rc` into a `sty` structure,
// and hence we have to remove the rc to put this into a `TyTrait`.
ty
::
Binder
((
*
self
.0
)
.clone
())
}
}
/// Binder is a binder for higher-ranked lifetimes. It is part of the
...
...
@@ -1833,15 +1826,6 @@ pub struct ProjectionTy<'tcx> {
pub
item_name
:
ast
::
Name
,
}
// Annoying: a version of `ProjectionTy` that avoids the `Rc`, because
// it is difficult to place an `Rc` in the `sty` struct. Eventually
// these two types ought to be unified.
#[deriving(Clone,
PartialEq,
Eq,
Hash,
Show)]
pub
struct
TyProjection
<
'tcx
>
{
pub
trait_ref
:
ty
::
TraitRef
<
'tcx
>
,
pub
item_name
:
ast
::
Name
,
}
pub
trait
ToPolyTraitRef
<
'tcx
>
{
fn
to_poly_trait_ref
(
&
self
)
->
PolyTraitRef
<
'tcx
>
;
}
...
...
@@ -2690,10 +2674,9 @@ pub fn mk_ctor_fn<'tcx>(cx: &ctxt<'tcx>,
}
pub
fn
mk_trait
<
'tcx
>
(
cx
:
&
ctxt
<
'tcx
>
,
principal
:
ty
::
Binder
<
ty
::
TraitRef
<
'tcx
>
>
,
principal
:
ty
::
PolyTraitRef
<
'tcx
>
,
bounds
:
ExistentialBounds
)
->
Ty
<
'tcx
>
{
// take a copy of substs so that we own the vectors inside
let
inner
=
box
TyTrait
{
principal
:
principal
,
bounds
:
bounds
...
...
@@ -2702,11 +2685,11 @@ pub fn mk_trait<'tcx>(cx: &ctxt<'tcx>,
}
pub
fn
mk_projection
<
'tcx
>
(
cx
:
&
ctxt
<
'tcx
>
,
trait_ref
:
ty
::
TraitRef
<
'tcx
>
,
trait_ref
:
Rc
<
ty
::
TraitRef
<
'tcx
>
>
,
item_name
:
ast
::
Name
)
->
Ty
<
'tcx
>
{
// take a copy of substs so that we own the vectors inside
let
inner
=
box
TyProjection
{
trait_ref
:
trait_ref
,
item_name
:
item_name
};
let
inner
=
ProjectionTy
{
trait_ref
:
trait_ref
,
item_name
:
item_name
};
mk_t
(
cx
,
ty_projection
(
inner
))
}
...
...
@@ -2776,7 +2759,7 @@ pub fn maybe_walk_ty<'tcx>(ty: Ty<'tcx>, f: |Ty<'tcx>| -> bool) {
maybe_walk_ty
(
*
subty
,
|
x
|
f
(
x
));
}
}
ty_projection
(
box
TyProjection
{
ref
trait_ref
,
..
})
=>
{
ty_projection
(
ProjectionTy
{
ref
trait_ref
,
..
})
=>
{
for
subty
in
trait_ref
.substs.types
.iter
()
{
maybe_walk_ty
(
*
subty
,
|
x
|
f
(
x
));
}
...
...
@@ -5783,7 +5766,7 @@ pub fn each_bound_trait_and_supertraits<'tcx, F>(tcx: &ctxt<'tcx>,
pub
fn
object_region_bounds
<
'tcx
>
(
tcx
:
&
ctxt
<
'tcx
>
,
opt_principal
:
Option
<&
Binder
<
TraitRef
<
'tcx
>
>>
,
// None for closures
opt_principal
:
Option
<&
PolyTraitRef
<
'tcx
>>
,
// None for closures
others
:
BuiltinBounds
)
->
Vec
<
ty
::
Region
>
{
...
...
@@ -6913,14 +6896,6 @@ fn repr(&self, tcx: &ctxt<'tcx>) -> String {
}
}
impl
<
'tcx
>
Repr
<
'tcx
>
for
ty
::
TyProjection
<
'tcx
>
{
fn
repr
(
&
self
,
tcx
:
&
ctxt
<
'tcx
>
)
->
String
{
format!
(
"TyProjection({}, {})"
,
self
.trait_ref
.repr
(
tcx
),
self
.item_name
.repr
(
tcx
))
}
}
pub
trait
HasProjectionTypes
{
fn
has_projection_types
(
&
self
)
->
bool
;
}
...
...
src/librustc/middle/ty_fold.rs
浏览文件 @
82787c22
...
...
@@ -436,15 +436,6 @@ fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::ProjectionTy<'tc
}
}
impl
<
'tcx
>
TypeFoldable
<
'tcx
>
for
ty
::
TyProjection
<
'tcx
>
{
fn
fold_with
<
F
:
TypeFolder
<
'tcx
>>
(
&
self
,
folder
:
&
mut
F
)
->
ty
::
TyProjection
<
'tcx
>
{
ty
::
TyProjection
{
trait_ref
:
self
.trait_ref
.fold_with
(
folder
),
item_name
:
self
.item_name
,
}
}
}
impl
<
'tcx
>
TypeFoldable
<
'tcx
>
for
ty
::
GenericBounds
<
'tcx
>
{
fn
fold_with
<
F
:
TypeFolder
<
'tcx
>>
(
&
self
,
folder
:
&
mut
F
)
->
ty
::
GenericBounds
<
'tcx
>
{
ty
::
GenericBounds
{
...
...
src/librustc_typeck/astconv.rs
浏览文件 @
82787c22
...
...
@@ -881,7 +881,7 @@ fn ast_ty_to_trait_ref<'tcx,AC,RS>(this: &AC,
fn
trait_ref_to_object_type
<
'tcx
,
AC
,
RS
>
(
this
:
&
AC
,
rscope
:
&
RS
,
span
:
Span
,
trait_ref
:
ty
::
Binder
<
ty
::
TraitRef
<
'tcx
>
>
,
trait_ref
:
ty
::
PolyTraitRef
<
'tcx
>
,
bounds
:
&
[
ast
::
TyParamBound
])
->
Ty
<
'tcx
>
where
AC
:
AstConv
<
'tcx
>
,
RS
:
RegionScope
...
...
@@ -889,7 +889,7 @@ fn trait_ref_to_object_type<'tcx,AC,RS>(this: &AC,
let
existential_bounds
=
conv_existential_bounds
(
this
,
rscope
,
span
,
Some
(
&
trait_ref
),
Some
(
trait_ref
.clone
()
),
bounds
);
let
result
=
ty
::
mk_trait
(
this
.tcx
(),
trait_ref
,
existential_bounds
);
...
...
@@ -1020,7 +1020,6 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
ast
::
TyObjectSum
(
ref
ty
,
ref
bounds
)
=>
{
match
ast_ty_to_trait_ref
(
this
,
rscope
,
&**
ty
,
bounds
[])
{
Ok
(
trait_ref
)
=>
{
let
trait_ref
=
trait_ref
.remove_rc
();
trait_ref_to_object_type
(
this
,
rscope
,
ast_ty
.span
,
trait_ref
,
bounds
[])
}
...
...
@@ -1100,7 +1099,6 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
None
,
path
,
Some
(
&
mut
projections
));
let
trait_ref
=
(
*
trait_ref
)
.clone
();
let
trait_ref
=
ty
::
Binder
(
trait_ref
);
trait_ref_to_object_type
(
this
,
rscope
,
path
.span
,
trait_ref
,
&
[])
}
...
...
@@ -1501,7 +1499,7 @@ pub fn conv_existential_bounds<'tcx, AC: AstConv<'tcx>, RS:RegionScope>(
this
:
&
AC
,
rscope
:
&
RS
,
span
:
Span
,
principal_trait_ref
:
Option
<
&
ty
::
Binder
<
ty
::
TraitRef
<
'tcx
>
>>
,
// None for boxed closures
principal_trait_ref
:
Option
<
ty
::
PolyTraitRef
<
'tcx
>>
,
// None for boxed closures
ast_bounds
:
&
[
ast
::
TyParamBound
])
->
ty
::
ExistentialBounds
{
...
...
@@ -1530,7 +1528,7 @@ fn conv_ty_poly_trait_ref<'tcx, AC, RS>(
trait_bound
,
None
,
&
mut
projections
);
Some
(
ptr
.remove_rc
()
)
Some
(
ptr
)
}
None
=>
{
this
.tcx
()
.sess
.span_err
(
...
...
@@ -1546,7 +1544,7 @@ fn conv_ty_poly_trait_ref<'tcx, AC, RS>(
conv_existential_bounds_from_partitioned_bounds
(
this
,
rscope
,
span
,
main_trait_bound
.
as_ref
(),
main_trait_bound
.
clone
(),
partitioned_bounds
);
match
main_trait_bound
{
...
...
@@ -1559,7 +1557,7 @@ pub fn conv_existential_bounds_from_partitioned_bounds<'tcx, AC, RS>(
this
:
&
AC
,
rscope
:
&
RS
,
span
:
Span
,
principal_trait_ref
:
Option
<
&
ty
::
Binder
<
ty
::
TraitRef
<
'tcx
>
>>
,
// None for boxed closures
principal_trait_ref
:
Option
<
ty
::
PolyTraitRef
<
'tcx
>>
,
// None for boxed closures
partitioned_bounds
:
PartitionedBounds
)
->
ty
::
ExistentialBounds
where
AC
:
AstConv
<
'tcx
>
,
RS
:
RegionScope
...
...
@@ -1597,7 +1595,7 @@ pub fn conv_existential_bounds_from_partitioned_bounds<'tcx, AC, RS>(
fn
compute_opt_region_bound
<
'tcx
>
(
tcx
:
&
ty
::
ctxt
<
'tcx
>
,
span
:
Span
,
explicit_region_bounds
:
&
[
&
ast
::
Lifetime
],
principal_trait_ref
:
Option
<
&
ty
::
Binder
<
ty
::
TraitRef
<
'tcx
>
>>
,
principal_trait_ref
:
Option
<
ty
::
PolyTraitRef
<
'tcx
>>
,
builtin_bounds
:
ty
::
BuiltinBounds
)
->
Option
<
ty
::
Region
>
{
...
...
@@ -1622,7 +1620,7 @@ fn compute_opt_region_bound<'tcx>(tcx: &ty::ctxt<'tcx>,
// No explicit region bound specified. Therefore, examine trait
// bounds and see if we can derive region bounds from those.
let
derived_region_bounds
=
ty
::
object_region_bounds
(
tcx
,
principal_trait_ref
,
builtin_bounds
);
ty
::
object_region_bounds
(
tcx
,
principal_trait_ref
.as_ref
()
,
builtin_bounds
);
// If there are no derived region bounds, then report back that we
// can find no region bound.
...
...
@@ -1657,7 +1655,7 @@ fn compute_region_bound<'tcx, AC: AstConv<'tcx>, RS:RegionScope>(
rscope
:
&
RS
,
span
:
Span
,
region_bounds
:
&
[
&
ast
::
Lifetime
],
principal_trait_ref
:
Option
<
&
ty
::
Binder
<
ty
::
TraitRef
<
'tcx
>
>>
,
// None for closures
principal_trait_ref
:
Option
<
ty
::
PolyTraitRef
<
'tcx
>>
,
// None for closures
builtin_bounds
:
ty
::
BuiltinBounds
)
->
ty
::
Region
{
...
...
src/librustc_typeck/check/assoc.rs
浏览文件 @
82787c22
...
...
@@ -58,7 +58,7 @@ fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
self
.span
,
self
.body_id
,
ObligationCauseCode
::
MiscObligation
);
let
trait_ref
=
Rc
::
new
(
data
.trait_ref
.clone
()
);
let
trait_ref
=
data
.trait_ref
.clone
(
);
self
.fulfillment_cx
.normalize_associated_type
(
self
.infcx
,
trait_ref
,
...
...
src/librustc_typeck/collect.rs
浏览文件 @
82787c22
...
...
@@ -177,7 +177,7 @@ fn projected_ty(&self,
item_name
:
ast
::
Name
)
->
Ty
<
'tcx
>
{
ty
::
mk_projection
(
self
.tcx
,
(
*
trait_ref
)
.clone
()
,
item_name
)
ty
::
mk_projection
(
self
.tcx
,
trait_ref
,
item_name
)
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录