Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
8a91d33e
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,发现更多精彩内容 >>
提交
8a91d33e
编写于
10月 01, 2014
作者:
E
Eduard Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: remove support for Gc.
上级
d1a57e47
变更
43
隐藏空白更改
内联
并排
Showing
43 changed file
with
55 addition
and
565 deletion
+55
-565
src/librustc/lint/builtin.rs
src/librustc/lint/builtin.rs
+1
-19
src/librustc/metadata/tydecode.rs
src/librustc/metadata/tydecode.rs
+0
-1
src/librustc/metadata/tyencode.rs
src/librustc/metadata/tyencode.rs
+0
-1
src/librustc/middle/borrowck/check_loans.rs
src/librustc/middle/borrowck/check_loans.rs
+0
-5
src/librustc/middle/borrowck/gather_loans/gather_moves.rs
src/librustc/middle/borrowck/gather_loans/gather_moves.rs
+0
-1
src/librustc/middle/borrowck/gather_loans/lifetime.rs
src/librustc/middle/borrowck/gather_loans/lifetime.rs
+1
-3
src/librustc/middle/borrowck/gather_loans/move_error.rs
src/librustc/middle/borrowck/gather_loans/move_error.rs
+0
-1
src/librustc/middle/borrowck/gather_loans/restrictions.rs
src/librustc/middle/borrowck/gather_loans/restrictions.rs
+1
-4
src/librustc/middle/borrowck/mod.rs
src/librustc/middle/borrowck/mod.rs
+0
-5
src/librustc/middle/check_match.rs
src/librustc/middle/check_match.rs
+1
-6
src/librustc/middle/intrinsicck.rs
src/librustc/middle/intrinsicck.rs
+2
-2
src/librustc/middle/lang_items.rs
src/librustc/middle/lang_items.rs
+0
-4
src/librustc/middle/mem_categorization.rs
src/librustc/middle/mem_categorization.rs
+1
-16
src/librustc/middle/traits/coherence.rs
src/librustc/middle/traits/coherence.rs
+0
-5
src/librustc/middle/traits/select.rs
src/librustc/middle/traits/select.rs
+0
-17
src/librustc/middle/trans/adt.rs
src/librustc/middle/trans/adt.rs
+0
-3
src/librustc/middle/trans/base.rs
src/librustc/middle/trans/base.rs
+0
-30
src/librustc/middle/trans/cleanup.rs
src/librustc/middle/trans/cleanup.rs
+0
-7
src/librustc/middle/trans/common.rs
src/librustc/middle/trans/common.rs
+1
-1
src/librustc/middle/trans/datum.rs
src/librustc/middle/trans/datum.rs
+17
-27
src/librustc/middle/trans/debuginfo.rs
src/librustc/middle/trans/debuginfo.rs
+1
-125
src/librustc/middle/trans/doc.rs
src/librustc/middle/trans/doc.rs
+1
-1
src/librustc/middle/trans/expr.rs
src/librustc/middle/trans/expr.rs
+2
-39
src/librustc/middle/trans/glue.rs
src/librustc/middle/trans/glue.rs
+1
-69
src/librustc/middle/trans/reflect.rs
src/librustc/middle/trans/reflect.rs
+0
-8
src/librustc/middle/trans/tvec.rs
src/librustc/middle/trans/tvec.rs
+1
-1
src/librustc/middle/trans/type_of.rs
src/librustc/middle/trans/type_of.rs
+0
-4
src/librustc/middle/ty.rs
src/librustc/middle/ty.rs
+16
-58
src/librustc/middle/ty_fold.rs
src/librustc/middle/ty_fold.rs
+0
-3
src/librustc/middle/typeck/astconv.rs
src/librustc/middle/typeck/astconv.rs
+0
-60
src/librustc/middle/typeck/check/method.rs
src/librustc/middle/typeck/check/method.rs
+1
-1
src/librustc/middle/typeck/check/mod.rs
src/librustc/middle/typeck/check/mod.rs
+0
-6
src/librustc/middle/typeck/check/regionck.rs
src/librustc/middle/typeck/check/regionck.rs
+0
-3
src/librustc/middle/typeck/check/regionmanip.rs
src/librustc/middle/typeck/check/regionmanip.rs
+0
-1
src/librustc/middle/typeck/check/vtable2.rs
src/librustc/middle/typeck/check/vtable2.rs
+1
-1
src/librustc/middle/typeck/coherence/mod.rs
src/librustc/middle/typeck/coherence/mod.rs
+3
-3
src/librustc/middle/typeck/infer/coercion.rs
src/librustc/middle/typeck/infer/coercion.rs
+1
-1
src/librustc/middle/typeck/infer/combine.rs
src/librustc/middle/typeck/infer/combine.rs
+0
-4
src/librustc/middle/typeck/infer/error_reporting.rs
src/librustc/middle/typeck/infer/error_reporting.rs
+0
-10
src/librustc/middle/typeck/infer/mod.rs
src/librustc/middle/typeck/infer/mod.rs
+0
-5
src/librustc/middle/typeck/infer/skolemize.rs
src/librustc/middle/typeck/infer/skolemize.rs
+0
-1
src/librustc/middle/typeck/variance.rs
src/librustc/middle/typeck/variance.rs
+1
-1
src/librustc/util/ppaux.rs
src/librustc/util/ppaux.rs
+1
-2
未找到文件。
src/librustc/lint/builtin.rs
浏览文件 @
8a91d33e
...
...
@@ -412,26 +412,16 @@ fn check_foreign_fn(cx: &Context, decl: &ast::FnDecl) {
}
}
declare_lint!
(
MANAGED_HEAP_MEMORY
,
Allow
,
"use of managed (@ type) heap memory"
)
declare_lint!
(
OWNED_HEAP_MEMORY
,
Allow
,
"use of owned (Box type) heap memory"
)
declare_lint!
(
HEAP_MEMORY
,
Allow
,
"use of any (Box type or @ type) heap memory"
)
pub
struct
HeapMemory
;
impl
HeapMemory
{
fn
check_heap_type
(
&
self
,
cx
:
&
Context
,
span
:
Span
,
ty
:
ty
::
t
)
{
let
mut
n_box
=
0
i
;
let
mut
n_uniq
=
0
i
;
ty
::
fold_ty
(
cx
.tcx
,
ty
,
|
t
|
{
match
ty
::
get
(
t
)
.sty
{
ty
::
ty_box
(
_
)
=>
{
n_box
+=
1
;
}
ty
::
ty_uniq
(
_
)
|
ty
::
ty_closure
(
box
ty
::
ClosureTy
{
store
:
ty
::
UniqTraitStore
,
...
...
@@ -449,21 +439,13 @@ fn check_heap_type(&self, cx: &Context, span: Span, ty: ty::t) {
let
s
=
ty_to_string
(
cx
.tcx
,
ty
);
let
m
=
format!
(
"type uses owned (Box type) pointers: {}"
,
s
);
cx
.span_lint
(
OWNED_HEAP_MEMORY
,
span
,
m
.as_slice
());
cx
.span_lint
(
HEAP_MEMORY
,
span
,
m
.as_slice
());
}
if
n_box
>
0
{
let
s
=
ty_to_string
(
cx
.tcx
,
ty
);
let
m
=
format!
(
"type uses managed (@ type) pointers: {}"
,
s
);
cx
.span_lint
(
MANAGED_HEAP_MEMORY
,
span
,
m
.as_slice
());
cx
.span_lint
(
HEAP_MEMORY
,
span
,
m
.as_slice
());
}
}
}
impl
LintPass
for
HeapMemory
{
fn
get_lints
(
&
self
)
->
LintArray
{
lint_array!
(
MANAGED_HEAP_MEMORY
,
OWNED_HEAP_MEMORY
,
HEAP_MEMORY
)
lint_array!
(
OWNED_
HEAP_MEMORY
)
}
fn
check_item
(
&
mut
self
,
cx
:
&
Context
,
it
:
&
ast
::
Item
)
{
...
...
src/librustc/metadata/tydecode.rs
浏览文件 @
8a91d33e
...
...
@@ -397,7 +397,6 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t {
assert_eq!
(
next
(
st
),
'|'
);
return
ty
::
mk_param
(
st
.tcx
,
space
,
index
,
did
);
}
'@'
=>
return
ty
::
mk_box
(
st
.tcx
,
parse_ty
(
st
,
|
x
,
y
|
conv
(
x
,
y
))),
'~'
=>
return
ty
::
mk_uniq
(
st
.tcx
,
parse_ty
(
st
,
|
x
,
y
|
conv
(
x
,
y
))),
'*'
=>
return
ty
::
mk_ptr
(
st
.tcx
,
parse_mt
(
st
,
|
x
,
y
|
conv
(
x
,
y
))),
'&'
=>
{
...
...
src/librustc/metadata/tyencode.rs
浏览文件 @
8a91d33e
...
...
@@ -244,7 +244,6 @@ fn enc_sty(w: &mut SeekableMemWriter, cx: &ctxt, st: &ty::sty) {
for
t
in
ts
.iter
()
{
enc_ty
(
w
,
cx
,
*
t
);
}
mywrite!
(
w
,
"]"
);
}
ty
::
ty_box
(
typ
)
=>
{
mywrite!
(
w
,
"@"
);
enc_ty
(
w
,
cx
,
typ
);
}
ty
::
ty_uniq
(
typ
)
=>
{
mywrite!
(
w
,
"~"
);
enc_ty
(
w
,
cx
,
typ
);
}
ty
::
ty_ptr
(
mt
)
=>
{
mywrite!
(
w
,
"*"
);
enc_mt
(
w
,
cx
,
mt
);
}
ty
::
ty_rptr
(
r
,
mt
)
=>
{
...
...
src/librustc/middle/borrowck/check_loans.rs
浏览文件 @
8a91d33e
...
...
@@ -815,11 +815,6 @@ fn mark_variable_as_used_mut(this: &CheckLoanCtxt,
return
;
}
mc
::
cat_deref
(
_
,
_
,
mc
::
GcPtr
)
=>
{
assert_eq!
(
cmt
.mutbl
,
mc
::
McImmutable
);
return
;
}
mc
::
cat_rvalue
(
..
)
|
mc
::
cat_static_item
|
mc
::
cat_deref
(
_
,
_
,
mc
::
UnsafePtr
(
..
))
|
...
...
src/librustc/middle/borrowck/gather_loans/gather_moves.rs
浏览文件 @
8a91d33e
...
...
@@ -132,7 +132,6 @@ fn check_and_get_illegal_move_origin(bccx: &BorrowckCtxt,
match
cmt
.cat
{
mc
::
cat_deref
(
_
,
_
,
mc
::
BorrowedPtr
(
..
))
|
mc
::
cat_deref
(
_
,
_
,
mc
::
Implicit
(
..
))
|
mc
::
cat_deref
(
_
,
_
,
mc
::
GcPtr
)
|
mc
::
cat_deref
(
_
,
_
,
mc
::
UnsafePtr
(
..
))
|
mc
::
cat_upvar
(
..
)
|
mc
::
cat_static_item
|
mc
::
cat_copied_upvar
(
mc
::
CopiedUpvar
{
onceness
:
ast
::
Many
,
..
})
=>
{
...
...
src/librustc/middle/borrowck/gather_loans/lifetime.rs
浏览文件 @
8a91d33e
...
...
@@ -82,8 +82,7 @@ fn check(&self, cmt: &mc::cmt, discr_scope: Option<ast::NodeId>) -> R {
mc
::
cat_downcast
(
ref
base
)
|
mc
::
cat_deref
(
ref
base
,
_
,
mc
::
OwnedPtr
)
|
// L-Deref-Send
mc
::
cat_interior
(
ref
base
,
_
)
|
// L-Field
mc
::
cat_deref
(
ref
base
,
_
,
mc
::
GcPtr
)
=>
{
mc
::
cat_interior
(
ref
base
,
_
)
=>
{
// L-Field
self
.check
(
base
,
discr_scope
)
}
...
...
@@ -185,7 +184,6 @@ fn scope(&self, cmt: &mc::cmt) -> ty::Region {
}
mc
::
cat_downcast
(
ref
cmt
)
|
mc
::
cat_deref
(
ref
cmt
,
_
,
mc
::
OwnedPtr
)
|
mc
::
cat_deref
(
ref
cmt
,
_
,
mc
::
GcPtr
)
|
mc
::
cat_interior
(
ref
cmt
,
_
)
|
mc
::
cat_discr
(
ref
cmt
,
_
)
=>
{
self
.scope
(
cmt
)
...
...
src/librustc/middle/borrowck/gather_loans/move_error.rs
浏览文件 @
8a91d33e
...
...
@@ -114,7 +114,6 @@ fn report_cannot_move_out_of(bccx: &BorrowckCtxt, move_from: mc::cmt) {
match
move_from
.cat
{
mc
::
cat_deref
(
_
,
_
,
mc
::
BorrowedPtr
(
..
))
|
mc
::
cat_deref
(
_
,
_
,
mc
::
Implicit
(
..
))
|
mc
::
cat_deref
(
_
,
_
,
mc
::
GcPtr
)
|
mc
::
cat_deref
(
_
,
_
,
mc
::
UnsafePtr
(
..
))
|
mc
::
cat_upvar
(
..
)
|
mc
::
cat_static_item
|
mc
::
cat_copied_upvar
(
mc
::
CopiedUpvar
{
onceness
:
ast
::
Many
,
..
})
=>
{
...
...
src/librustc/middle/borrowck/gather_loans/restrictions.rs
浏览文件 @
8a91d33e
...
...
@@ -101,16 +101,13 @@ fn restrict(&self,
self
.extend
(
result
,
cmt
.mutbl
,
LpInterior
(
i
))
}
mc
::
cat_deref
(
cmt_base
,
_
,
pk
@
mc
::
OwnedPtr
)
|
mc
::
cat_deref
(
cmt_base
,
_
,
pk
@
mc
::
GcPtr
)
=>
{
mc
::
cat_deref
(
cmt_base
,
_
,
pk
@
mc
::
OwnedPtr
)
=>
{
// R-Deref-Send-Pointer
//
// When we borrow the interior of an owned pointer, we
// cannot permit the base to be mutated, because that
// would cause the unique pointer to be freed.
//
// For a managed pointer, the rules are basically the
// same, because this could be the last ref.
// Eventually we should make these non-special and
// just rely on Deref<T> implementation.
let
result
=
self
.restrict
(
cmt_base
);
...
...
src/librustc/middle/borrowck/mod.rs
浏览文件 @
8a91d33e
...
...
@@ -730,11 +730,6 @@ pub fn report_aliasability_violation(&self,
span
,
format!
(
"{} in a static location"
,
prefix
)
.as_slice
());
}
mc
::
AliasableManaged
=>
{
self
.tcx.sess
.span_err
(
span
,
format!
(
"{} in a `Gc` pointer"
,
prefix
)
.as_slice
());
}
mc
::
AliasableBorrowed
=>
{
self
.tcx.sess
.span_err
(
span
,
...
...
src/librustc/middle/check_match.rs
浏览文件 @
8a91d33e
...
...
@@ -440,11 +440,6 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
}
}
ty
::
ty_box
(
_
)
=>
{
assert_eq!
(
pats_len
,
1
);
PatBox
(
pats
.nth
(
0
)
.unwrap
())
}
ty
::
ty_vec
(
_
,
Some
(
len
))
=>
{
assert_eq!
(
pats_len
,
len
);
PatVec
(
pats
.collect
(),
None
,
vec!
[])
...
...
@@ -681,7 +676,7 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
pub
fn
constructor_arity
(
cx
:
&
MatchCheckCtxt
,
ctor
:
&
Constructor
,
ty
:
ty
::
t
)
->
uint
{
match
ty
::
get
(
ty
)
.sty
{
ty
::
ty_tup
(
ref
fs
)
=>
fs
.len
(),
ty
::
ty_
box
(
_
)
|
ty
::
ty_
uniq
(
_
)
=>
1u
,
ty
::
ty_uniq
(
_
)
=>
1u
,
ty
::
ty_rptr
(
_
,
ty
::
mt
{
ty
:
ty
,
..
})
=>
match
ty
::
get
(
ty
)
.sty
{
ty
::
ty_vec
(
_
,
None
)
=>
match
*
ctor
{
Slice
(
length
)
=>
length
,
...
...
src/librustc/middle/intrinsicck.rs
浏览文件 @
8a91d33e
...
...
@@ -28,8 +28,8 @@ fn type_size_is_affected_by_type_parameters(tcx: &ty::ctxt, typ: ty::t)
let
mut
result
=
false
;
ty
::
maybe_walk_ty
(
typ
,
|
typ
|
{
match
ty
::
get
(
typ
)
.sty
{
ty
::
ty_
box
(
_
)
|
ty
::
ty_uniq
(
_
)
|
ty
::
ty_ptr
(
_
)
|
ty
::
ty_
rptr
(
..
)
|
ty
::
ty_
bare_fn
(
..
)
|
ty
::
ty_closure
(
..
)
=>
{
ty
::
ty_
uniq
(
_
)
|
ty
::
ty_ptr
(
_
)
|
ty
::
ty_rptr
(
..
)
|
ty
::
ty_bare_fn
(
..
)
|
ty
::
ty_closure
(
..
)
=>
{
false
}
ty
::
ty_param
(
_
)
=>
{
...
...
src/librustc/middle/lang_items.rs
浏览文件 @
8a91d33e
...
...
@@ -279,8 +279,6 @@ pub fn collect_language_items(krate: &ast::Crate,
ExchangeMallocFnLangItem
,
"exchange_malloc"
,
exchange_malloc_fn
;
ExchangeFreeFnLangItem
,
"exchange_free"
,
exchange_free_fn
;
MallocFnLangItem
,
"malloc"
,
malloc_fn
;
FreeFnLangItem
,
"free"
,
free_fn
;
StrDupUniqFnLangItem
,
"strdup_uniq"
,
strdup_uniq_fn
;
StartFnLangItem
,
"start"
,
start_fn
;
...
...
@@ -293,9 +291,7 @@ pub fn collect_language_items(krate: &ast::Crate,
EhPersonalityLangItem
,
"eh_personality"
,
eh_personality
;
ManagedHeapLangItem
,
"managed_heap"
,
managed_heap
;
ExchangeHeapLangItem
,
"exchange_heap"
,
exchange_heap
;
GcLangItem
,
"gc"
,
gc
;
OwnedBoxLangItem
,
"owned_box"
,
owned_box
;
CovariantTypeItem
,
"covariant_type"
,
covariant_type
;
...
...
src/librustc/middle/mem_categorization.rs
浏览文件 @
8a91d33e
...
...
@@ -104,7 +104,6 @@ pub struct CopiedUpvar {
#[deriving(Clone,
PartialEq,
Eq,
Hash)]
pub
enum
PointerKind
{
OwnedPtr
,
GcPtr
,
BorrowedPtr
(
ty
::
BorrowKind
,
ty
::
Region
),
Implicit
(
ty
::
BorrowKind
,
ty
::
Region
),
// Implicit deref of a borrowed ptr.
UnsafePtr
(
ast
::
Mutability
)
...
...
@@ -191,10 +190,6 @@ pub fn opt_deref_kind(t: ty::t) -> Option<deref_kind> {
Some
(
deref_ptr
(
BorrowedPtr
(
ty
::
ImmBorrow
,
r
)))
}
ty
::
ty_box
(
..
)
=>
{
Some
(
deref_ptr
(
GcPtr
))
}
ty
::
ty_ptr
(
ref
mt
)
=>
{
Some
(
deref_ptr
(
UnsafePtr
(
mt
.mutbl
)))
}
...
...
@@ -302,9 +297,6 @@ pub fn from_pointer_kind(base_mutbl: MutabilityCategory,
BorrowedPtr
(
borrow_kind
,
_
)
|
Implicit
(
borrow_kind
,
_
)
=>
{
MutabilityCategory
::
from_borrow_kind
(
borrow_kind
)
}
GcPtr
=>
{
McImmutable
}
UnsafePtr
(
m
)
=>
{
MutabilityCategory
::
from_mutbl
(
m
)
}
...
...
@@ -1200,7 +1192,7 @@ pub fn cmt_to_string(&self, cmt: &cmt_) -> String {
Implicit
(
..
)
=>
{
"dereference (dereference is implicit, due to indexing)"
.to_string
()
}
OwnedPtr
|
GcPtr
=>
format!
(
"dereference of `{}`"
,
ptr_sigil
(
pk
)),
OwnedPtr
=>
format!
(
"dereference of `{}`"
,
ptr_sigil
(
pk
)),
_
=>
format!
(
"dereference of `{}`-pointer"
,
ptr_sigil
(
pk
))
}
}
...
...
@@ -1237,7 +1229,6 @@ pub enum InteriorSafety {
}
pub
enum
AliasableReason
{
AliasableManaged
,
AliasableBorrowed
,
AliasableOther
,
AliasableStatic
(
InteriorSafety
),
...
...
@@ -1256,7 +1247,6 @@ pub fn guarantor(&self) -> cmt {
cat_copied_upvar
(
..
)
|
cat_local
(
..
)
|
cat_deref
(
_
,
_
,
UnsafePtr
(
..
))
|
cat_deref
(
_
,
_
,
GcPtr
(
..
))
|
cat_deref
(
_
,
_
,
BorrowedPtr
(
..
))
|
cat_deref
(
_
,
_
,
Implicit
(
..
))
|
cat_upvar
(
..
)
=>
{
...
...
@@ -1320,10 +1310,6 @@ pub fn freely_aliasable(&self, ctxt: &ty::ctxt) -> Option<AliasableReason> {
}
}
cat_deref
(
_
,
_
,
GcPtr
)
=>
{
Some
(
AliasableManaged
)
}
cat_deref
(
_
,
_
,
BorrowedPtr
(
ty
::
ImmBorrow
,
_
))
|
cat_deref
(
_
,
_
,
Implicit
(
ty
::
ImmBorrow
,
_
))
=>
{
Some
(
AliasableBorrowed
)
...
...
@@ -1371,7 +1357,6 @@ fn repr(&self, tcx: &ty::ctxt) -> String {
pub
fn
ptr_sigil
(
ptr
:
PointerKind
)
->
&
'static
str
{
match
ptr
{
OwnedPtr
=>
"Box"
,
GcPtr
=>
"Gc"
,
BorrowedPtr
(
ty
::
ImmBorrow
,
_
)
|
Implicit
(
ty
::
ImmBorrow
,
_
)
=>
"&"
,
BorrowedPtr
(
ty
::
MutBorrow
,
_
)
|
...
...
src/librustc/middle/traits/coherence.rs
浏览文件 @
8a91d33e
...
...
@@ -104,11 +104,6 @@ pub fn ty_is_local(tcx: &ty::ctxt,
krate
==
Some
(
ast
::
LOCAL_CRATE
)
||
ty_is_local
(
tcx
,
t
)
}
ty
::
ty_box
(
t
)
=>
{
let
krate
=
tcx
.lang_items
.gc
()
.map
(|
d
|
d
.krate
);
krate
==
Some
(
ast
::
LOCAL_CRATE
)
||
ty_is_local
(
tcx
,
t
)
}
ty
::
ty_vec
(
t
,
_
)
|
ty
::
ty_ptr
(
ty
::
mt
{
ty
:
t
,
..
})
|
ty
::
ty_rptr
(
_
,
ty
::
mt
{
ty
:
t
,
..
})
=>
{
...
...
src/librustc/middle/traits/select.rs
浏览文件 @
8a91d33e
...
...
@@ -713,23 +713,6 @@ enum WhenOk<'a> {
ok
(
self
,
Always
)
}
ty
::
ty_box
(
_
)
=>
{
match
bound
{
ty
::
BoundSync
|
ty
::
BoundSend
|
ty
::
BoundCopy
=>
{
// Managed data is not copyable, sendable, nor
// synchronized, regardless of referent.
ok
(
self
,
Never
)
}
ty
::
BoundSized
=>
{
// But it is sized, regardless of referent.
ok
(
self
,
Always
)
}
}
}
ty
::
ty_uniq
(
referent_ty
)
=>
{
// Box<T>
match
bound
{
ty
::
BoundCopy
=>
{
...
...
src/librustc/middle/trans/adt.rs
浏览文件 @
8a91d33e
...
...
@@ -321,9 +321,6 @@ fn find_ptr(&self) -> Option<PointerField> {
_
=>
return
Some
(
ThinPointer
(
i
))
},
// Gc<T> is just a pointer
ty
::
ty_box
(
..
)
=>
return
Some
(
ThinPointer
(
i
)),
// Functions are just pointers
ty
::
ty_bare_fn
(
..
)
=>
return
Some
(
ThinPointer
(
i
)),
...
...
src/librustc/middle/trans/base.rs
浏览文件 @
8a91d33e
...
...
@@ -397,36 +397,6 @@ pub fn malloc_raw_dyn_proc<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: ty::t) -> Resu
Result
::
new
(
bcx
,
llbox
)
}
pub
fn
malloc_raw_dyn_managed
<
'blk
,
'tcx
>
(
bcx
:
Block
<
'blk
,
'tcx
>
,
t
:
ty
::
t
,
alloc_fn
:
LangItem
,
size
:
ValueRef
)
->
Result
<
'blk
,
'tcx
>
{
let
_
icx
=
push_ctxt
(
"malloc_raw_dyn_managed"
);
let
ccx
=
bcx
.ccx
();
let
langcall
=
require_alloc_fn
(
bcx
,
t
,
alloc_fn
);
// Grab the TypeRef type of box_ptr_ty.
let
box_ptr_ty
=
ty
::
mk_box
(
bcx
.tcx
(),
t
);
let
llty
=
type_of
(
ccx
,
box_ptr_ty
);
let
llalign
=
C_uint
(
ccx
,
type_of
::
align_of
(
ccx
,
box_ptr_ty
)
as
uint
);
// Allocate space:
let
drop_glue
=
glue
::
get_drop_glue
(
ccx
,
t
);
let
r
=
callee
::
trans_lang_call
(
bcx
,
langcall
,
[
PointerCast
(
bcx
,
drop_glue
,
Type
::
glue_fn
(
ccx
,
Type
::
i8p
(
ccx
))
.ptr_to
()),
size
,
llalign
],
None
);
Result
::
new
(
r
.bcx
,
PointerCast
(
r
.bcx
,
r
.val
,
llty
))
}
// Type descriptor and type glue stuff
pub
fn
get_tydesc
(
ccx
:
&
CrateContext
,
t
:
ty
::
t
)
->
Rc
<
tydesc_info
>
{
...
...
src/librustc/middle/trans/cleanup.rs
浏览文件 @
8a91d33e
...
...
@@ -960,7 +960,6 @@ fn trans<'blk, 'tcx>(&self,
}
pub
enum
Heap
{
HeapManaged
,
HeapExchange
}
...
...
@@ -986,9 +985,6 @@ fn trans<'blk, 'tcx>(&self,
apply_debug_loc
(
bcx
.fcx
,
debug_loc
);
match
self
.heap
{
HeapManaged
=>
{
glue
::
trans_free
(
bcx
,
self
.ptr
)
}
HeapExchange
=>
{
glue
::
trans_exchange_free_ty
(
bcx
,
self
.ptr
,
self
.content_ty
)
}
...
...
@@ -1019,9 +1015,6 @@ fn trans<'blk, 'tcx>(&self,
apply_debug_loc
(
bcx
.fcx
,
debug_loc
);
match
self
.heap
{
HeapManaged
=>
{
glue
::
trans_free
(
bcx
,
self
.ptr
)
}
HeapExchange
=>
{
glue
::
trans_exchange_free_dyn
(
bcx
,
self
.ptr
,
self
.size
,
self
.align
)
}
...
...
src/librustc/middle/trans/common.rs
浏览文件 @
8a91d33e
...
...
@@ -71,7 +71,7 @@ pub fn type_is_immediate(ccx: &CrateContext, ty: ty::t) -> bool {
use
middle
::
trans
::
type_of
::
sizing_type_of
;
let
tcx
=
ccx
.tcx
();
let
simple
=
ty
::
type_is_scalar
(
ty
)
||
ty
::
type_is_boxed
(
ty
)
||
let
simple
=
ty
::
type_is_scalar
(
ty
)
||
ty
::
type_is_unique
(
ty
)
||
ty
::
type_is_region_ptr
(
ty
)
||
type_is_newtype_immediate
(
ccx
,
ty
)
||
ty
::
type_is_bot
(
ty
)
||
ty
::
type_is_simd
(
tcx
,
ty
);
...
...
src/librustc/middle/trans/datum.rs
浏览文件 @
8a91d33e
...
...
@@ -20,7 +20,6 @@
use
middle
::
trans
::
cleanup
;
use
middle
::
trans
::
cleanup
::
CleanupMethods
;
use
middle
::
trans
::
expr
;
use
middle
::
trans
::
glue
;
use
middle
::
trans
::
tvec
;
use
middle
::
trans
::
type_of
;
use
middle
::
ty
;
...
...
@@ -240,14 +239,9 @@ fn post_store<'blk, 'tcx>(&self,
*/
if
ty
::
type_needs_drop
(
bcx
.tcx
(),
ty
)
{
if
ty
::
type_moves_by_default
(
bcx
.tcx
(),
ty
)
{
// cancel cleanup of affine values by zeroing out
let
()
=
zero_mem
(
bcx
,
val
,
ty
);
bcx
}
else
{
// incr. refcount for @T or newtype'd @T
glue
::
take_ty
(
bcx
,
val
,
ty
)
}
// cancel cleanup of affine values by zeroing out
let
()
=
zero_mem
(
bcx
,
val
,
ty
);
bcx
}
else
{
bcx
}
...
...
@@ -567,15 +561,15 @@ pub fn store_to<'blk, 'tcx>(self,
* is moved).
*/
self
.shallow_copy
(
bcx
,
dst
);
self
.shallow_copy
_raw
(
bcx
,
dst
);
self
.kind
.post_store
(
bcx
,
self
.val
,
self
.ty
)
}
fn
shallow_copy
<
'blk
,
'tcx
>
(
&
self
,
bcx
:
Block
<
'blk
,
'tcx
>
,
dst
:
ValueRef
)
->
Block
<
'blk
,
'tcx
>
{
fn
shallow_copy
_raw
<
'blk
,
'tcx
>
(
&
self
,
bcx
:
Block
<
'blk
,
'tcx
>
,
dst
:
ValueRef
)
->
Block
<
'blk
,
'tcx
>
{
/*!
* Helper function that performs a shallow copy of this value
* into `dst`, which should be a pointer to a memory location
...
...
@@ -584,10 +578,9 @@ fn shallow_copy<'blk, 'tcx>(&self,
*
* This function is private to datums because it leaves memory
* in an unstable state, where the source value has been
* copied but not zeroed. Public methods are `store_to` (if
* you no longer need the source value) or
* `shallow_copy_and_take` (if you wish the source value to
* remain valid).
* copied but not zeroed. Public methods are `store_to`
* (if you no longer need the source value) or `shallow_copy`
* (if you wish the source value to remain valid).
*/
let
_
icx
=
push_ctxt
(
"copy_to_no_check"
);
...
...
@@ -605,22 +598,19 @@ fn shallow_copy<'blk, 'tcx>(&self,
return
bcx
;
}
pub
fn
shallow_copy
_and_take
<
'blk
,
'tcx
>
(
&
self
,
bcx
:
Block
<
'blk
,
'tcx
>
,
dst
:
ValueRef
)
->
Block
<
'blk
,
'tcx
>
{
pub
fn
shallow_copy
<
'blk
,
'tcx
>
(
&
self
,
bcx
:
Block
<
'blk
,
'tcx
>
,
dst
:
ValueRef
)
->
Block
<
'blk
,
'tcx
>
{
/*!
* Copies the value into a new location and runs any necessary
* take glue on the new location. This function always
* Copies the value into a new location. This function always
* preserves the existing datum as a valid value. Therefore,
* it does not consume `self` and, also, cannot be applied to
* affine values (since they must never be duplicated).
*/
assert
!
(
!
ty
::
type_moves_by_default
(
bcx
.tcx
(),
self
.ty
));
let
mut
bcx
=
bcx
;
bcx
=
self
.shallow_copy
(
bcx
,
dst
);
glue
::
take_ty
(
bcx
,
dst
,
self
.ty
)
self
.shallow_copy_raw
(
bcx
,
dst
)
}
#[allow(dead_code)]
// useful for debugging
...
...
src/librustc/middle/trans/debuginfo.rs
浏览文件 @
8a91d33e
...
...
@@ -373,12 +373,6 @@ fn get_unique_type_id_of_type(&mut self, cx: &CrateContext, type_: ty::t) -> Uni
unique_type_id
.push_str
(
component_type_id
.as_slice
());
}
},
ty
::
ty_box
(
inner_type
)
=>
{
unique_type_id
.push_char
(
'@'
);
let
inner_type_id
=
self
.get_unique_type_id_of_type
(
cx
,
inner_type
);
let
inner_type_id
=
self
.get_unique_type_id_as_string
(
inner_type_id
);
unique_type_id
.push_str
(
inner_type_id
.as_slice
());
},
ty
::
ty_uniq
(
inner_type
)
=>
{
unique_type_id
.push_char
(
'~'
);
let
inner_type_id
=
self
.get_unique_type_id_of_type
(
cx
,
inner_type
);
...
...
@@ -596,18 +590,6 @@ fn get_unique_type_id_of_enum_variant(&mut self,
let
interner_key
=
self
.unique_id_interner
.intern
(
Rc
::
new
(
enum_variant_type_id
));
UniqueTypeId
(
interner_key
)
}
fn
get_unique_type_id_of_gc_box
(
&
mut
self
,
cx
:
&
CrateContext
,
element_type
:
ty
::
t
)
->
UniqueTypeId
{
let
element_type_id
=
self
.get_unique_type_id_of_type
(
cx
,
element_type
);
let
gc_box_type_id
=
format!
(
"{{GC_BOX<{}>}}"
,
self
.get_unique_type_id_as_string
(
element_type_id
)
.as_slice
());
let
interner_key
=
self
.unique_id_interner
.intern
(
Rc
::
new
(
gc_box_type_id
));
UniqueTypeId
(
interner_key
)
}
}
// Returns from the enclosing function if the type metadata with the given
...
...
@@ -2646,105 +2628,6 @@ fn create_struct_stub(cx: &CrateContext,
return
metadata_stub
;
}
fn
at_box_metadata
(
cx
:
&
CrateContext
,
at_pointer_type
:
ty
::
t
,
content_type
:
ty
::
t
,
unique_type_id
:
UniqueTypeId
)
->
MetadataCreationResult
{
let
content_type_metadata
=
type_metadata
(
cx
,
content_type
,
codemap
::
DUMMY_SP
);
return_if_metadata_created_in_meantime!
(
cx
,
unique_type_id
);
let
content_type_name
=
compute_debuginfo_type_name
(
cx
,
content_type
,
true
);
let
content_type_name
=
content_type_name
.as_slice
();
let
content_llvm_type
=
type_of
::
type_of
(
cx
,
content_type
);
let
box_type_name
=
format!
(
"GcBox<{}>"
,
content_type_name
);
let
box_llvm_type
=
Type
::
at_box
(
cx
,
content_llvm_type
);
let
member_llvm_types
=
box_llvm_type
.field_types
();
assert
!
(
box_layout_is_correct
(
cx
,
member_llvm_types
.as_slice
(),
content_llvm_type
));
let
int_type
=
ty
::
mk_int
();
let
nil_pointer_type
=
ty
::
mk_nil_ptr
(
cx
.tcx
());
let
nil_pointer_type_metadata
=
type_metadata
(
cx
,
nil_pointer_type
,
codemap
::
DUMMY_SP
);
let
member_descriptions
=
[
MemberDescription
{
name
:
"refcnt"
.to_string
(),
llvm_type
:
*
member_llvm_types
.get
(
0
),
type_metadata
:
type_metadata
(
cx
,
int_type
,
codemap
::
DUMMY_SP
),
offset
:
ComputedMemberOffset
,
flags
:
FLAGS_ARTIFICAL
,
},
MemberDescription
{
name
:
"drop_glue"
.to_string
(),
llvm_type
:
*
member_llvm_types
.get
(
1
),
type_metadata
:
nil_pointer_type_metadata
,
offset
:
ComputedMemberOffset
,
flags
:
FLAGS_ARTIFICAL
,
},
MemberDescription
{
name
:
"prev"
.to_string
(),
llvm_type
:
*
member_llvm_types
.get
(
2
),
type_metadata
:
nil_pointer_type_metadata
,
offset
:
ComputedMemberOffset
,
flags
:
FLAGS_ARTIFICAL
,
},
MemberDescription
{
name
:
"next"
.to_string
(),
llvm_type
:
*
member_llvm_types
.get
(
3
),
type_metadata
:
nil_pointer_type_metadata
,
offset
:
ComputedMemberOffset
,
flags
:
FLAGS_ARTIFICAL
,
},
MemberDescription
{
name
:
"val"
.to_string
(),
llvm_type
:
*
member_llvm_types
.get
(
4
),
type_metadata
:
content_type_metadata
,
offset
:
ComputedMemberOffset
,
flags
:
FLAGS_ARTIFICAL
,
}
];
let
gc_box_unique_id
=
debug_context
(
cx
)
.type_map
.borrow_mut
()
.get_unique_type_id_of_gc_box
(
cx
,
content_type
);
let
gc_box_metadata
=
composite_type_metadata
(
cx
,
box_llvm_type
,
box_type_name
.as_slice
(),
gc_box_unique_id
,
member_descriptions
,
UNKNOWN_SCOPE_METADATA
,
UNKNOWN_FILE_METADATA
,
codemap
::
DUMMY_SP
);
let
gc_pointer_metadata
=
pointer_type_metadata
(
cx
,
at_pointer_type
,
gc_box_metadata
);
return
MetadataCreationResult
::
new
(
gc_pointer_metadata
,
false
);
// Unfortunately, we cannot assert anything but the correct types here---and
// not whether the 'next' and 'prev' pointers are in the correct order.
fn
box_layout_is_correct
(
cx
:
&
CrateContext
,
member_llvm_types
:
&
[
Type
],
content_llvm_type
:
Type
)
->
bool
{
member_llvm_types
.len
()
==
5
&&
member_llvm_types
[
0
]
==
cx
.int_type
()
&&
member_llvm_types
[
1
]
==
Type
::
generic_glue_fn
(
cx
)
.ptr_to
()
&&
member_llvm_types
[
2
]
==
Type
::
i8
(
cx
)
.ptr_to
()
&&
member_llvm_types
[
3
]
==
Type
::
i8
(
cx
)
.ptr_to
()
&&
member_llvm_types
[
4
]
==
content_llvm_type
}
}
fn
fixed_vec_metadata
(
cx
:
&
CrateContext
,
unique_type_id
:
UniqueTypeId
,
element_type
:
ty
::
t
,
...
...
@@ -2968,9 +2851,6 @@ fn type_metadata(cx: &CrateContext,
ty
::
ty_enum
(
def_id
,
_
)
=>
{
prepare_enum_metadata
(
cx
,
t
,
def_id
,
unique_type_id
,
usage_site_span
)
.finalize
(
cx
)
}
ty
::
ty_box
(
pointee_type
)
=>
{
at_box_metadata
(
cx
,
t
,
pointee_type
,
unique_type_id
)
}
ty
::
ty_vec
(
typ
,
Some
(
len
))
=>
{
fixed_vec_metadata
(
cx
,
unique_type_id
,
typ
,
len
,
usage_site_span
)
}
...
...
@@ -3702,7 +3582,7 @@ fn walk_expr(cx: &CrateContext,
ast
::
ExprInlineAsm
(
ast
::
InlineAsm
{
inputs
:
ref
inputs
,
outputs
:
ref
outputs
,
..
})
=>
{
// inputs, outputs:
~[(String, Gc<expr>)]
// inputs, outputs:
Vec<(String, P<Expr>)>
for
&
(
_
,
ref
exp
)
in
inputs
.iter
()
{
walk_expr
(
cx
,
&**
exp
,
scope_stack
,
scope_map
);
}
...
...
@@ -3777,10 +3657,6 @@ fn push_debuginfo_type_name(cx: &CrateContext,
push_debuginfo_type_name
(
cx
,
inner_type
,
true
,
output
);
output
.push_char
(
'>'
);
},
ty
::
ty_box
(
inner_type
)
=>
{
output
.push_char
(
'@'
);
push_debuginfo_type_name
(
cx
,
inner_type
,
true
,
output
);
},
ty
::
ty_ptr
(
ty
::
mt
{
ty
:
inner_type
,
mutbl
}
)
=>
{
output
.push_char
(
'*'
);
match
mutbl
{
...
...
src/librustc/middle/trans/doc.rs
浏览文件 @
8a91d33e
...
...
@@ -65,7 +65,7 @@
copyable values such as ints or pointers. Those methods may borrow the
datum (`&self`) rather than consume it, but they always include
assertions on the type of the value represented to check that this
makes sense. An example is `shallow_copy
_and_take
()`, which duplicates
makes sense. An example is `shallow_copy()`, which duplicates
a datum value.
Translating an expression always yields a `Datum<Expr>` result, but
...
...
src/librustc/middle/trans/expr.rs
浏览文件 @
8a91d33e
...
...
@@ -38,7 +38,6 @@
use
llvm
::{
ValueRef
};
use
metadata
::
csearch
;
use
middle
::
def
;
use
middle
::
lang_items
::
MallocFnLangItem
;
use
middle
::
mem_categorization
::
Typer
;
use
middle
::
subst
;
use
middle
::
subst
::
Subst
;
...
...
@@ -624,18 +623,15 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
DatumBlock
::
new
(
bcx
,
scratch
.to_expr_datum
())
}
ast
::
ExprBox
(
_
,
ref
contents
)
=>
{
// Special case for `Box<T>`
and `Gc<T>`
// Special case for `Box<T>`
let
box_ty
=
expr_ty
(
bcx
,
expr
);
let
contents_ty
=
expr_ty
(
bcx
,
&**
contents
);
match
ty
::
get
(
box_ty
)
.sty
{
ty
::
ty_uniq
(
..
)
=>
{
trans_uniq_expr
(
bcx
,
box_ty
,
&**
contents
,
contents_ty
)
}
ty
::
ty_box
(
..
)
=>
{
trans_managed_expr
(
bcx
,
box_ty
,
&**
contents
,
contents_ty
)
}
_
=>
bcx
.sess
()
.span_bug
(
expr
.span
,
"expected unique
or managed
box"
)
"expected unique box"
)
}
}
...
...
@@ -1572,26 +1568,6 @@ fn trans_uniq_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
immediate_rvalue_bcx
(
bcx
,
val
,
box_ty
)
.to_expr_datumblock
()
}
fn
trans_managed_expr
<
'blk
,
'tcx
>
(
bcx
:
Block
<
'blk
,
'tcx
>
,
box_ty
:
ty
::
t
,
contents
:
&
ast
::
Expr
,
contents_ty
:
ty
::
t
)
->
DatumBlock
<
'blk
,
'tcx
,
Expr
>
{
let
_
icx
=
push_ctxt
(
"trans_managed_expr"
);
let
fcx
=
bcx
.fcx
;
let
ty
=
type_of
::
type_of
(
bcx
.ccx
(),
contents_ty
);
let
Result
{
bcx
,
val
:
bx
}
=
malloc_raw_dyn_managed
(
bcx
,
contents_ty
,
MallocFnLangItem
,
llsize_of
(
bcx
.ccx
(),
ty
));
let
body
=
GEPi
(
bcx
,
bx
,
[
0u
,
abi
::
box_field_body
]);
let
custom_cleanup_scope
=
fcx
.push_custom_cleanup_scope
();
fcx
.schedule_free_value
(
cleanup
::
CustomScope
(
custom_cleanup_scope
),
bx
,
cleanup
::
HeapManaged
,
contents_ty
);
let
bcx
=
trans_into
(
bcx
,
contents
,
SaveIn
(
body
));
fcx
.pop_custom_cleanup_scope
(
custom_cleanup_scope
);
immediate_rvalue_bcx
(
bcx
,
bx
,
box_ty
)
.to_expr_datumblock
()
}
fn
trans_addr_of
<
'blk
,
'tcx
>
(
bcx
:
Block
<
'blk
,
'tcx
>
,
expr
:
&
ast
::
Expr
,
subexpr
:
&
ast
::
Expr
)
...
...
@@ -1924,10 +1900,6 @@ pub fn cast_type_kind(tcx: &ty::ctxt, t: ty::t) -> cast_kind {
}
fn
cast_is_noop
(
t_in
:
ty
::
t
,
t_out
:
ty
::
t
)
->
bool
{
if
ty
::
type_is_boxed
(
t_in
)
||
ty
::
type_is_boxed
(
t_out
)
{
return
false
;
}
match
(
ty
::
deref
(
t_in
,
true
),
ty
::
deref
(
t_out
,
true
))
{
(
Some
(
ty
::
mt
{
ty
:
t_in
,
..
}),
Some
(
ty
::
mt
{
ty
:
t_out
,
..
}))
=>
{
t_in
==
t_out
...
...
@@ -2160,15 +2132,6 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
}
}
ty
::
ty_box
(
content_ty
)
=>
{
let
datum
=
unpack_datum!
(
bcx
,
datum
.to_lvalue_datum
(
bcx
,
"deref"
,
expr
.id
));
let
llptrref
=
datum
.to_llref
();
let
llptr
=
Load
(
bcx
,
llptrref
);
let
llbody
=
GEPi
(
bcx
,
llptr
,
[
0u
,
abi
::
box_field_body
]);
DatumBlock
::
new
(
bcx
,
Datum
::
new
(
llbody
,
content_ty
,
LvalueExpr
))
}
ty
::
ty_ptr
(
ty
::
mt
{
ty
:
content_ty
,
..
})
|
ty
::
ty_rptr
(
_
,
ty
::
mt
{
ty
:
content_ty
,
..
})
=>
{
if
ty
::
type_is_sized
(
bcx
.tcx
(),
content_ty
)
{
...
...
src/librustc/middle/trans/glue.rs
浏览文件 @
8a91d33e
...
...
@@ -17,7 +17,7 @@
use
back
::
link
::
*
;
use
llvm
::{
ValueRef
,
True
,
get_param
};
use
llvm
;
use
middle
::
lang_items
::
{
FreeFnLangItem
,
ExchangeFreeFnLangItem
}
;
use
middle
::
lang_items
::
ExchangeFreeFnLangItem
;
use
middle
::
subst
;
use
middle
::
subst
::
Subst
;
use
middle
::
trans
::
adt
;
...
...
@@ -46,15 +46,6 @@
use
syntax
::
ast
;
use
syntax
::
parse
::
token
;
pub
fn
trans_free
<
'blk
,
'tcx
>
(
cx
:
Block
<
'blk
,
'tcx
>
,
v
:
ValueRef
)
->
Block
<
'blk
,
'tcx
>
{
let
_
icx
=
push_ctxt
(
"trans_free"
);
callee
::
trans_lang_call
(
cx
,
langcall
(
cx
,
None
,
""
,
FreeFnLangItem
),
[
PointerCast
(
cx
,
v
,
Type
::
i8p
(
cx
.ccx
()))],
Some
(
expr
::
Ignore
))
.bcx
}
pub
fn
trans_exchange_free_dyn
<
'blk
,
'tcx
>
(
cx
:
Block
<
'blk
,
'tcx
>
,
v
:
ValueRef
,
size
:
ValueRef
,
align
:
ValueRef
)
->
Block
<
'blk
,
'tcx
>
{
...
...
@@ -87,20 +78,6 @@ pub fn trans_exchange_free_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ptr: ValueRef,
}
}
pub
fn
take_ty
<
'blk
,
'tcx
>
(
bcx
:
Block
<
'blk
,
'tcx
>
,
v
:
ValueRef
,
t
:
ty
::
t
)
->
Block
<
'blk
,
'tcx
>
{
// NB: v is an *alias* of type t here, not a direct value.
let
_
icx
=
push_ctxt
(
"take_ty"
);
match
ty
::
get
(
t
)
.sty
{
ty
::
ty_box
(
_
)
=>
incr_refcnt_of_boxed
(
bcx
,
v
),
_
if
ty
::
type_is_structural
(
t
)
&&
ty
::
type_needs_drop
(
bcx
.tcx
(),
t
)
=>
{
iter_structural_ty
(
bcx
,
v
,
t
,
take_ty
)
}
_
=>
bcx
}
}
pub
fn
get_drop_glue_type
(
ccx
:
&
CrateContext
,
t
:
ty
::
t
)
->
ty
::
t
{
let
tcx
=
ccx
.tcx
();
// Even if there is no dtor for t, there might be one deeper down and we
...
...
@@ -446,9 +423,6 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, t: ty::t)
// NB: v0 is an *alias* of type t here, not a direct value.
let
_
icx
=
push_ctxt
(
"make_drop_glue"
);
match
ty
::
get
(
t
)
.sty
{
ty
::
ty_box
(
body_ty
)
=>
{
decr_refcnt_maybe_free
(
bcx
,
v0
,
body_ty
)
}
ty
::
ty_uniq
(
content_ty
)
=>
{
match
ty
::
get
(
content_ty
)
.sty
{
ty
::
ty_vec
(
ty
,
None
)
=>
{
...
...
@@ -568,48 +542,6 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, t: ty::t)
}
}
fn
decr_refcnt_maybe_free
<
'blk
,
'tcx
>
(
bcx
:
Block
<
'blk
,
'tcx
>
,
box_ptr_ptr
:
ValueRef
,
t
:
ty
::
t
)
->
Block
<
'blk
,
'tcx
>
{
let
_
icx
=
push_ctxt
(
"decr_refcnt_maybe_free"
);
let
fcx
=
bcx
.fcx
;
let
ccx
=
bcx
.ccx
();
let
decr_bcx
=
fcx
.new_temp_block
(
"decr"
);
let
free_bcx
=
fcx
.new_temp_block
(
"free"
);
let
next_bcx
=
fcx
.new_temp_block
(
"next"
);
let
box_ptr
=
Load
(
bcx
,
box_ptr_ptr
);
let
llnotnull
=
IsNotNull
(
bcx
,
box_ptr
);
CondBr
(
bcx
,
llnotnull
,
decr_bcx
.llbb
,
next_bcx
.llbb
);
let
rc_ptr
=
GEPi
(
decr_bcx
,
box_ptr
,
[
0u
,
abi
::
box_field_refcnt
]);
let
rc
=
Sub
(
decr_bcx
,
Load
(
decr_bcx
,
rc_ptr
),
C_int
(
ccx
,
1
));
Store
(
decr_bcx
,
rc
,
rc_ptr
);
CondBr
(
decr_bcx
,
IsNull
(
decr_bcx
,
rc
),
free_bcx
.llbb
,
next_bcx
.llbb
);
let
v
=
Load
(
free_bcx
,
box_ptr_ptr
);
let
body
=
GEPi
(
free_bcx
,
v
,
[
0u
,
abi
::
box_field_body
]);
let
free_bcx
=
drop_ty
(
free_bcx
,
body
,
t
,
None
);
let
free_bcx
=
trans_free
(
free_bcx
,
v
);
Br
(
free_bcx
,
next_bcx
.llbb
);
next_bcx
}
fn
incr_refcnt_of_boxed
<
'blk
,
'tcx
>
(
bcx
:
Block
<
'blk
,
'tcx
>
,
box_ptr_ptr
:
ValueRef
)
->
Block
<
'blk
,
'tcx
>
{
let
_
icx
=
push_ctxt
(
"incr_refcnt_of_boxed"
);
let
ccx
=
bcx
.ccx
();
let
box_ptr
=
Load
(
bcx
,
box_ptr_ptr
);
let
rc_ptr
=
GEPi
(
bcx
,
box_ptr
,
[
0u
,
abi
::
box_field_refcnt
]);
let
rc
=
Load
(
bcx
,
rc_ptr
);
let
rc
=
Add
(
bcx
,
rc
,
C_int
(
ccx
,
1
));
Store
(
bcx
,
rc
,
rc_ptr
);
bcx
}
// Generates the declaration for (but doesn't emit) a type descriptor.
pub
fn
declare_tydesc
(
ccx
:
&
CrateContext
,
t
:
ty
::
t
)
->
tydesc_info
{
// If emit_tydescs already ran, then we shouldn't be creating any new
...
...
src/librustc/middle/trans/reflect.rs
浏览文件 @
8a91d33e
...
...
@@ -169,14 +169,6 @@ pub fn visit_ty(&mut self, t: ty::t) {
extra
.push
(
self
.c_tydesc
(
ty
));
self
.visit
(
"evec_fixed"
,
extra
.as_slice
())
}
// Should remove mt from box and uniq.
ty
::
ty_box
(
typ
)
=>
{
let
extra
=
self
.c_mt
(
&
ty
::
mt
{
ty
:
typ
,
mutbl
:
ast
::
MutImmutable
,
});
self
.visit
(
"box"
,
extra
.as_slice
())
}
ty
::
ty_ptr
(
ref
mt
)
=>
{
match
ty
::
get
(
mt
.ty
)
.sty
{
ty
::
ty_vec
(
ty
,
None
)
=>
{
...
...
src/librustc/middle/trans/tvec.rs
浏览文件 @
8a91d33e
...
...
@@ -325,7 +325,7 @@ pub fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let
bcx
=
iter_vec_loop
(
bcx
,
lldest
,
vt
,
C_uint
(
bcx
.ccx
(),
count
),
|
set_bcx
,
lleltptr
,
_
|
{
elem
.shallow_copy
_and_take
(
set_bcx
,
lleltptr
)
elem
.shallow_copy
(
set_bcx
,
lleltptr
)
});
elem
.add_clean_if_rvalue
(
bcx
,
element
.id
);
...
...
src/librustc/middle/trans/type_of.rs
浏览文件 @
8a91d33e
...
...
@@ -174,7 +174,6 @@ pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type {
ty
::
ty_uint
(
t
)
=>
Type
::
uint_from_ty
(
cx
,
t
),
ty
::
ty_float
(
t
)
=>
Type
::
float_from_ty
(
cx
,
t
),
ty
::
ty_box
(
..
)
=>
Type
::
i8p
(
cx
),
ty
::
ty_uniq
(
ty
)
|
ty
::
ty_rptr
(
_
,
ty
::
mt
{
ty
,
..
})
|
ty
::
ty_ptr
(
ty
::
mt
{
ty
,
..
})
=>
{
if
ty
::
type_is_sized
(
cx
.tcx
(),
ty
)
{
Type
::
i8p
(
cx
)
...
...
@@ -299,9 +298,6 @@ fn type_of_unsize_info(cx: &CrateContext, t: ty::t) -> Type {
let
name
=
llvm_type_name
(
cx
,
an_unboxed_closure
,
did
,
[]);
adt
::
incomplete_type_of
(
cx
,
&*
repr
,
name
.as_slice
())
}
ty
::
ty_box
(
typ
)
=>
{
Type
::
at_box
(
cx
,
type_of
(
cx
,
typ
))
.ptr_to
()
}
ty
::
ty_uniq
(
ty
)
|
ty
::
ty_rptr
(
_
,
ty
::
mt
{
ty
,
..
})
|
ty
::
ty_ptr
(
ty
::
mt
{
ty
,
..
})
=>
{
match
ty
::
get
(
ty
)
.sty
{
...
...
src/librustc/middle/ty.rs
浏览文件 @
8a91d33e
...
...
@@ -940,7 +940,6 @@ pub enum sty {
/// the `ast_ty_to_ty_cache`. This is probably true for `ty_struct` as
/// well.`
ty_enum
(
DefId
,
Substs
),
ty_box
(
t
),
ty_uniq
(
t
),
ty_str
,
ty_vec
(
t
,
Option
<
uint
>
),
// Second field is length.
...
...
@@ -1621,7 +1620,7 @@ fn flags_for_bounds(bounds: &ExistentialBounds) -> uint {
flags
|
=
sflags
(
substs
);
flags
|
=
flags_for_bounds
(
bounds
);
}
&
ty_
box
(
tt
)
|
&
ty_
uniq
(
tt
)
|
&
ty_vec
(
tt
,
_
)
|
&
ty_open
(
tt
)
=>
{
&
ty_uniq
(
tt
)
|
&
ty_vec
(
tt
,
_
)
|
&
ty_open
(
tt
)
=>
{
flags
|
=
get
(
tt
)
.flags
}
&
ty_ptr
(
ref
m
)
=>
{
...
...
@@ -1776,8 +1775,6 @@ pub fn mk_enum(cx: &ctxt, did: ast::DefId, substs: Substs) -> t {
mk_t
(
cx
,
ty_enum
(
did
,
substs
))
}
pub
fn
mk_box
(
cx
:
&
ctxt
,
ty
:
t
)
->
t
{
mk_t
(
cx
,
ty_box
(
ty
))
}
pub
fn
mk_uniq
(
cx
:
&
ctxt
,
ty
:
t
)
->
t
{
mk_t
(
cx
,
ty_uniq
(
ty
))
}
pub
fn
mk_ptr
(
cx
:
&
ctxt
,
tm
:
mt
)
->
t
{
mk_t
(
cx
,
ty_ptr
(
tm
))
}
...
...
@@ -1901,7 +1898,7 @@ pub fn maybe_walk_ty(ty: t, f: |t| -> bool) {
match
get
(
ty
)
.sty
{
ty_nil
|
ty_bot
|
ty_bool
|
ty_char
|
ty_int
(
_
)
|
ty_uint
(
_
)
|
ty_float
(
_
)
|
ty_str
|
ty_infer
(
_
)
|
ty_param
(
_
)
|
ty_unboxed_closure
(
_
,
_
)
|
ty_err
=>
{}
ty_
box
(
ty
)
|
ty_
uniq
(
ty
)
|
ty_vec
(
ty
,
_
)
|
ty_open
(
ty
)
=>
maybe_walk_ty
(
ty
,
f
),
ty_uniq
(
ty
)
|
ty_vec
(
ty
,
_
)
|
ty_open
(
ty
)
=>
maybe_walk_ty
(
ty
,
f
),
ty_ptr
(
ref
tm
)
|
ty_rptr
(
_
,
ref
tm
)
=>
{
maybe_walk_ty
(
tm
.ty
,
f
);
}
...
...
@@ -2014,7 +2011,7 @@ pub fn type_is_vec(ty: t) -> bool {
match
get
(
ty
)
.sty
{
ty_vec
(
..
)
=>
true
,
ty_ptr
(
mt
{
ty
:
t
,
..
})
|
ty_rptr
(
_
,
mt
{
ty
:
t
,
..
})
|
ty_
box
(
t
)
|
ty_
uniq
(
t
)
=>
match
get
(
t
)
.sty
{
ty_uniq
(
t
)
=>
match
get
(
t
)
.sty
{
ty_vec
(
_
,
None
)
=>
true
,
_
=>
false
},
...
...
@@ -2067,13 +2064,6 @@ pub fn simd_size(cx: &ctxt, ty: t) -> uint {
}
}
pub
fn
type_is_boxed
(
ty
:
t
)
->
bool
{
match
get
(
ty
)
.sty
{
ty_box
(
_
)
=>
true
,
_
=>
false
}
}
pub
fn
type_is_region_ptr
(
ty
:
t
)
->
bool
{
match
get
(
ty
)
.sty
{
ty_rptr
(
..
)
=>
true
,
...
...
@@ -2144,29 +2134,22 @@ pub fn type_needs_unwind_cleanup(cx: &ctxt, ty: t) -> bool {
let
mut
tycache
=
HashSet
::
new
();
let
needs_unwind_cleanup
=
type_needs_unwind_cleanup_
(
cx
,
ty
,
&
mut
tycache
,
false
);
type_needs_unwind_cleanup_
(
cx
,
ty
,
&
mut
tycache
);
cx
.needs_unwind_cleanup_cache
.borrow_mut
()
.insert
(
ty
,
needs_unwind_cleanup
);
return
needs_unwind_cleanup
;
needs_unwind_cleanup
}
fn
type_needs_unwind_cleanup_
(
cx
:
&
ctxt
,
ty
:
t
,
tycache
:
&
mut
HashSet
<
t
>
,
encountered_box
:
bool
)
->
bool
{
tycache
:
&
mut
HashSet
<
t
>
)
->
bool
{
// Prevent infinite recursion
if
!
tycache
.insert
(
ty
)
{
return
false
;
}
let
mut
encountered_box
=
encountered_box
;
let
mut
needs_unwind_cleanup
=
false
;
maybe_walk_ty
(
ty
,
|
ty
|
{
let
old_encountered_box
=
encountered_box
;
let
result
=
match
get
(
ty
)
.sty
{
ty_box
(
_
)
=>
{
encountered_box
=
true
;
true
}
ty_nil
|
ty_bot
|
ty_bool
|
ty_int
(
_
)
|
ty_uint
(
_
)
|
ty_float
(
_
)
|
ty_tup
(
_
)
|
ty_ptr
(
_
)
=>
{
true
...
...
@@ -2176,33 +2159,21 @@ fn type_needs_unwind_cleanup_(cx: &ctxt, ty: t,
for
aty
in
v
.args
.iter
()
{
let
t
=
aty
.subst
(
cx
,
substs
);
needs_unwind_cleanup
|
=
type_needs_unwind_cleanup_
(
cx
,
t
,
tycache
,
encountered_box
);
type_needs_unwind_cleanup_
(
cx
,
t
,
tycache
);
}
}
!
needs_unwind_cleanup
}
ty_uniq
(
_
)
=>
{
// Once we're inside a box, the annihilator will find
// it and destroy it.
if
!
encountered_box
{
needs_unwind_cleanup
=
true
;
false
}
else
{
true
}
}
_
=>
{
needs_unwind_cleanup
=
true
;
false
}
};
encountered_box
=
old_encountered_box
;
result
});
return
needs_unwind_cleanup
;
needs_unwind_cleanup
}
/**
...
...
@@ -2460,10 +2431,6 @@ fn tc_ty(cx: &ctxt,
closure_contents
(
cx
,
&**
c
)
|
TC
::
ReachesFfiUnsafe
}
ty_box
(
typ
)
=>
{
tc_ty
(
cx
,
typ
,
cache
)
.managed_pointer
()
|
TC
::
ReachesFfiUnsafe
}
ty_uniq
(
typ
)
=>
{
TC
::
ReachesFfiUnsafe
|
match
get
(
typ
)
.sty
{
ty_str
=>
TC
::
OwnsOwned
,
...
...
@@ -2782,7 +2749,7 @@ fn subtypes_require(cx: &ctxt, seen: &mut Vec<DefId>,
ty_vec
(
_
,
None
)
=>
{
false
}
ty_
box
(
typ
)
|
ty_
uniq
(
typ
)
|
ty_open
(
typ
)
=>
{
ty_uniq
(
typ
)
|
ty_open
(
typ
)
=>
{
type_requires
(
cx
,
seen
,
r_ty
,
typ
)
}
ty_rptr
(
_
,
ref
mt
)
=>
{
...
...
@@ -3092,7 +3059,7 @@ pub fn type_is_c_like_enum(cx: &ctxt, ty: t) -> bool {
// Some types---notably unsafe ptrs---can only be dereferenced explicitly.
pub
fn
deref
(
t
:
t
,
explicit
:
bool
)
->
Option
<
mt
>
{
match
get
(
t
)
.sty
{
ty_
box
(
ty
)
|
ty_
uniq
(
ty
)
=>
{
ty_uniq
(
ty
)
=>
{
Some
(
mt
{
ty
:
ty
,
mutbl
:
ast
::
MutImmutable
,
...
...
@@ -3106,9 +3073,7 @@ pub fn deref(t: t, explicit: bool) -> Option<mt> {
pub
fn
deref_or_dont
(
t
:
t
)
->
t
{
match
get
(
t
)
.sty
{
ty_box
(
ty
)
|
ty_uniq
(
ty
)
=>
{
ty
},
ty_uniq
(
ty
)
=>
ty
,
ty_rptr
(
_
,
mt
)
|
ty_ptr
(
mt
)
=>
mt
.ty
,
_
=>
t
}
...
...
@@ -3124,7 +3089,7 @@ pub fn close_type(cx: &ctxt, t: t) -> t {
pub
fn
type_content
(
t
:
t
)
->
t
{
match
get
(
t
)
.sty
{
ty_
box
(
ty
)
|
ty_
uniq
(
ty
)
=>
ty
,
ty_uniq
(
ty
)
=>
ty
,
ty_rptr
(
_
,
mt
)
|
ty_ptr
(
mt
)
=>
mt
.ty
,
_
=>
t
}
...
...
@@ -3695,14 +3660,13 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind {
}
ast
::
ExprBox
(
ref
place
,
_
)
=>
{
// Special case `Box<T>`
/`Gc<T>`
for now:
// Special case `Box<T>` for now:
let
definition
=
match
tcx
.def_map
.borrow
()
.find
(
&
place
.id
)
{
Some
(
&
def
)
=>
def
,
None
=>
fail
!
(
"no def for place"
),
};
let
def_id
=
definition
.def_id
();
if
tcx
.lang_items
.exchange_heap
()
==
Some
(
def_id
)
||
tcx
.lang_items
.managed_heap
()
==
Some
(
def_id
)
{
if
tcx
.lang_items
.exchange_heap
()
==
Some
(
def_id
)
{
RvalueDatumExpr
}
else
{
RvalueDpsExpr
...
...
@@ -3753,7 +3717,6 @@ pub fn ty_sort_string(cx: &ctxt, t: t) -> String {
}
ty_enum
(
id
,
_
)
=>
format!
(
"enum {}"
,
item_path_str
(
cx
,
id
)),
ty_box
(
_
)
=>
"Gc-ptr"
.to_string
(),
ty_uniq
(
_
)
=>
"box"
.to_string
(),
ty_vec
(
_
,
Some
(
_
))
=>
"array"
.to_string
(),
ty_vec
(
_
,
None
)
=>
"unsized array"
.to_string
(),
...
...
@@ -5223,19 +5186,15 @@ pub fn hash_crate_independent(tcx: &ctxt, t: t, svh: &Svh) -> u64 {
byte!
(
8
);
did
(
&
mut
state
,
d
);
}
ty_box
(
_
)
=>
{
byte!
(
9
);
}
ty_uniq
(
_
)
=>
{
byte!
(
10
);
byte!
(
9
);
}
ty_vec
(
_
,
Some
(
n
))
=>
{
byte!
(
1
1
);
byte!
(
1
0
);
n
.hash
(
&
mut
state
);
}
ty_vec
(
_
,
None
)
=>
{
byte!
(
11
);
0u8
.hash
(
&
mut
state
);
}
ty_ptr
(
m
)
=>
{
byte!
(
12
);
...
...
@@ -5586,7 +5545,6 @@ pub fn accumulate_lifetimes_in_type(accumulator: &mut Vec<ty::Region>,
ty_int
(
_
)
|
ty_uint
(
_
)
|
ty_float
(
_
)
|
ty_box
(
_
)
|
ty_uniq
(
_
)
|
ty_str
|
ty_vec
(
_
,
_
)
|
...
...
src/librustc/middle/ty_fold.rs
浏览文件 @
8a91d33e
...
...
@@ -458,9 +458,6 @@ pub fn super_fold_mt<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
pub
fn
super_fold_sty
<
'tcx
,
T
:
TypeFolder
<
'tcx
>>
(
this
:
&
mut
T
,
sty
:
&
ty
::
sty
)
->
ty
::
sty
{
match
*
sty
{
ty
::
ty_box
(
typ
)
=>
{
ty
::
ty_box
(
typ
.fold_with
(
this
))
}
ty
::
ty_uniq
(
typ
)
=>
{
ty
::
ty_uniq
(
typ
.fold_with
(
this
))
}
...
...
src/librustc/middle/typeck/astconv.rs
浏览文件 @
8a91d33e
...
...
@@ -559,44 +559,6 @@ pub fn ast_ty_to_builtin_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
"not enough type parameters supplied to `Box<T>`"
);
Some
(
ty
::
mk_err
())
}
def
::
DefTy
(
did
,
_
)
|
def
::
DefStruct
(
did
)
if
Some
(
did
)
==
this
.tcx
()
.lang_items
.gc
()
=>
{
if
path
.segments
.iter
()
.flat_map
(|
s
|
s
.types
.iter
())
.count
()
>
1
{
span_err!
(
this
.tcx
()
.sess
,
path
.span
,
E0048
,
"`Gc` has only one type parameter"
);
}
for
inner_ast_type
in
path
.segments
.iter
()
.flat_map
(|
s
|
s
.types
.iter
())
{
return
Some
(
mk_pointer
(
this
,
rscope
,
ast
::
MutImmutable
,
&**
inner_ast_type
,
Box
,
|
typ
|
{
match
ty
::
get
(
typ
)
.sty
{
ty
::
ty_str
=>
{
span_err!
(
this
.tcx
()
.sess
,
path
.span
,
E0114
,
"`Gc<str>` is not a type"
);
ty
::
mk_err
()
}
ty
::
ty_vec
(
_
,
None
)
=>
{
span_err!
(
this
.tcx
()
.sess
,
path
.span
,
E0115
,
"`Gc<[T]>` is not a type"
);
ty
::
mk_err
()
}
_
=>
ty
::
mk_box
(
this
.tcx
(),
typ
),
}
}))
}
this
.tcx
()
.sess
.span_bug
(
path
.span
,
"not enough type parameters
\
supplied to `Gc<T>`"
)
}
_
=>
None
}
}
...
...
@@ -606,7 +568,6 @@ pub fn ast_ty_to_builtin_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
#[deriving(Show)]
enum
PointerTy
{
Box
,
RPtr
(
ty
::
Region
),
Uniq
}
...
...
@@ -614,7 +575,6 @@ enum PointerTy {
impl
PointerTy
{
fn
default_region
(
&
self
)
->
ty
::
Region
{
match
*
self
{
Box
=>
ty
::
ReStatic
,
Uniq
=>
ty
::
ReStatic
,
RPtr
(
r
)
=>
r
,
}
...
...
@@ -702,14 +662,6 @@ fn mk_pointer<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
r
,
ty
::
mt
{
mutbl
:
a_seq_mutbl
,
ty
:
tr
});
}
_
=>
{
tcx
.sess
.span_err
(
a_seq_ty
.span
,
"~trait or &trait are the only supported
\
forms of casting-to-trait"
);
return
ty
::
mk_err
();
}
}
}
ast
::
TyPath
(
ref
path
,
ref
opt_bounds
,
id
)
=>
{
...
...
@@ -726,11 +678,6 @@ fn mk_pointer<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
RPtr
(
r
)
=>
{
return
ty
::
mk_str_slice
(
tcx
,
r
,
ast
::
MutImmutable
);
}
_
=>
{
tcx
.sess
.span_err
(
path
.span
,
"managed strings are not supported"
)
}
}
}
Some
(
&
def
::
DefTrait
(
trait_def_id
))
=>
{
...
...
@@ -767,13 +714,6 @@ fn mk_pointer<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
RPtr
(
r
)
=>
{
return
ty
::
mk_rptr
(
tcx
,
r
,
ty
::
mt
{
mutbl
:
a_seq_mutbl
,
ty
:
tr
});
}
_
=>
{
tcx
.sess
.span_err
(
path
.span
,
"~trait or &trait are the only supported
\
forms of casting-to-trait"
);
return
ty
::
mk_err
();
}
};
}
_
=>
{}
...
...
src/librustc/middle/typeck/check/method.rs
浏览文件 @
8a91d33e
...
...
@@ -1094,7 +1094,7 @@ fn search_for_autoptrd_method(&self, self_ty: ty::t, autoderefs: uint)
let
tcx
=
self
.tcx
();
match
ty
::
get
(
self_ty
)
.sty
{
ty_bare_fn
(
..
)
|
ty_
box
(
..
)
|
ty_
uniq
(
..
)
|
ty_rptr
(
..
)
|
ty_bare_fn
(
..
)
|
ty_uniq
(
..
)
|
ty_rptr
(
..
)
|
ty_infer
(
IntVar
(
_
))
|
ty_infer
(
FloatVar
(
_
))
|
ty_param
(
..
)
|
ty_nil
|
ty_bot
|
ty_bool
|
...
...
src/librustc/middle/typeck/check/mod.rs
浏览文件 @
8a91d33e
...
...
@@ -3820,12 +3820,6 @@ fn check_struct_fields_on_error(fcx: &FnCtxt,
if
tcx
.lang_items
.exchange_heap
()
==
Some
(
def_id
)
{
fcx
.write_ty
(
id
,
ty
::
mk_uniq
(
tcx
,
referent_ty
));
checked
=
true
}
else
if
tcx
.lang_items
.managed_heap
()
==
Some
(
def_id
)
{
fcx
.register_region_obligation
(
infer
::
Managed
(
expr
.span
),
referent_ty
,
ty
::
ReStatic
);
fcx
.write_ty
(
id
,
ty
::
mk_box
(
tcx
,
referent_ty
));
checked
=
true
}
}
_
=>
{}
...
...
src/librustc/middle/typeck/check/regionck.rs
浏览文件 @
8a91d33e
...
...
@@ -1466,7 +1466,6 @@ fn link_region(rcx: &Rcx,
mc
::
cat_discr
(
cmt_base
,
_
)
|
mc
::
cat_downcast
(
cmt_base
)
|
mc
::
cat_deref
(
cmt_base
,
_
,
mc
::
GcPtr
(
..
))
|
mc
::
cat_deref
(
cmt_base
,
_
,
mc
::
OwnedPtr
)
|
mc
::
cat_interior
(
cmt_base
,
_
)
=>
{
// Borrowing interior or owned data requires the base
...
...
@@ -1699,7 +1698,6 @@ fn adjust_upvar_borrow_kind_for_mut(rcx: &Rcx,
}
mc
::
cat_deref
(
_
,
_
,
mc
::
UnsafePtr
(
..
))
|
mc
::
cat_deref
(
_
,
_
,
mc
::
GcPtr
)
|
mc
::
cat_static_item
|
mc
::
cat_rvalue
(
_
)
|
mc
::
cat_copied_upvar
(
_
)
|
...
...
@@ -1750,7 +1748,6 @@ fn adjust_upvar_borrow_kind_for_unique(rcx: &Rcx, cmt: mc::cmt) {
}
mc
::
cat_deref
(
_
,
_
,
mc
::
UnsafePtr
(
..
))
|
mc
::
cat_deref
(
_
,
_
,
mc
::
GcPtr
)
|
mc
::
cat_static_item
|
mc
::
cat_rvalue
(
_
)
|
mc
::
cat_copied_upvar
(
_
)
|
...
...
src/librustc/middle/typeck/check/regionmanip.rs
浏览文件 @
8a91d33e
...
...
@@ -129,7 +129,6 @@ fn accumulate_from_ty(&mut self, ty: ty::t) {
ty
::
ty_vec
(
t
,
_
)
|
ty
::
ty_ptr
(
ty
::
mt
{
ty
:
t
,
..
})
|
ty
::
ty_box
(
t
)
|
ty
::
ty_uniq
(
t
)
=>
{
self
.accumulate_from_ty
(
t
)
}
...
...
src/librustc/middle/typeck/check/vtable2.rs
浏览文件 @
8a91d33e
...
...
@@ -95,7 +95,7 @@ pub fn check_object_cast(fcx: &FnCtxt,
}
}
// Because we currently give unsound lifetimes to the "t
y
_box", I
// Because we currently give unsound lifetimes to the "t_box", I
// could have written &'static ty::TyTrait here, but it seems
// gratuitously unsafe.
fn
object_trait
<
'a
>
(
t
:
&
'a
ty
::
t
)
->
&
'a
ty
::
TyTrait
{
...
...
src/librustc/middle/typeck/coherence/mod.rs
浏览文件 @
8a91d33e
...
...
@@ -23,7 +23,7 @@
use
middle
::
ty
::
get
;
use
middle
::
ty
::{
ImplContainer
,
ImplOrTraitItemId
,
MethodTraitItemId
};
use
middle
::
ty
::{
TypeTraitItemId
,
lookup_item_type
};
use
middle
::
ty
::{
t
,
ty_bool
,
ty_char
,
ty_bot
,
ty_
box
,
ty_
enum
,
ty_err
};
use
middle
::
ty
::{
t
,
ty_bool
,
ty_char
,
ty_bot
,
ty_enum
,
ty_err
};
use
middle
::
ty
::{
ty_str
,
ty_vec
,
ty_float
,
ty_infer
,
ty_int
,
ty_nil
,
ty_open
};
use
middle
::
ty
::{
ty_param
,
Polytype
,
ty_ptr
};
use
middle
::
ty
::{
ty_rptr
,
ty_struct
,
ty_trait
,
ty_tup
};
...
...
@@ -84,8 +84,8 @@ fn get_base_type(inference_context: &InferCtxt,
ty_nil
|
ty_bot
|
ty_bool
|
ty_char
|
ty_int
(
..
)
|
ty_uint
(
..
)
|
ty_float
(
..
)
|
ty_str
(
..
)
|
ty_vec
(
..
)
|
ty_bare_fn
(
..
)
|
ty_closure
(
..
)
|
ty_tup
(
..
)
|
ty_infer
(
..
)
|
ty_param
(
..
)
|
ty_err
|
ty_open
(
..
)
|
ty_
box
(
_
)
|
ty_uniq
(
_
)
|
ty_
ptr
(
_
)
|
ty_rptr
(
_
,
_
)
=>
{
ty_infer
(
..
)
|
ty_param
(
..
)
|
ty_err
|
ty_open
(
..
)
|
ty_uniq
(
_
)
|
ty_ptr
(
_
)
|
ty_rptr
(
_
,
_
)
=>
{
debug!
(
"(getting base type) no base type; found {:?}"
,
get
(
original_type
)
.sty
);
None
...
...
src/librustc/middle/typeck/infer/coercion.rs
浏览文件 @
8a91d33e
...
...
@@ -258,7 +258,7 @@ pub fn coerce_borrowed_pointer(&self,
let
r_borrow
=
self
.get_ref
()
.infcx
.next_region_var
(
coercion
);
let
inner_ty
=
match
*
sty_a
{
ty
::
ty_
box
(
_
)
|
ty
::
ty_
uniq
(
_
)
=>
return
Err
(
ty
::
terr_mismatch
),
ty
::
ty_uniq
(
_
)
=>
return
Err
(
ty
::
terr_mismatch
),
ty
::
ty_rptr
(
_
,
mt_a
)
=>
mt_a
.ty
,
_
=>
{
return
self
.subtype
(
a
,
b
);
...
...
src/librustc/middle/typeck/infer/combine.rs
浏览文件 @
8a91d33e
...
...
@@ -495,10 +495,6 @@ fn check_ptr_to_unsized<'tcx, C: Combine<'tcx>>(this: &C,
Ok
(
ty
::
mk_unboxed_closure
(
tcx
,
a_id
,
region
))
}
(
&
ty
::
ty_box
(
a_inner
),
&
ty
::
ty_box
(
b_inner
))
=>
{
this
.tys
(
a_inner
,
b_inner
)
.and_then
(|
typ
|
Ok
(
ty
::
mk_box
(
tcx
,
typ
)))
}
(
&
ty
::
ty_uniq
(
a_inner
),
&
ty
::
ty_uniq
(
b_inner
))
=>
{
let
typ
=
try!
(
this
.tys
(
a_inner
,
b_inner
));
check_ptr_to_unsized
(
this
,
a
,
b
,
a_inner
,
b_inner
,
ty
::
mk_uniq
(
tcx
,
typ
))
...
...
src/librustc/middle/typeck/infer/error_reporting.rs
浏览文件 @
8a91d33e
...
...
@@ -776,11 +776,6 @@ fn report_concrete_failure(&self,
sup
,
""
);
}
infer
::
Managed
(
span
)
=>
{
self
.tcx.sess
.span_err
(
span
,
format!
(
"cannot put borrowed references into managed memory"
)
.as_slice
());
}
}
}
...
...
@@ -1612,11 +1607,6 @@ fn note_region_origin(&self, origin: &SubregionOrigin) {
does not outlive the data it points at"
,
self
.ty_to_string
(
ty
))
.as_slice
());
}
infer
::
Managed
(
span
)
=>
{
self
.tcx.sess
.span_note
(
span
,
"...so that the value can be stored in managed memory."
);
}
infer
::
RelateParamBound
(
span
,
param_ty
,
t
)
=>
{
self
.tcx.sess
.span_note
(
span
,
...
...
src/librustc/middle/typeck/infer/mod.rs
浏览文件 @
8a91d33e
...
...
@@ -216,9 +216,6 @@ pub enum SubregionOrigin {
// An auto-borrow that does not enclose the expr where it occurs
AutoBorrow
(
Span
),
// Managed data cannot contain borrowed pointers.
Managed
(
Span
),
}
/// Reasons to create a region inference variable
...
...
@@ -1029,7 +1026,6 @@ pub fn span(&self) -> Span {
CallReturn
(
a
)
=>
a
,
AddrOf
(
a
)
=>
a
,
AutoBorrow
(
a
)
=>
a
,
Managed
(
a
)
=>
a
,
}
}
}
...
...
@@ -1102,7 +1098,6 @@ fn repr(&self, tcx: &ty::ctxt) -> String {
CallReturn
(
a
)
=>
format!
(
"CallReturn({})"
,
a
.repr
(
tcx
)),
AddrOf
(
a
)
=>
format!
(
"AddrOf({})"
,
a
.repr
(
tcx
)),
AutoBorrow
(
a
)
=>
format!
(
"AutoBorrow({})"
,
a
.repr
(
tcx
)),
Managed
(
a
)
=>
format!
(
"Managed({})"
,
a
.repr
(
tcx
)),
}
}
}
...
...
src/librustc/middle/typeck/infer/skolemize.rs
浏览文件 @
8a91d33e
...
...
@@ -143,7 +143,6 @@ fn fold_ty(&mut self, t: ty::t) -> ty::t {
ty
::
ty_uint
(
..
)
|
ty
::
ty_float
(
..
)
|
ty
::
ty_enum
(
..
)
|
ty
::
ty_box
(
..
)
|
ty
::
ty_uniq
(
..
)
|
ty
::
ty_str
|
ty
::
ty_err
|
...
...
src/librustc/middle/typeck/variance.rs
浏览文件 @
8a91d33e
...
...
@@ -742,7 +742,7 @@ fn add_constraints_from_ty(&mut self,
self
.add_constraints_from_mt
(
mt
,
variance
);
}
ty
::
ty_uniq
(
typ
)
|
ty
::
ty_
box
(
typ
)
|
ty
::
ty_
vec
(
typ
,
_
)
|
ty
::
ty_open
(
typ
)
=>
{
ty
::
ty_uniq
(
typ
)
|
ty
::
ty_vec
(
typ
,
_
)
|
ty
::
ty_open
(
typ
)
=>
{
self
.add_constraints_from_ty
(
typ
,
variance
);
}
...
...
src/librustc/util/ppaux.rs
浏览文件 @
8a91d33e
...
...
@@ -17,7 +17,7 @@
use
middle
::
ty
::{
ReFree
,
ReScope
,
ReInfer
,
ReStatic
,
Region
,
ReEmpty
};
use
middle
::
ty
::{
ReSkolemized
,
ReVar
};
use
middle
::
ty
::{
mt
,
t
,
ParamTy
};
use
middle
::
ty
::{
ty_bool
,
ty_char
,
ty_bot
,
ty_
box
,
ty_
struct
,
ty_enum
};
use
middle
::
ty
::{
ty_bool
,
ty_char
,
ty_bot
,
ty_struct
,
ty_enum
};
use
middle
::
ty
::{
ty_err
,
ty_str
,
ty_vec
,
ty_float
,
ty_bare_fn
,
ty_closure
};
use
middle
::
ty
::{
ty_nil
,
ty_param
,
ty_ptr
,
ty_rptr
,
ty_tup
,
ty_open
};
use
middle
::
ty
::{
ty_unboxed_closure
};
...
...
@@ -375,7 +375,6 @@ fn push_sig_to_string(cx: &ctxt,
ty_int
(
t
)
=>
ast_util
::
int_ty_to_string
(
t
,
None
)
.to_string
(),
ty_uint
(
t
)
=>
ast_util
::
uint_ty_to_string
(
t
,
None
)
.to_string
(),
ty_float
(
t
)
=>
ast_util
::
float_ty_to_string
(
t
)
.to_string
(),
ty_box
(
typ
)
=>
format!
(
"Gc<{}>"
,
ty_to_string
(
cx
,
typ
)),
ty_uniq
(
typ
)
=>
format!
(
"Box<{}>"
,
ty_to_string
(
cx
,
typ
)),
ty_ptr
(
ref
tm
)
=>
{
format!
(
"*{} {}"
,
match
tm
.mutbl
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录