Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
27cc0a36
R
Rust
项目概览
int
/
Rust
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
27cc0a36
编写于
9月 11, 2012
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Promote 'struct' from a restricted keyword to a strict keyword
上级
1203da3b
变更
42
显示空白变更内容
内联
并排
Showing
42 changed file
with
185 addition
and
186 deletion
+185
-186
src/libsyntax/parse/token.rs
src/libsyntax/parse/token.rs
+1
-1
src/rustc/metadata/decoder.rs
src/rustc/metadata/decoder.rs
+2
-2
src/rustc/metadata/tyencode.rs
src/rustc/metadata/tyencode.rs
+2
-2
src/rustc/middle/borrowck/check_loans.rs
src/rustc/middle/borrowck/check_loans.rs
+1
-1
src/rustc/middle/check_alt.rs
src/rustc/middle/check_alt.rs
+7
-7
src/rustc/middle/const_eval.rs
src/rustc/middle/const_eval.rs
+1
-1
src/rustc/middle/kind.rs
src/rustc/middle/kind.rs
+4
-4
src/rustc/middle/lint.rs
src/rustc/middle/lint.rs
+2
-2
src/rustc/middle/mem_categorization.rs
src/rustc/middle/mem_categorization.rs
+4
-4
src/rustc/middle/privacy.rs
src/rustc/middle/privacy.rs
+3
-3
src/rustc/middle/trans/alt.rs
src/rustc/middle/trans/alt.rs
+3
-4
src/rustc/middle/trans/base.rs
src/rustc/middle/trans/base.rs
+6
-6
src/rustc/middle/trans/callee.rs
src/rustc/middle/trans/callee.rs
+1
-1
src/rustc/middle/trans/consts.rs
src/rustc/middle/trans/consts.rs
+4
-4
src/rustc/middle/trans/datum.rs
src/rustc/middle/trans/datum.rs
+2
-2
src/rustc/middle/trans/expr.rs
src/rustc/middle/trans/expr.rs
+4
-4
src/rustc/middle/trans/foreign.rs
src/rustc/middle/trans/foreign.rs
+1
-1
src/rustc/middle/trans/glue.rs
src/rustc/middle/trans/glue.rs
+6
-6
src/rustc/middle/trans/monomorphize.rs
src/rustc/middle/trans/monomorphize.rs
+1
-1
src/rustc/middle/trans/reflect.rs
src/rustc/middle/trans/reflect.rs
+1
-1
src/rustc/middle/trans/shape.rs
src/rustc/middle/trans/shape.rs
+3
-3
src/rustc/middle/trans/tvec.rs
src/rustc/middle/trans/tvec.rs
+2
-2
src/rustc/middle/trans/type_of.rs
src/rustc/middle/trans/type_of.rs
+3
-3
src/rustc/middle/trans/type_use.rs
src/rustc/middle/trans/type_use.rs
+3
-3
src/rustc/middle/ty.rs
src/rustc/middle/ty.rs
+66
-66
src/rustc/middle/typeck.rs
src/rustc/middle/typeck.rs
+3
-3
src/rustc/middle/typeck/astconv.rs
src/rustc/middle/typeck/astconv.rs
+2
-2
src/rustc/middle/typeck/check.rs
src/rustc/middle/typeck/check.rs
+11
-11
src/rustc/middle/typeck/check/method.rs
src/rustc/middle/typeck/check/method.rs
+6
-6
src/rustc/middle/typeck/check/regionck.rs
src/rustc/middle/typeck/check/regionck.rs
+2
-2
src/rustc/middle/typeck/check/regionmanip.rs
src/rustc/middle/typeck/check/regionmanip.rs
+1
-1
src/rustc/middle/typeck/check/vtable.rs
src/rustc/middle/typeck/check/vtable.rs
+8
-8
src/rustc/middle/typeck/coherence.rs
src/rustc/middle/typeck/coherence.rs
+4
-4
src/rustc/middle/typeck/collect.rs
src/rustc/middle/typeck/collect.rs
+2
-2
src/rustc/middle/typeck/infer/assignment.rs
src/rustc/middle/typeck/infer/assignment.rs
+2
-2
src/rustc/middle/typeck/infer/combine.rs
src/rustc/middle/typeck/infer/combine.rs
+3
-3
src/rustc/middle/typeck/infer/integral.rs
src/rustc/middle/typeck/infer/integral.rs
+1
-1
src/rustc/middle/typeck/infer/lattice.rs
src/rustc/middle/typeck/infer/lattice.rs
+1
-1
src/rustc/middle/typeck/infer/resolve.rs
src/rustc/middle/typeck/infer/resolve.rs
+1
-1
src/rustc/middle/typeck/infer/sub.rs
src/rustc/middle/typeck/infer/sub.rs
+1
-1
src/rustc/util/ppaux.rs
src/rustc/util/ppaux.rs
+2
-2
src/test/run-pass/alias-uninit-value.rs
src/test/run-pass/alias-uninit-value.rs
+2
-2
未找到文件。
src/libsyntax/parse/token.rs
浏览文件 @
27cc0a36
...
@@ -415,7 +415,6 @@ fn restricted_keyword_table() -> HashMap<~str, ()> {
...
@@ -415,7 +415,6 @@ fn restricted_keyword_table() -> HashMap<~str, ()> {
~
"fail"
,
~
"fn"
,
~
"fail"
,
~
"fn"
,
~
"impl"
,
~
"impl"
,
~
"priv"
,
~
"pub"
,
~
"priv"
,
~
"pub"
,
~
"struct"
,
~
"unsafe"
~
"unsafe"
];
];
for
keys
.each
|
word
|
{
for
keys
.each
|
word
|
{
...
@@ -438,6 +437,7 @@ fn strict_keyword_table() -> HashMap<~str, ()> {
...
@@ -438,6 +437,7 @@ fn strict_keyword_table() -> HashMap<~str, ()> {
~
"match"
,
~
"mod"
,
~
"move"
,
~
"mut"
,
~
"match"
,
~
"mod"
,
~
"move"
,
~
"mut"
,
~
"pure"
,
~
"pure"
,
~
"ref"
,
~
"return"
,
~
"ref"
,
~
"return"
,
~
"struct"
,
~
"true"
,
~
"trait"
,
~
"type"
,
~
"true"
,
~
"trait"
,
~
"type"
,
~
"unchecked"
,
~
"use"
,
~
"unchecked"
,
~
"use"
,
~
"while"
~
"while"
...
...
src/rustc/metadata/decoder.rs
浏览文件 @
27cc0a36
...
@@ -584,7 +584,7 @@ fn get_enum_variants(intr: ident_interner, cdata: cmd, id: ast::node_id,
...
@@ -584,7 +584,7 @@ fn get_enum_variants(intr: ident_interner, cdata: cmd, id: ast::node_id,
tcx
,
cdata
);
tcx
,
cdata
);
let
name
=
item_name
(
intr
,
item
);
let
name
=
item_name
(
intr
,
item
);
let
mut
arg_tys
:
~
[
ty
::
t
]
=
~
[];
let
mut
arg_tys
:
~
[
ty
::
t
]
=
~
[];
match
ty
::
get
(
ctor_ty
)
.st
ruct
{
match
ty
::
get
(
ctor_ty
)
.st
y
{
ty
::
ty_fn
(
f
)
=>
{
ty
::
ty_fn
(
f
)
=>
{
for
f
.sig.inputs.each
|
a
|
{
vec
::
push
(
arg_tys
,
a
.ty
);
}
for
f
.sig.inputs.each
|
a
|
{
vec
::
push
(
arg_tys
,
a
.ty
);
}
}
}
...
@@ -696,7 +696,7 @@ fn get_trait_methods(intr: ident_interner, cdata: cmd, id: ast::node_id,
...
@@ -696,7 +696,7 @@ fn get_trait_methods(intr: ident_interner, cdata: cmd, id: ast::node_id,
let
bounds
=
item_ty_param_bounds
(
mth
,
tcx
,
cdata
);
let
bounds
=
item_ty_param_bounds
(
mth
,
tcx
,
cdata
);
let
name
=
item_name
(
intr
,
mth
);
let
name
=
item_name
(
intr
,
mth
);
let
ty
=
doc_type
(
mth
,
tcx
,
cdata
);
let
ty
=
doc_type
(
mth
,
tcx
,
cdata
);
let
fty
=
match
ty
::
get
(
ty
)
.st
ruct
{
let
fty
=
match
ty
::
get
(
ty
)
.st
y
{
ty
::
ty_fn
(
f
)
=>
f
,
ty
::
ty_fn
(
f
)
=>
f
,
_
=>
{
_
=>
{
tcx
.diag
.handler
()
.bug
(
tcx
.diag
.handler
()
.bug
(
...
...
src/rustc/metadata/tyencode.rs
浏览文件 @
27cc0a36
...
@@ -47,7 +47,7 @@ fn enc_ty(w: io::Writer, cx: @ctxt, t: ty::t) {
...
@@ -47,7 +47,7 @@ fn enc_ty(w: io::Writer, cx: @ctxt, t: ty::t) {
Some
(
s
)
=>
*
s
,
Some
(
s
)
=>
*
s
,
None
=>
{
None
=>
{
let
buf
=
io
::
mem_buffer
();
let
buf
=
io
::
mem_buffer
();
enc_sty
(
io
::
mem_buffer_writer
(
buf
),
cx
,
ty
::
get
(
t
)
.st
ruct
);
enc_sty
(
io
::
mem_buffer_writer
(
buf
),
cx
,
ty
::
get
(
t
)
.st
y
);
cx
.tcx.short_names_cache
.insert
(
t
,
@
io
::
mem_buffer_str
(
buf
));
cx
.tcx.short_names_cache
.insert
(
t
,
@
io
::
mem_buffer_str
(
buf
));
io
::
mem_buffer_str
(
buf
)
io
::
mem_buffer_str
(
buf
)
}
}
...
@@ -72,7 +72,7 @@ fn enc_ty(w: io::Writer, cx: @ctxt, t: ty::t) {
...
@@ -72,7 +72,7 @@ fn enc_ty(w: io::Writer, cx: @ctxt, t: ty::t) {
}
}
_
=>
{}
_
=>
{}
}
}
enc_sty
(
w
,
cx
,
ty
::
get
(
t
)
.st
ruct
);
enc_sty
(
w
,
cx
,
ty
::
get
(
t
)
.st
y
);
let
end
=
w
.tell
();
let
end
=
w
.tell
();
let
len
=
end
-
pos
;
let
len
=
end
-
pos
;
fn
estimate_sz
(
u
:
uint
)
->
uint
{
fn
estimate_sz
(
u
:
uint
)
->
uint
{
...
...
src/rustc/middle/borrowck/check_loans.rs
浏览文件 @
27cc0a36
...
@@ -224,7 +224,7 @@ fn check_pure_callee_or_arg(pc: purity_cause,
...
@@ -224,7 +224,7 @@ fn check_pure_callee_or_arg(pc: purity_cause,
}
}
let
callee_ty
=
ty
::
node_id_to_type
(
tcx
,
callee_id
);
let
callee_ty
=
ty
::
node_id_to_type
(
tcx
,
callee_id
);
match
ty
::
get
(
callee_ty
)
.st
ruct
{
match
ty
::
get
(
callee_ty
)
.st
y
{
ty
::
ty_fn
(
fn_ty
)
=>
{
ty
::
ty_fn
(
fn_ty
)
=>
{
match
fn_ty
.meta.purity
{
match
fn_ty
.meta.purity
{
ast
::
pure_fn
=>
return
,
// case (c) above
ast
::
pure_fn
=>
return
,
// case (c) above
...
...
src/rustc/middle/check_alt.rs
浏览文件 @
27cc0a36
...
@@ -39,7 +39,7 @@ fn check_expr(tcx: ty::ctxt, ex: @expr, &&s: (), v: visit::vt<()>) {
...
@@ -39,7 +39,7 @@ fn check_expr(tcx: ty::ctxt, ex: @expr, &&s: (), v: visit::vt<()>) {
// If the type *is* empty, it's vacuously exhaustive
// If the type *is* empty, it's vacuously exhaustive
return
;
return
;
}
}
match
ty
::
get
(
pat_ty
)
.st
ruct
{
match
ty
::
get
(
pat_ty
)
.st
y
{
ty_enum
(
did
,
_
)
=>
{
ty_enum
(
did
,
_
)
=>
{
if
(
*
enum_variants
(
tcx
,
did
))
.is_empty
()
&&
arms
.is_empty
()
{
if
(
*
enum_variants
(
tcx
,
did
))
.is_empty
()
&&
arms
.is_empty
()
{
...
@@ -85,7 +85,7 @@ fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: ~[@pat]) {
...
@@ -85,7 +85,7 @@ fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: ~[@pat]) {
not_useful
=>
return
,
// This is good, wildcard pattern isn't reachable
not_useful
=>
return
,
// This is good, wildcard pattern isn't reachable
useful_
=>
None
,
useful_
=>
None
,
useful
(
ty
,
ctor
)
=>
{
useful
(
ty
,
ctor
)
=>
{
match
ty
::
get
(
ty
)
.st
ruct
{
match
ty
::
get
(
ty
)
.st
y
{
ty
::
ty_bool
=>
{
ty
::
ty_bool
=>
{
match
ctor
{
match
ctor
{
val
(
const_bool
(
true
))
=>
Some
(
~
"true"
),
val
(
const_bool
(
true
))
=>
Some
(
~
"true"
),
...
@@ -167,7 +167,7 @@ fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful {
...
@@ -167,7 +167,7 @@ fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful {
None
=>
{
None
=>
{
match
missing_ctor
(
tcx
,
m
,
left_ty
)
{
match
missing_ctor
(
tcx
,
m
,
left_ty
)
{
None
=>
{
None
=>
{
match
ty
::
get
(
left_ty
)
.st
ruct
{
match
ty
::
get
(
left_ty
)
.st
y
{
ty
::
ty_bool
=>
{
ty
::
ty_bool
=>
{
match
is_useful_specialized
(
tcx
,
m
,
v
,
val
(
const_bool
(
true
)),
match
is_useful_specialized
(
tcx
,
m
,
v
,
val
(
const_bool
(
true
)),
0u
,
left_ty
){
0u
,
left_ty
){
...
@@ -257,7 +257,7 @@ fn is_wild(tcx: ty::ctxt, p: @pat) -> bool {
...
@@ -257,7 +257,7 @@ fn is_wild(tcx: ty::ctxt, p: @pat) -> bool {
}
}
fn
missing_ctor
(
tcx
:
ty
::
ctxt
,
m
:
matrix
,
left_ty
:
ty
::
t
)
->
Option
<
ctor
>
{
fn
missing_ctor
(
tcx
:
ty
::
ctxt
,
m
:
matrix
,
left_ty
:
ty
::
t
)
->
Option
<
ctor
>
{
match
ty
::
get
(
left_ty
)
.st
ruct
{
match
ty
::
get
(
left_ty
)
.st
y
{
ty
::
ty_box
(
_
)
|
ty
::
ty_uniq
(
_
)
|
ty
::
ty_rptr
(
*
)
|
ty
::
ty_tup
(
_
)
|
ty
::
ty_box
(
_
)
|
ty
::
ty_uniq
(
_
)
|
ty
::
ty_rptr
(
*
)
|
ty
::
ty_tup
(
_
)
|
ty
::
ty_rec
(
_
)
|
ty
::
ty_class
(
*
)
=>
{
ty
::
ty_rec
(
_
)
|
ty
::
ty_class
(
*
)
=>
{
for
m
.each
|
r
|
{
for
m
.each
|
r
|
{
...
@@ -302,7 +302,7 @@ fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> Option<ctor> {
...
@@ -302,7 +302,7 @@ fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> Option<ctor> {
}
}
fn
ctor_arity
(
tcx
:
ty
::
ctxt
,
ctor
:
ctor
,
ty
:
ty
::
t
)
->
uint
{
fn
ctor_arity
(
tcx
:
ty
::
ctxt
,
ctor
:
ctor
,
ty
:
ty
::
t
)
->
uint
{
match
ty
::
get
(
ty
)
.st
ruct
{
match
ty
::
get
(
ty
)
.st
y
{
ty
::
ty_tup
(
fs
)
=>
fs
.len
(),
ty
::
ty_tup
(
fs
)
=>
fs
.len
(),
ty
::
ty_rec
(
fs
)
=>
fs
.len
(),
ty
::
ty_rec
(
fs
)
=>
fs
.len
(),
ty
::
ty_box
(
_
)
|
ty
::
ty_uniq
(
_
)
|
ty
::
ty_rptr
(
*
)
=>
1u
,
ty
::
ty_box
(
_
)
|
ty
::
ty_uniq
(
_
)
|
ty
::
ty_rptr
(
*
)
=>
1u
,
...
@@ -352,7 +352,7 @@ fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint,
...
@@ -352,7 +352,7 @@ fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint,
}
}
}
}
pat_rec
(
flds
,
_
)
=>
{
pat_rec
(
flds
,
_
)
=>
{
let
ty_flds
=
match
ty
::
get
(
left_ty
)
.st
ruct
{
let
ty_flds
=
match
ty
::
get
(
left_ty
)
.st
y
{
ty
::
ty_rec
(
flds
)
=>
flds
,
ty
::
ty_rec
(
flds
)
=>
flds
,
_
=>
fail
~
"bad type for pat_rec"
_
=>
fail
~
"bad type for pat_rec"
};
};
...
@@ -367,7 +367,7 @@ fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint,
...
@@ -367,7 +367,7 @@ fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint,
pat_struct
(
_
,
flds
,
_
)
=>
{
pat_struct
(
_
,
flds
,
_
)
=>
{
// Grab the class data that we care about.
// Grab the class data that we care about.
let
class_fields
,
class_id
;
let
class_fields
,
class_id
;
match
ty
::
get
(
left_ty
)
.st
ruct
{
match
ty
::
get
(
left_ty
)
.st
y
{
ty
::
ty_class
(
cid
,
_
)
=>
{
ty
::
ty_class
(
cid
,
_
)
=>
{
class_id
=
cid
;
class_id
=
cid
;
class_fields
=
ty
::
lookup_class_fields
(
tcx
,
class_id
);
class_fields
=
ty
::
lookup_class_fields
(
tcx
,
class_id
);
...
...
src/rustc/middle/const_eval.rs
浏览文件 @
27cc0a36
...
@@ -317,7 +317,7 @@ fn fromb(b: bool) -> const_val { const_int(b as i64) }
...
@@ -317,7 +317,7 @@ fn fromb(b: bool) -> const_val { const_int(b as i64) }
expr_cast
(
base
,
_
)
=>
{
expr_cast
(
base
,
_
)
=>
{
let
ety
=
ty
::
expr_ty
(
tcx
,
e
);
let
ety
=
ty
::
expr_ty
(
tcx
,
e
);
let
base
=
eval_const_expr
(
tcx
,
base
);
let
base
=
eval_const_expr
(
tcx
,
base
);
match
ty
::
get
(
ety
)
.st
ruct
{
match
ty
::
get
(
ety
)
.st
y
{
ty
::
ty_float
(
_
)
=>
{
ty
::
ty_float
(
_
)
=>
{
match
base
{
match
base
{
const_uint
(
u
)
=>
const_float
(
u
as
f64
),
const_uint
(
u
)
=>
const_float
(
u
as
f64
),
...
...
src/rustc/middle/kind.rs
浏览文件 @
27cc0a36
...
@@ -300,7 +300,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
...
@@ -300,7 +300,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
Some
(
ex
)
=>
{
Some
(
ex
)
=>
{
// All noncopyable fields must be overridden
// All noncopyable fields must be overridden
let
t
=
ty
::
expr_ty
(
cx
.tcx
,
ex
);
let
t
=
ty
::
expr_ty
(
cx
.tcx
,
ex
);
let
ty_fields
=
match
ty
::
get
(
t
)
.st
ruct
{
let
ty_fields
=
match
ty
::
get
(
t
)
.st
y
{
ty
::
ty_rec
(
f
)
=>
f
,
ty
::
ty_rec
(
f
)
=>
f
,
_
=>
cx
.tcx.sess
.span_bug
(
ex
.span
,
~
"bad expr type in record"
)
_
=>
cx
.tcx.sess
.span_bug
(
ex
.span
,
~
"bad expr type in record"
)
};
};
...
@@ -504,7 +504,7 @@ fn check_send(cx: ctx, ty: ty::t, sp: span) -> bool {
...
@@ -504,7 +504,7 @@ fn check_send(cx: ctx, ty: ty::t, sp: span) -> bool {
// note: also used from middle::typeck::regionck!
// note: also used from middle::typeck::regionck!
fn
check_owned
(
tcx
:
ty
::
ctxt
,
ty
:
ty
::
t
,
sp
:
span
)
->
bool
{
fn
check_owned
(
tcx
:
ty
::
ctxt
,
ty
:
ty
::
t
,
sp
:
span
)
->
bool
{
if
!
ty
::
kind_is_owned
(
ty
::
type_kind
(
tcx
,
ty
))
{
if
!
ty
::
kind_is_owned
(
ty
::
type_kind
(
tcx
,
ty
))
{
match
ty
::
get
(
ty
)
.st
ruct
{
match
ty
::
get
(
ty
)
.st
y
{
ty
::
ty_param
(
*
)
=>
{
ty
::
ty_param
(
*
)
=>
{
tcx
.sess
.span_err
(
sp
,
~
"value may contain borrowed
\
tcx
.sess
.span_err
(
sp
,
~
"value may contain borrowed
\
pointers; use `owned` bound"
);
pointers; use `owned` bound"
);
...
@@ -551,7 +551,7 @@ fn check_cast_for_escaping_regions(
...
@@ -551,7 +551,7 @@ fn check_cast_for_escaping_regions(
// Determine what type we are casting to; if it is not an trait, then no
// Determine what type we are casting to; if it is not an trait, then no
// worries.
// worries.
let
target_ty
=
ty
::
expr_ty
(
cx
.tcx
,
target
);
let
target_ty
=
ty
::
expr_ty
(
cx
.tcx
,
target
);
let
target_substs
=
match
ty
::
get
(
target_ty
)
.st
ruct
{
let
target_substs
=
match
ty
::
get
(
target_ty
)
.st
y
{
ty
::
ty_trait
(
_
,
substs
,
_
)
=>
{
substs
}
ty
::
ty_trait
(
_
,
substs
,
_
)
=>
{
substs
}
_
=>
{
return
;
/* not a cast to a trait */
}
_
=>
{
return
;
/* not a cast to a trait */
}
};
};
...
@@ -574,7 +574,7 @@ fn check_cast_for_escaping_regions(
...
@@ -574,7 +574,7 @@ fn check_cast_for_escaping_regions(
let
target_params
=
ty
::
param_tys_in_type
(
target_ty
);
let
target_params
=
ty
::
param_tys_in_type
(
target_ty
);
let
source_ty
=
ty
::
expr_ty
(
cx
.tcx
,
source
);
let
source_ty
=
ty
::
expr_ty
(
cx
.tcx
,
source
);
do
ty
::
walk_ty
(
source_ty
)
|
ty
|
{
do
ty
::
walk_ty
(
source_ty
)
|
ty
|
{
match
ty
::
get
(
ty
)
.st
ruct
{
match
ty
::
get
(
ty
)
.st
y
{
ty
::
ty_param
(
source_param
)
=>
{
ty
::
ty_param
(
source_param
)
=>
{
if
target_params
.contains
(
source_param
)
{
if
target_params
.contains
(
source_param
)
{
/* case (2) */
/* case (2) */
...
...
src/rustc/middle/lint.rs
浏览文件 @
27cc0a36
...
@@ -498,7 +498,7 @@ fn check_type_for_lint(cx: ty::ctxt, lint: lint,
...
@@ -498,7 +498,7 @@ fn check_type_for_lint(cx: ty::ctxt, lint: lint,
let
mut
n_box
=
0
;
let
mut
n_box
=
0
;
let
mut
n_uniq
=
0
;
let
mut
n_uniq
=
0
;
ty
::
fold_ty
(
cx
,
ty
,
|
t
|
{
ty
::
fold_ty
(
cx
,
ty
,
|
t
|
{
match
ty
::
get
(
t
)
.st
ruct
{
match
ty
::
get
(
t
)
.st
y
{
ty
::
ty_box
(
_
)
=>
n_box
+=
1
,
ty
::
ty_box
(
_
)
=>
n_box
+=
1
,
ty
::
ty_uniq
(
_
)
=>
n_uniq
+=
1
,
ty
::
ty_uniq
(
_
)
=>
n_uniq
+=
1
,
_
=>
()
_
=>
()
...
@@ -658,7 +658,7 @@ fn check_fn(tcx: ty::ctxt, fk: visit::fn_kind, decl: ast::fn_decl,
...
@@ -658,7 +658,7 @@ fn check_fn(tcx: ty::ctxt, fk: visit::fn_kind, decl: ast::fn_decl,
}
}
let
fn_ty
=
ty
::
node_id_to_type
(
tcx
,
id
);
let
fn_ty
=
ty
::
node_id_to_type
(
tcx
,
id
);
match
ty
::
get
(
fn_ty
)
.st
ruct
{
match
ty
::
get
(
fn_ty
)
.st
y
{
ty
::
ty_fn
(
fn_ty
)
=>
{
ty
::
ty_fn
(
fn_ty
)
=>
{
let
mut
counter
=
0
;
let
mut
counter
=
0
;
do
vec
::
iter2
(
fn_ty
.sig.inputs
,
decl
.inputs
)
|
arg_ty
,
arg_ast
|
{
do
vec
::
iter2
(
fn_ty
.sig.inputs
,
decl
.inputs
)
|
arg_ty
,
arg_ast
|
{
...
...
src/rustc/middle/mem_categorization.rs
浏览文件 @
27cc0a36
...
@@ -290,7 +290,7 @@ enum deref_kind {deref_ptr(ptr_kind), deref_comp(comp_kind)}
...
@@ -290,7 +290,7 @@ enum deref_kind {deref_ptr(ptr_kind), deref_comp(comp_kind)}
// derefable (we model an index as the combination of a deref and then a
// derefable (we model an index as the combination of a deref and then a
// pointer adjustment).
// pointer adjustment).
fn
opt_deref_kind
(
t
:
ty
::
t
)
->
Option
<
deref_kind
>
{
fn
opt_deref_kind
(
t
:
ty
::
t
)
->
Option
<
deref_kind
>
{
match
ty
::
get
(
t
)
.st
ruct
{
match
ty
::
get
(
t
)
.st
y
{
ty
::
ty_uniq
(
*
)
|
ty
::
ty_uniq
(
*
)
|
ty
::
ty_evec
(
_
,
ty
::
vstore_uniq
)
|
ty
::
ty_evec
(
_
,
ty
::
vstore_uniq
)
|
ty
::
ty_estr
(
ty
::
vstore_uniq
)
=>
{
ty
::
ty_estr
(
ty
::
vstore_uniq
)
=>
{
...
@@ -424,7 +424,7 @@ fn cat_borrow_of_expr(expr: @ast::expr) -> cmt {
...
@@ -424,7 +424,7 @@ fn cat_borrow_of_expr(expr: @ast::expr) -> cmt {
// Any expression can be borrowed (to account for auto-ref on method
// Any expression can be borrowed (to account for auto-ref on method
// receivers), but @, ~, @vec, and ~vec are handled specially.
// receivers), but @, ~, @vec, and ~vec are handled specially.
let
expr_ty
=
ty
::
expr_ty
(
self
.tcx
,
expr
);
let
expr_ty
=
ty
::
expr_ty
(
self
.tcx
,
expr
);
match
ty
::
get
(
expr_ty
)
.st
ruct
{
match
ty
::
get
(
expr_ty
)
.st
y
{
ty
::
ty_evec
(
*
)
|
ty
::
ty_estr
(
*
)
=>
{
ty
::
ty_evec
(
*
)
|
ty
::
ty_estr
(
*
)
=>
{
self
.cat_index
(
expr
,
expr
)
self
.cat_index
(
expr
,
expr
)
}
}
...
@@ -1013,7 +1013,7 @@ fn cmt_to_str(cmt: cmt) -> ~str {
...
@@ -1013,7 +1013,7 @@ fn cmt_to_str(cmt: cmt) -> ~str {
cat_comp
(
_
,
comp_tuple
)
=>
~
"tuple content"
,
cat_comp
(
_
,
comp_tuple
)
=>
~
"tuple content"
,
cat_comp
(
_
,
comp_variant
(
_
))
=>
~
"enum content"
,
cat_comp
(
_
,
comp_variant
(
_
))
=>
~
"enum content"
,
cat_comp
(
_
,
comp_index
(
t
,
_
))
=>
{
cat_comp
(
_
,
comp_index
(
t
,
_
))
=>
{
match
ty
::
get
(
t
)
.st
ruct
{
match
ty
::
get
(
t
)
.st
y
{
ty
::
ty_evec
(
*
)
=>
mut_str
+
~
" vec content"
,
ty
::
ty_evec
(
*
)
=>
mut_str
+
~
" vec content"
,
ty
::
ty_estr
(
*
)
=>
mut_str
+
~
" str content"
,
ty
::
ty_estr
(
*
)
=>
mut_str
+
~
" str content"
,
_
=>
mut_str
+
~
" indexed content"
_
=>
mut_str
+
~
" indexed content"
...
@@ -1034,7 +1034,7 @@ fn field_mutbl(tcx: ty::ctxt,
...
@@ -1034,7 +1034,7 @@ fn field_mutbl(tcx: ty::ctxt,
base_ty
:
ty
::
t
,
base_ty
:
ty
::
t
,
f_name
:
ast
::
ident
)
->
Option
<
ast
::
mutability
>
{
f_name
:
ast
::
ident
)
->
Option
<
ast
::
mutability
>
{
// Need to refactor so that records/class fields can be treated uniformly.
// Need to refactor so that records/class fields can be treated uniformly.
match
ty
::
get
(
base_ty
)
.st
ruct
{
match
ty
::
get
(
base_ty
)
.st
y
{
ty
::
ty_rec
(
fields
)
=>
{
ty
::
ty_rec
(
fields
)
=>
{
for
fields
.each
|
f
|
{
for
fields
.each
|
f
|
{
if
f
.ident
==
f_name
{
if
f
.ident
==
f_name
{
...
...
src/rustc/middle/privacy.rs
浏览文件 @
27cc0a36
...
@@ -154,7 +154,7 @@ fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) {
...
@@ -154,7 +154,7 @@ fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) {
visit_expr
:
|
expr
,
method_map
:
&
method_map
,
visitor
|
{
visit_expr
:
|
expr
,
method_map
:
&
method_map
,
visitor
|
{
match
expr
.node
{
match
expr
.node
{
expr_field
(
base
,
ident
,
_
)
=>
{
expr_field
(
base
,
ident
,
_
)
=>
{
match
ty
::
get
(
ty
::
expr_ty
(
tcx
,
base
))
.st
ruct
{
match
ty
::
get
(
ty
::
expr_ty
(
tcx
,
base
))
.st
y
{
ty_class
(
id
,
_
)
ty_class
(
id
,
_
)
if
id
.crate
!=
local_crate
||
if
id
.crate
!=
local_crate
||
!
privileged_items
.contains
(
id
.node
)
=>
{
!
privileged_items
.contains
(
id
.node
)
=>
{
...
@@ -175,7 +175,7 @@ fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) {
...
@@ -175,7 +175,7 @@ fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) {
}
}
}
}
expr_struct
(
_
,
fields
,
_
)
=>
{
expr_struct
(
_
,
fields
,
_
)
=>
{
match
ty
::
get
(
ty
::
expr_ty
(
tcx
,
expr
))
.st
ruct
{
match
ty
::
get
(
ty
::
expr_ty
(
tcx
,
expr
))
.st
y
{
ty_class
(
id
,
_
)
=>
{
ty_class
(
id
,
_
)
=>
{
if
id
.crate
!=
local_crate
||
if
id
.crate
!=
local_crate
||
!
privileged_items
.contains
(
id
.node
)
{
!
privileged_items
.contains
(
id
.node
)
{
...
@@ -202,7 +202,7 @@ fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) {
...
@@ -202,7 +202,7 @@ fn check_crate(tcx: ty::ctxt, method_map: &method_map, crate: @ast::crate) {
visit_pat
:
|
pattern
,
method_map
,
visitor
|
{
visit_pat
:
|
pattern
,
method_map
,
visitor
|
{
match
pattern
.node
{
match
pattern
.node
{
pat_struct
(
_
,
fields
,
_
)
=>
{
pat_struct
(
_
,
fields
,
_
)
=>
{
match
ty
::
get
(
ty
::
pat_ty
(
tcx
,
pattern
))
.st
ruct
{
match
ty
::
get
(
ty
::
pat_ty
(
tcx
,
pattern
))
.st
y
{
ty_class
(
id
,
_
)
=>
{
ty_class
(
id
,
_
)
=>
{
if
id
.crate
!=
local_crate
||
if
id
.crate
!=
local_crate
||
!
privileged_items
.contains
(
id
.node
)
{
!
privileged_items
.contains
(
id
.node
)
{
...
...
src/rustc/middle/trans/alt.rs
浏览文件 @
27cc0a36
...
@@ -293,8 +293,7 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id,
...
@@ -293,8 +293,7 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id,
{
vals
:
~
[
ValueRef
],
bcx
:
block
}
{
{
vals
:
~
[
ValueRef
],
bcx
:
block
}
{
let
_
icx
=
bcx
.insn_ctxt
(
"alt::extract_variant_args"
);
let
_
icx
=
bcx
.insn_ctxt
(
"alt::extract_variant_args"
);
let
ccx
=
bcx
.fcx.ccx
;
let
ccx
=
bcx
.fcx.ccx
;
let
enum_ty_substs
=
match
ty
::
get
(
node_id_type
(
bcx
,
pat_id
))
let
enum_ty_substs
=
match
ty
::
get
(
node_id_type
(
bcx
,
pat_id
))
.sty
{
.struct
{
ty
::
ty_enum
(
id
,
substs
)
=>
{
assert
id
==
vdefs
.enm
;
substs
.tps
}
ty
::
ty_enum
(
id
,
substs
)
=>
{
assert
id
==
vdefs
.enm
;
substs
.tps
}
_
=>
bcx
.sess
()
.bug
(
~
"extract_variant_args: pattern has non-enum type"
)
_
=>
bcx
.sess
()
.bug
(
~
"extract_variant_args: pattern has non-enum type"
)
};
};
...
@@ -436,7 +435,7 @@ fn compare_values(cx: block, lhs: ValueRef, rhs: ValueRef, rhs_t: ty::t) ->
...
@@ -436,7 +435,7 @@ fn compare_values(cx: block, lhs: ValueRef, rhs: ValueRef, rhs_t: ty::t) ->
return
rslt
(
rs
.bcx
,
rs
.val
);
return
rslt
(
rs
.bcx
,
rs
.val
);
}
}
match
ty
::
get
(
rhs_t
)
.st
ruct
{
match
ty
::
get
(
rhs_t
)
.st
y
{
ty
::
ty_estr
(
ty
::
vstore_uniq
)
=>
{
ty
::
ty_estr
(
ty
::
vstore_uniq
)
=>
{
let
scratch_result
=
scratch_datum
(
cx
,
ty
::
mk_bool
(
cx
.tcx
()),
let
scratch_result
=
scratch_datum
(
cx
,
ty
::
mk_bool
(
cx
.tcx
()),
false
);
false
);
...
@@ -559,7 +558,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
...
@@ -559,7 +558,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
if
any_tup_pat
(
m
,
col
)
{
if
any_tup_pat
(
m
,
col
)
{
let
tup_ty
=
node_id_type
(
bcx
,
pat_id
);
let
tup_ty
=
node_id_type
(
bcx
,
pat_id
);
let
n_tup_elts
=
match
ty
::
get
(
tup_ty
)
.st
ruct
{
let
n_tup_elts
=
match
ty
::
get
(
tup_ty
)
.st
y
{
ty
::
ty_tup
(
elts
)
=>
elts
.len
(),
ty
::
ty_tup
(
elts
)
=>
elts
.len
(),
_
=>
ccx
.sess
.bug
(
~
"non-tuple type in tuple pattern"
)
_
=>
ccx
.sess
.bug
(
~
"non-tuple type in tuple pattern"
)
};
};
...
...
src/rustc/middle/trans/base.rs
浏览文件 @
27cc0a36
...
@@ -422,7 +422,7 @@ fn compare_scalar_types(cx: block, lhs: ValueRef, rhs: ValueRef,
...
@@ -422,7 +422,7 @@ fn compare_scalar_types(cx: block, lhs: ValueRef, rhs: ValueRef,
t
:
ty
::
t
,
op
:
ast
::
binop
)
->
Result
{
t
:
ty
::
t
,
op
:
ast
::
binop
)
->
Result
{
let
f
=
|
a
|
compare_scalar_values
(
cx
,
lhs
,
rhs
,
a
,
op
);
let
f
=
|
a
|
compare_scalar_values
(
cx
,
lhs
,
rhs
,
a
,
op
);
match
ty
::
get
(
t
)
.st
ruct
{
match
ty
::
get
(
t
)
.st
y
{
ty
::
ty_nil
=>
rslt
(
cx
,
f
(
nil_type
)),
ty
::
ty_nil
=>
rslt
(
cx
,
f
(
nil_type
)),
ty
::
ty_bool
|
ty
::
ty_ptr
(
_
)
=>
rslt
(
cx
,
f
(
unsigned_int
)),
ty
::
ty_bool
|
ty
::
ty_ptr
(
_
)
=>
rslt
(
cx
,
f
(
unsigned_int
)),
ty
::
ty_int
(
_
)
=>
rslt
(
cx
,
f
(
signed_int
)),
ty
::
ty_int
(
_
)
=>
rslt
(
cx
,
f
(
signed_int
)),
...
@@ -528,7 +528,7 @@ fn iter_variant(cx: block, a_tup: ValueRef,
...
@@ -528,7 +528,7 @@ fn iter_variant(cx: block, a_tup: ValueRef,
let
fn_ty
=
variant
.ctor_ty
;
let
fn_ty
=
variant
.ctor_ty
;
let
ccx
=
cx
.ccx
();
let
ccx
=
cx
.ccx
();
let
mut
cx
=
cx
;
let
mut
cx
=
cx
;
match
ty
::
get
(
fn_ty
)
.st
ruct
{
match
ty
::
get
(
fn_ty
)
.st
y
{
ty
::
ty_fn
(
ref
fn_ty
)
=>
{
ty
::
ty_fn
(
ref
fn_ty
)
=>
{
let
mut
j
=
0u
;
let
mut
j
=
0u
;
let
v_id
=
variant
.id
;
let
v_id
=
variant
.id
;
...
@@ -548,7 +548,7 @@ fn iter_variant(cx: block, a_tup: ValueRef,
...
@@ -548,7 +548,7 @@ fn iter_variant(cx: block, a_tup: ValueRef,
Typestate constraint that shows the unimpl case doesn't happen?
Typestate constraint that shows the unimpl case doesn't happen?
*/
*/
let
mut
cx
=
cx
;
let
mut
cx
=
cx
;
match
ty
::
get
(
t
)
.st
ruct
{
match
ty
::
get
(
t
)
.st
y
{
ty
::
ty_rec
(
*
)
|
ty
::
ty_class
(
*
)
=>
{
ty
::
ty_rec
(
*
)
|
ty
::
ty_class
(
*
)
=>
{
do
expr
::
with_field_tys
(
cx
.tcx
(),
t
)
|
_
has_dtor
,
field_tys
|
{
do
expr
::
with_field_tys
(
cx
.tcx
(),
t
)
|
_
has_dtor
,
field_tys
|
{
for
vec
::
eachi
(
field_tys
)
|
i
,
field_ty
|
{
for
vec
::
eachi
(
field_tys
)
|
i
,
field_ty
|
{
...
@@ -655,7 +655,7 @@ fn fail_if_zero(cx: block, span: span, divmod: ast::binop,
...
@@ -655,7 +655,7 @@ fn fail_if_zero(cx: block, span: span, divmod: ast::binop,
}
else
{
}
else
{
~
"modulo zero"
~
"modulo zero"
};
};
let
is_zero
=
match
ty
::
get
(
rhs_t
)
.st
ruct
{
let
is_zero
=
match
ty
::
get
(
rhs_t
)
.st
y
{
ty
::
ty_int
(
t
)
=>
{
ty
::
ty_int
(
t
)
=>
{
let
zero
=
C_integral
(
T_int_ty
(
cx
.ccx
(),
t
),
0u64
,
False
);
let
zero
=
C_integral
(
T_int_ty
(
cx
.ccx
(),
t
),
0u64
,
False
);
ICmp
(
cx
,
lib
::
llvm
::
IntEQ
,
rhs
,
zero
)
ICmp
(
cx
,
lib
::
llvm
::
IntEQ
,
rhs
,
zero
)
...
@@ -681,7 +681,7 @@ fn null_env_ptr(bcx: block) -> ValueRef {
...
@@ -681,7 +681,7 @@ fn null_env_ptr(bcx: block) -> ValueRef {
fn
trans_external_path
(
ccx
:
@
crate_ctxt
,
did
:
ast
::
def_id
,
t
:
ty
::
t
)
fn
trans_external_path
(
ccx
:
@
crate_ctxt
,
did
:
ast
::
def_id
,
t
:
ty
::
t
)
->
ValueRef
{
->
ValueRef
{
let
name
=
csearch
::
get_symbol
(
ccx
.sess.cstore
,
did
);
let
name
=
csearch
::
get_symbol
(
ccx
.sess.cstore
,
did
);
match
ty
::
get
(
t
)
.st
ruct
{
match
ty
::
get
(
t
)
.st
y
{
ty
::
ty_fn
(
_
)
=>
{
ty
::
ty_fn
(
_
)
=>
{
let
llty
=
type_of_fn_from_ty
(
ccx
,
t
);
let
llty
=
type_of_fn_from_ty
(
ccx
,
t
);
return
get_extern_fn
(
ccx
.externs
,
ccx
.llmod
,
name
,
return
get_extern_fn
(
ccx
.externs
,
ccx
.llmod
,
name
,
...
@@ -1956,7 +1956,7 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
...
@@ -1956,7 +1956,7 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
let
main_takes_argv
=
let
main_takes_argv
=
// invariant!
// invariant!
match
ty
::
get
(
main_node_type
)
.st
ruct
{
match
ty
::
get
(
main_node_type
)
.st
y
{
ty
::
ty_fn
(
ref
fn_ty
)
=>
fn_ty
.sig.inputs
.len
()
!=
0u
,
ty
::
ty_fn
(
ref
fn_ty
)
=>
fn_ty
.sig.inputs
.len
()
!=
0u
,
_
=>
ccx
.sess
.span_fatal
(
sp
,
~
"main has a non-function type"
)
_
=>
ccx
.sess
.span_fatal
(
sp
,
~
"main has a non-function type"
)
};
};
...
...
src/rustc/middle/trans/callee.rs
浏览文件 @
27cc0a36
...
@@ -620,7 +620,7 @@ fn adapt_borrowed_value(bcx: block,
...
@@ -620,7 +620,7 @@ fn adapt_borrowed_value(bcx: block,
datum
.to_str
(
bcx
.ccx
()),
datum
.to_str
(
bcx
.ccx
()),
bcx
.expr_to_str
(
expr
));
bcx
.expr_to_str
(
expr
));
match
ty
::
get
(
datum
.ty
)
.st
ruct
{
match
ty
::
get
(
datum
.ty
)
.st
y
{
ty
::
ty_uniq
(
_
)
|
ty
::
ty_box
(
_
)
=>
{
ty
::
ty_uniq
(
_
)
|
ty
::
ty_box
(
_
)
=>
{
let
body_datum
=
datum
.box_body
(
bcx
);
let
body_datum
=
datum
.box_body
(
bcx
);
let
rptr_datum
=
body_datum
.to_rptr
(
bcx
);
let
rptr_datum
=
body_datum
.to_rptr
(
bcx
);
...
...
src/rustc/middle/trans/consts.rs
浏览文件 @
27cc0a36
...
@@ -10,7 +10,7 @@ fn const_lit(cx: @crate_ctxt, e: @ast::expr, lit: ast::lit)
...
@@ -10,7 +10,7 @@ fn const_lit(cx: @crate_ctxt, e: @ast::expr, lit: ast::lit)
ast
::
lit_uint
(
u
,
t
)
=>
C_integral
(
T_uint_ty
(
cx
,
t
),
u
,
False
),
ast
::
lit_uint
(
u
,
t
)
=>
C_integral
(
T_uint_ty
(
cx
,
t
),
u
,
False
),
ast
::
lit_int_unsuffixed
(
i
)
=>
{
ast
::
lit_int_unsuffixed
(
i
)
=>
{
let
lit_int_ty
=
ty
::
node_id_to_type
(
cx
.tcx
,
e
.id
);
let
lit_int_ty
=
ty
::
node_id_to_type
(
cx
.tcx
,
e
.id
);
match
ty
::
get
(
lit_int_ty
)
.st
ruct
{
match
ty
::
get
(
lit_int_ty
)
.st
y
{
ty
::
ty_int
(
t
)
=>
{
ty
::
ty_int
(
t
)
=>
{
C_integral
(
T_int_ty
(
cx
,
t
),
i
as
u64
,
True
)
C_integral
(
T_int_ty
(
cx
,
t
),
i
as
u64
,
True
)
}
}
...
@@ -76,7 +76,7 @@ fn const_autoderef(cx: @crate_ctxt, ty: ty::t, v: ValueRef)
...
@@ -76,7 +76,7 @@ fn const_autoderef(cx: @crate_ctxt, ty: ty::t, v: ValueRef)
let
mut
v1
=
v
;
let
mut
v1
=
v
;
loop
{
loop
{
// Only rptrs can be autoderef'ed in a const context.
// Only rptrs can be autoderef'ed in a const context.
match
ty
::
get
(
ty
)
.st
ruct
{
match
ty
::
get
(
ty
)
.st
y
{
ty
::
ty_rptr
(
_
,
mt
)
=>
{
ty
::
ty_rptr
(
_
,
mt
)
=>
{
t1
=
mt
.ty
;
t1
=
mt
.ty
;
v1
=
const_deref
(
cx
,
v1
);
v1
=
const_deref
(
cx
,
v1
);
...
@@ -184,7 +184,7 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
...
@@ -184,7 +184,7 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
~
"index is not an integer-constant
\
~
"index is not an integer-constant
\
expression"
)
expression"
)
};
};
let
(
arr
,
_
len
)
=
match
ty
::
get
(
bt
)
.st
ruct
{
let
(
arr
,
_
len
)
=
match
ty
::
get
(
bt
)
.st
y
{
ty
::
ty_evec
(
_
,
vstore
)
|
ty
::
ty_estr
(
vstore
)
=>
ty
::
ty_evec
(
_
,
vstore
)
|
ty
::
ty_estr
(
vstore
)
=>
match
vstore
{
match
vstore
{
ty
::
vstore_fixed
(
u
)
=>
ty
::
vstore_fixed
(
u
)
=>
...
@@ -236,7 +236,7 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
...
@@ -236,7 +236,7 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
// we can get the value (as a number) out of.
// we can get the value (as a number) out of.
let
len
=
llvm
::
LLVMGetArrayLength
(
val_ty
(
arr
))
as
u64
;
let
len
=
llvm
::
LLVMGetArrayLength
(
val_ty
(
arr
))
as
u64
;
let
len
=
match
ty
::
get
(
bt
)
.st
ruct
{
let
len
=
match
ty
::
get
(
bt
)
.st
y
{
ty
::
ty_estr
(
*
)
=>
{
assert
len
>
0
;
len
-
1
},
ty
::
ty_estr
(
*
)
=>
{
assert
len
>
0
;
len
-
1
},
_
=>
len
_
=>
len
};
};
...
...
src/rustc/middle/trans/datum.rs
浏览文件 @
27cc0a36
...
@@ -528,7 +528,7 @@ fn box_body(bcx: block) -> Datum {
...
@@ -528,7 +528,7 @@ fn box_body(bcx: block) -> Datum {
* This datum must represent an @T or ~T box. Returns a new
* This datum must represent an @T or ~T box. Returns a new
* by-ref datum of type T, pointing at the contents. */
* by-ref datum of type T, pointing at the contents. */
let
content_ty
=
match
ty
::
get
(
self
.ty
)
.st
ruct
{
let
content_ty
=
match
ty
::
get
(
self
.ty
)
.st
y
{
ty
::
ty_box
(
mt
)
|
ty
::
ty_uniq
(
mt
)
=>
mt
.ty
,
ty
::
ty_box
(
mt
)
|
ty
::
ty_uniq
(
mt
)
=>
mt
.ty
,
_
=>
{
_
=>
{
bcx
.tcx
()
.sess
.bug
(
fmt!
(
bcx
.tcx
()
.sess
.bug
(
fmt!
(
...
@@ -583,7 +583,7 @@ fn try_deref(
...
@@ -583,7 +583,7 @@ fn try_deref(
}
}
}
}
match
ty
::
get
(
self
.ty
)
.st
ruct
{
match
ty
::
get
(
self
.ty
)
.st
y
{
ty
::
ty_box
(
_
)
|
ty
::
ty_uniq
(
_
)
=>
{
ty
::
ty_box
(
_
)
|
ty
::
ty_uniq
(
_
)
=>
{
return
Some
(
self
.box_body
(
bcx
));
return
Some
(
self
.box_body
(
bcx
));
}
}
...
...
src/rustc/middle/trans/expr.rs
浏览文件 @
27cc0a36
...
@@ -447,7 +447,7 @@ fn ast_proto_to_proto_simple(ast_proto: ast::proto)
...
@@ -447,7 +447,7 @@ fn ast_proto_to_proto_simple(ast_proto: ast::proto)
}
}
ast
::
expr_fn_block
(
decl
,
body
,
cap_clause
)
=>
{
ast
::
expr_fn_block
(
decl
,
body
,
cap_clause
)
=>
{
let
expr_ty
=
expr_ty
(
bcx
,
expr
);
let
expr_ty
=
expr_ty
(
bcx
,
expr
);
match
ty
::
get
(
expr_ty
)
.st
ruct
{
match
ty
::
get
(
expr_ty
)
.st
y
{
ty
::
ty_fn
(
ref
fn_ty
)
=>
{
ty
::
ty_fn
(
ref
fn_ty
)
=>
{
debug!
(
"translating fn_block %s with type %s"
,
debug!
(
"translating fn_block %s with type %s"
,
expr_to_str
(
expr
,
tcx
.sess
.intr
()),
expr_to_str
(
expr
,
tcx
.sess
.intr
()),
...
@@ -464,7 +464,7 @@ fn ast_proto_to_proto_simple(ast_proto: ast::proto)
...
@@ -464,7 +464,7 @@ fn ast_proto_to_proto_simple(ast_proto: ast::proto)
}
}
}
}
ast
::
expr_loop_body
(
blk
)
=>
{
ast
::
expr_loop_body
(
blk
)
=>
{
match
ty
::
get
(
expr_ty
(
bcx
,
expr
))
.st
ruct
{
match
ty
::
get
(
expr_ty
(
bcx
,
expr
))
.st
y
{
ty
::
ty_fn
(
ref
fn_ty
)
=>
{
ty
::
ty_fn
(
ref
fn_ty
)
=>
{
match
blk
.node
{
match
blk
.node
{
ast
::
expr_fn_block
(
decl
,
body
,
cap
)
=>
{
ast
::
expr_fn_block
(
decl
,
body
,
cap
)
=>
{
...
@@ -774,7 +774,7 @@ fn fn_data_to_datum(bcx: block,
...
@@ -774,7 +774,7 @@ fn fn_data_to_datum(bcx: block,
fn
with_field_tys
<
R
>
(
tcx
:
ty
::
ctxt
,
ty
:
ty
::
t
,
fn
with_field_tys
<
R
>
(
tcx
:
ty
::
ctxt
,
ty
:
ty
::
t
,
op
:
fn
(
bool
,
(
&
[
ty
::
field
]))
->
R
)
->
R
{
op
:
fn
(
bool
,
(
&
[
ty
::
field
]))
->
R
)
->
R
{
match
ty
::
get
(
ty
)
.st
ruct
{
match
ty
::
get
(
ty
)
.st
y
{
ty
::
ty_rec
(
ref
fields
)
=>
{
ty
::
ty_rec
(
ref
fields
)
=>
{
op
(
false
,
*
fields
)
op
(
false
,
*
fields
)
}
}
...
@@ -1279,7 +1279,7 @@ impl cast_kind : cmp::Eq {
...
@@ -1279,7 +1279,7 @@ impl cast_kind : cmp::Eq {
}
}
fn
cast_type_kind
(
t
:
ty
::
t
)
->
cast_kind
{
fn
cast_type_kind
(
t
:
ty
::
t
)
->
cast_kind
{
match
ty
::
get
(
t
)
.st
ruct
{
match
ty
::
get
(
t
)
.st
y
{
ty
::
ty_float
(
*
)
=>
cast_float
,
ty
::
ty_float
(
*
)
=>
cast_float
,
ty
::
ty_ptr
(
*
)
=>
cast_pointer
,
ty
::
ty_ptr
(
*
)
=>
cast_pointer
,
ty
::
ty_rptr
(
*
)
=>
cast_pointer
,
ty
::
ty_rptr
(
*
)
=>
cast_pointer
,
...
...
src/rustc/middle/trans/foreign.rs
浏览文件 @
27cc0a36
...
@@ -440,7 +440,7 @@ fn link_name(ccx: @crate_ctxt, i: @ast::foreign_item) -> ~str {
...
@@ -440,7 +440,7 @@ fn link_name(ccx: @crate_ctxt, i: @ast::foreign_item) -> ~str {
fn
c_arg_and_ret_lltys
(
ccx
:
@
crate_ctxt
,
fn
c_arg_and_ret_lltys
(
ccx
:
@
crate_ctxt
,
id
:
ast
::
node_id
)
->
(
~
[
TypeRef
],
TypeRef
,
ty
::
t
)
{
id
:
ast
::
node_id
)
->
(
~
[
TypeRef
],
TypeRef
,
ty
::
t
)
{
match
ty
::
get
(
ty
::
node_id_to_type
(
ccx
.tcx
,
id
))
.st
ruct
{
match
ty
::
get
(
ty
::
node_id_to_type
(
ccx
.tcx
,
id
))
.st
y
{
ty
::
ty_fn
(
ref
fn_ty
)
=>
{
ty
::
ty_fn
(
ref
fn_ty
)
=>
{
let
llargtys
=
type_of_explicit_args
(
ccx
,
fn_ty
.sig.inputs
);
let
llargtys
=
type_of_explicit_args
(
ccx
,
fn_ty
.sig.inputs
);
let
llretty
=
type_of
::
type_of
(
ccx
,
fn_ty
.sig.output
);
let
llretty
=
type_of
::
type_of
(
ccx
,
fn_ty
.sig.output
);
...
...
src/rustc/middle/trans/glue.rs
浏览文件 @
27cc0a36
...
@@ -51,7 +51,7 @@ fn drop_ty_root(bcx: block, v: ValueRef, rooted: bool, t: ty::t) -> block {
...
@@ -51,7 +51,7 @@ fn drop_ty_root(bcx: block, v: ValueRef, rooted: bool, t: ty::t) -> block {
fn
drop_ty_immediate
(
bcx
:
block
,
v
:
ValueRef
,
t
:
ty
::
t
)
->
block
{
fn
drop_ty_immediate
(
bcx
:
block
,
v
:
ValueRef
,
t
:
ty
::
t
)
->
block
{
let
_
icx
=
bcx
.insn_ctxt
(
"drop_ty_immediate"
);
let
_
icx
=
bcx
.insn_ctxt
(
"drop_ty_immediate"
);
match
ty
::
get
(
t
)
.st
ruct
{
match
ty
::
get
(
t
)
.st
y
{
ty
::
ty_uniq
(
_
)
|
ty
::
ty_uniq
(
_
)
|
ty
::
ty_evec
(
_
,
ty
::
vstore_uniq
)
|
ty
::
ty_evec
(
_
,
ty
::
vstore_uniq
)
|
ty
::
ty_estr
(
ty
::
vstore_uniq
)
=>
{
ty
::
ty_estr
(
ty
::
vstore_uniq
)
=>
{
...
@@ -68,7 +68,7 @@ fn drop_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> block {
...
@@ -68,7 +68,7 @@ fn drop_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> block {
fn
take_ty_immediate
(
bcx
:
block
,
v
:
ValueRef
,
t
:
ty
::
t
)
->
Result
{
fn
take_ty_immediate
(
bcx
:
block
,
v
:
ValueRef
,
t
:
ty
::
t
)
->
Result
{
let
_
icx
=
bcx
.insn_ctxt
(
"take_ty_immediate"
);
let
_
icx
=
bcx
.insn_ctxt
(
"take_ty_immediate"
);
match
ty
::
get
(
t
)
.st
ruct
{
match
ty
::
get
(
t
)
.st
y
{
ty
::
ty_box
(
_
)
|
ty
::
ty_opaque_box
|
ty
::
ty_box
(
_
)
|
ty
::
ty_opaque_box
|
ty
::
ty_evec
(
_
,
ty
::
vstore_box
)
|
ty
::
ty_evec
(
_
,
ty
::
vstore_box
)
|
ty
::
ty_estr
(
ty
::
vstore_box
)
=>
{
ty
::
ty_estr
(
ty
::
vstore_box
)
=>
{
...
@@ -97,7 +97,7 @@ fn free_ty(cx: block, v: ValueRef, t: ty::t) -> block {
...
@@ -97,7 +97,7 @@ fn free_ty(cx: block, v: ValueRef, t: ty::t) -> block {
fn
free_ty_immediate
(
bcx
:
block
,
v
:
ValueRef
,
t
:
ty
::
t
)
->
block
{
fn
free_ty_immediate
(
bcx
:
block
,
v
:
ValueRef
,
t
:
ty
::
t
)
->
block
{
let
_
icx
=
bcx
.insn_ctxt
(
"free_ty_immediate"
);
let
_
icx
=
bcx
.insn_ctxt
(
"free_ty_immediate"
);
match
ty
::
get
(
t
)
.st
ruct
{
match
ty
::
get
(
t
)
.st
y
{
ty
::
ty_uniq
(
_
)
|
ty
::
ty_uniq
(
_
)
|
ty
::
ty_evec
(
_
,
ty
::
vstore_uniq
)
|
ty
::
ty_evec
(
_
,
ty
::
vstore_uniq
)
|
ty
::
ty_estr
(
ty
::
vstore_uniq
)
|
ty
::
ty_estr
(
ty
::
vstore_uniq
)
|
...
@@ -268,7 +268,7 @@ fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) {
...
@@ -268,7 +268,7 @@ fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) {
// NB: v0 is an *alias* of type t here, not a direct value.
// NB: v0 is an *alias* of type t here, not a direct value.
let
_
icx
=
bcx
.insn_ctxt
(
"make_free_glue"
);
let
_
icx
=
bcx
.insn_ctxt
(
"make_free_glue"
);
let
ccx
=
bcx
.ccx
();
let
ccx
=
bcx
.ccx
();
let
bcx
=
match
ty
::
get
(
t
)
.st
ruct
{
let
bcx
=
match
ty
::
get
(
t
)
.st
y
{
ty
::
ty_box
(
body_mt
)
=>
{
ty
::
ty_box
(
body_mt
)
=>
{
let
v
=
Load
(
bcx
,
v
);
let
v
=
Load
(
bcx
,
v
);
let
body
=
GEPi
(
bcx
,
v
,
[
0u
,
abi
::
box_field_body
]);
let
body
=
GEPi
(
bcx
,
v
,
[
0u
,
abi
::
box_field_body
]);
...
@@ -357,7 +357,7 @@ fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) {
...
@@ -357,7 +357,7 @@ fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) {
// NB: v0 is an *alias* of type t here, not a direct value.
// NB: v0 is an *alias* of type t here, not a direct value.
let
_
icx
=
bcx
.insn_ctxt
(
"make_drop_glue"
);
let
_
icx
=
bcx
.insn_ctxt
(
"make_drop_glue"
);
let
ccx
=
bcx
.ccx
();
let
ccx
=
bcx
.ccx
();
let
bcx
=
match
ty
::
get
(
t
)
.st
ruct
{
let
bcx
=
match
ty
::
get
(
t
)
.st
y
{
ty
::
ty_box
(
_
)
|
ty
::
ty_opaque_box
|
ty
::
ty_box
(
_
)
|
ty
::
ty_opaque_box
|
ty
::
ty_estr
(
ty
::
vstore_box
)
|
ty
::
ty_evec
(
_
,
ty
::
vstore_box
)
=>
{
ty
::
ty_estr
(
ty
::
vstore_box
)
|
ty
::
ty_evec
(
_
,
ty
::
vstore_box
)
=>
{
decr_refcnt_maybe_free
(
bcx
,
Load
(
bcx
,
v0
),
t
)
decr_refcnt_maybe_free
(
bcx
,
Load
(
bcx
,
v0
),
t
)
...
@@ -418,7 +418,7 @@ fn decr_refcnt_maybe_free(bcx: block, box_ptr: ValueRef, t: ty::t) -> block {
...
@@ -418,7 +418,7 @@ fn decr_refcnt_maybe_free(bcx: block, box_ptr: ValueRef, t: ty::t) -> block {
fn
make_take_glue
(
bcx
:
block
,
v
:
ValueRef
,
t
:
ty
::
t
)
{
fn
make_take_glue
(
bcx
:
block
,
v
:
ValueRef
,
t
:
ty
::
t
)
{
let
_
icx
=
bcx
.insn_ctxt
(
"make_take_glue"
);
let
_
icx
=
bcx
.insn_ctxt
(
"make_take_glue"
);
// NB: v is a *pointer* to type t here, not a direct value.
// NB: v is a *pointer* to type t here, not a direct value.
let
bcx
=
match
ty
::
get
(
t
)
.st
ruct
{
let
bcx
=
match
ty
::
get
(
t
)
.st
y
{
ty
::
ty_box
(
_
)
|
ty
::
ty_opaque_box
|
ty
::
ty_box
(
_
)
|
ty
::
ty_opaque_box
|
ty
::
ty_evec
(
_
,
ty
::
vstore_box
)
|
ty
::
ty_estr
(
ty
::
vstore_box
)
=>
{
ty
::
ty_evec
(
_
,
ty
::
vstore_box
)
|
ty
::
ty_estr
(
ty
::
vstore_box
)
=>
{
incr_refcnt_of_boxed
(
bcx
,
Load
(
bcx
,
v
));
bcx
incr_refcnt_of_boxed
(
bcx
,
Load
(
bcx
,
v
));
bcx
...
...
src/rustc/middle/trans/monomorphize.rs
浏览文件 @
27cc0a36
...
@@ -198,7 +198,7 @@ fn monomorphic_fn(ccx: @crate_ctxt,
...
@@ -198,7 +198,7 @@ fn monomorphic_fn(ccx: @crate_ctxt,
fn
normalize_for_monomorphization
(
tcx
:
ty
::
ctxt
,
ty
:
ty
::
t
)
->
Option
<
ty
::
t
>
{
fn
normalize_for_monomorphization
(
tcx
:
ty
::
ctxt
,
ty
:
ty
::
t
)
->
Option
<
ty
::
t
>
{
// FIXME[mono] could do this recursively. is that worthwhile? (#2529)
// FIXME[mono] could do this recursively. is that worthwhile? (#2529)
match
ty
::
get
(
ty
)
.st
ruct
{
match
ty
::
get
(
ty
)
.st
y
{
ty
::
ty_box
(
*
)
=>
{
ty
::
ty_box
(
*
)
=>
{
Some
(
ty
::
mk_opaque_box
(
tcx
))
Some
(
ty
::
mk_opaque_box
(
tcx
))
}
}
...
...
src/rustc/middle/trans/reflect.rs
浏览文件 @
27cc0a36
...
@@ -114,7 +114,7 @@ fn visit_ty(t: ty::t) {
...
@@ -114,7 +114,7 @@ fn visit_ty(t: ty::t) {
debug!
(
"reflect::visit_ty %s"
,
debug!
(
"reflect::visit_ty %s"
,
ty_to_str
(
bcx
.ccx
()
.tcx
,
t
));
ty_to_str
(
bcx
.ccx
()
.tcx
,
t
));
match
ty
::
get
(
t
)
.st
ruct
{
match
ty
::
get
(
t
)
.st
y
{
ty
::
ty_bot
=>
self
.leaf
(
~
"bot"
),
ty
::
ty_bot
=>
self
.leaf
(
~
"bot"
),
ty
::
ty_nil
=>
self
.leaf
(
~
"nil"
),
ty
::
ty_nil
=>
self
.leaf
(
~
"nil"
),
ty
::
ty_bool
=>
self
.leaf
(
~
"bool"
),
ty
::
ty_bool
=>
self
.leaf
(
~
"bool"
),
...
...
src/rustc/middle/trans/shape.rs
浏览文件 @
27cc0a36
...
@@ -215,7 +215,7 @@ fn add_substr(&dest: ~[u8], src: ~[u8]) {
...
@@ -215,7 +215,7 @@ fn add_substr(&dest: ~[u8], src: ~[u8]) {
}
}
fn
shape_of
(
ccx
:
@
crate_ctxt
,
t
:
ty
::
t
)
->
~
[
u8
]
{
fn
shape_of
(
ccx
:
@
crate_ctxt
,
t
:
ty
::
t
)
->
~
[
u8
]
{
match
ty
::
get
(
t
)
.st
ruct
{
match
ty
::
get
(
t
)
.st
y
{
ty
::
ty_nil
|
ty
::
ty_bool
|
ty
::
ty_uint
(
ast
::
ty_u8
)
|
ty
::
ty_nil
|
ty
::
ty_bool
|
ty
::
ty_uint
(
ast
::
ty_u8
)
|
ty
::
ty_bot
=>
~
[
shape_u8
],
ty
::
ty_bot
=>
~
[
shape_u8
],
ty
::
ty_int
(
ast
::
ty_i
)
=>
~
[
s_int
(
ccx
.tcx
)],
ty
::
ty_int
(
ast
::
ty_i
)
=>
~
[
s_int
(
ccx
.tcx
)],
...
@@ -719,7 +719,7 @@ fn llalign_of(cx: @crate_ctxt, t: TypeRef) -> ValueRef {
...
@@ -719,7 +719,7 @@ fn llalign_of(cx: @crate_ctxt, t: TypeRef) -> ValueRef {
// Computes the size of the data part of an enum.
// Computes the size of the data part of an enum.
fn
static_size_of_enum
(
cx
:
@
crate_ctxt
,
t
:
ty
::
t
)
->
uint
{
fn
static_size_of_enum
(
cx
:
@
crate_ctxt
,
t
:
ty
::
t
)
->
uint
{
if
cx
.enum_sizes
.contains_key
(
t
)
{
return
cx
.enum_sizes
.get
(
t
);
}
if
cx
.enum_sizes
.contains_key
(
t
)
{
return
cx
.enum_sizes
.get
(
t
);
}
match
ty
::
get
(
t
)
.st
ruct
{
match
ty
::
get
(
t
)
.st
y
{
ty
::
ty_enum
(
tid
,
ref
substs
)
=>
{
ty
::
ty_enum
(
tid
,
ref
substs
)
=>
{
// Compute max(variant sizes).
// Compute max(variant sizes).
let
mut
max_size
=
0u
;
let
mut
max_size
=
0u
;
...
@@ -753,7 +753,7 @@ fn nilptr(tcx: ty::ctxt) -> ty::t {
...
@@ -753,7 +753,7 @@ fn nilptr(tcx: ty::ctxt) -> ty::t {
ty
::
mk_ptr
(
tcx
,
{
ty
:
ty
::
mk_nil
(
tcx
),
mutbl
:
ast
::
m_imm
})
ty
::
mk_ptr
(
tcx
,
{
ty
:
ty
::
mk_nil
(
tcx
),
mutbl
:
ast
::
m_imm
})
}
}
fn
simplifier
(
tcx
:
ty
::
ctxt
,
typ
:
ty
::
t
)
->
ty
::
t
{
fn
simplifier
(
tcx
:
ty
::
ctxt
,
typ
:
ty
::
t
)
->
ty
::
t
{
match
ty
::
get
(
typ
)
.st
ruct
{
match
ty
::
get
(
typ
)
.st
y
{
ty
::
ty_box
(
_
)
|
ty
::
ty_opaque_box
|
ty
::
ty_uniq
(
_
)
|
ty
::
ty_box
(
_
)
|
ty
::
ty_opaque_box
|
ty
::
ty_uniq
(
_
)
|
ty
::
ty_evec
(
_
,
ty
::
vstore_uniq
)
|
ty
::
ty_evec
(
_
,
ty
::
vstore_box
)
|
ty
::
ty_evec
(
_
,
ty
::
vstore_uniq
)
|
ty
::
ty_evec
(
_
,
ty
::
vstore_box
)
|
ty
::
ty_estr
(
ty
::
vstore_uniq
)
|
ty
::
ty_estr
(
ty
::
vstore_box
)
|
ty
::
ty_estr
(
ty
::
vstore_uniq
)
|
ty
::
ty_estr
(
ty
::
vstore_box
)
|
...
...
src/rustc/middle/trans/tvec.rs
浏览文件 @
27cc0a36
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
fn
expand_boxed_vec_ty
(
tcx
:
ty
::
ctxt
,
t
:
ty
::
t
)
->
ty
::
t
{
fn
expand_boxed_vec_ty
(
tcx
:
ty
::
ctxt
,
t
:
ty
::
t
)
->
ty
::
t
{
let
unit_ty
=
ty
::
sequence_element_type
(
tcx
,
t
);
let
unit_ty
=
ty
::
sequence_element_type
(
tcx
,
t
);
let
unboxed_vec_ty
=
ty
::
mk_mut_unboxed_vec
(
tcx
,
unit_ty
);
let
unboxed_vec_ty
=
ty
::
mk_mut_unboxed_vec
(
tcx
,
unit_ty
);
match
ty
::
get
(
t
)
.st
ruct
{
match
ty
::
get
(
t
)
.st
y
{
ty
::
ty_estr
(
ty
::
vstore_uniq
)
|
ty
::
ty_evec
(
_
,
ty
::
vstore_uniq
)
=>
{
ty
::
ty_estr
(
ty
::
vstore_uniq
)
|
ty
::
ty_evec
(
_
,
ty
::
vstore_uniq
)
=>
{
ty
::
mk_imm_uniq
(
tcx
,
unboxed_vec_ty
)
ty
::
mk_imm_uniq
(
tcx
,
unboxed_vec_ty
)
}
}
...
@@ -431,7 +431,7 @@ fn get_base_and_len(bcx: block,
...
@@ -431,7 +431,7 @@ fn get_base_and_len(bcx: block,
let
ccx
=
bcx
.ccx
();
let
ccx
=
bcx
.ccx
();
let
vt
=
vec_types
(
bcx
,
vec_ty
);
let
vt
=
vec_types
(
bcx
,
vec_ty
);
let
vstore
=
match
ty
::
get
(
vt
.vec_ty
)
.st
ruct
{
let
vstore
=
match
ty
::
get
(
vt
.vec_ty
)
.st
y
{
ty
::
ty_estr
(
vst
)
|
ty
::
ty_evec
(
_
,
vst
)
=>
vst
,
ty
::
ty_estr
(
vst
)
|
ty
::
ty_evec
(
_
,
vst
)
=>
vst
,
_
=>
ty
::
vstore_uniq
_
=>
ty
::
vstore_uniq
};
};
...
...
src/rustc/middle/trans/type_of.rs
浏览文件 @
27cc0a36
...
@@ -55,7 +55,7 @@ fn type_of_non_gc_box(cx: @crate_ctxt, t: ty::t) -> TypeRef {
...
@@ -55,7 +55,7 @@ fn type_of_non_gc_box(cx: @crate_ctxt, t: ty::t) -> TypeRef {
if
t
!=
t_norm
{
if
t
!=
t_norm
{
type_of_non_gc_box
(
cx
,
t_norm
)
type_of_non_gc_box
(
cx
,
t_norm
)
}
else
{
}
else
{
match
ty
::
get
(
t
)
.st
ruct
{
match
ty
::
get
(
t
)
.st
y
{
ty
::
ty_box
(
mt
)
=>
{
ty
::
ty_box
(
mt
)
=>
{
T_ptr
(
T_box
(
cx
,
type_of
(
cx
,
mt
.ty
)))
T_ptr
(
T_box
(
cx
,
type_of
(
cx
,
mt
.ty
)))
}
}
...
@@ -88,7 +88,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
...
@@ -88,7 +88,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
return
llty
;
return
llty
;
}
}
let
llty
=
match
ty
::
get
(
t
)
.st
ruct
{
let
llty
=
match
ty
::
get
(
t
)
.st
y
{
ty
::
ty_nil
|
ty
::
ty_bot
=>
T_nil
(),
ty
::
ty_nil
|
ty
::
ty_bot
=>
T_nil
(),
ty
::
ty_bool
=>
T_bool
(),
ty
::
ty_bool
=>
T_bool
(),
ty
::
ty_int
(
t
)
=>
T_int_ty
(
cx
,
t
),
ty
::
ty_int
(
t
)
=>
T_int_ty
(
cx
,
t
),
...
@@ -178,7 +178,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
...
@@ -178,7 +178,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
cx
.lltypes
.insert
(
t
,
llty
);
cx
.lltypes
.insert
(
t
,
llty
);
// If this was an enum or class, fill in the type now.
// If this was an enum or class, fill in the type now.
match
ty
::
get
(
t
)
.st
ruct
{
match
ty
::
get
(
t
)
.st
y
{
ty
::
ty_enum
(
did
,
_
)
=>
{
ty
::
ty_enum
(
did
,
_
)
=>
{
fill_type_of_enum
(
cx
,
did
,
t
,
llty
);
fill_type_of_enum
(
cx
,
did
,
t
,
llty
);
}
}
...
...
src/rustc/middle/trans/type_use.rs
浏览文件 @
27cc0a36
...
@@ -45,7 +45,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
...
@@ -45,7 +45,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
ccx
.type_use_cache
.insert
(
fn_id
,
vec
::
from_elem
(
n_tps
,
3u
));
ccx
.type_use_cache
.insert
(
fn_id
,
vec
::
from_elem
(
n_tps
,
3u
));
let
cx
=
{
ccx
:
ccx
,
uses
:
vec
::
to_mut
(
vec
::
from_elem
(
n_tps
,
0u
))};
let
cx
=
{
ccx
:
ccx
,
uses
:
vec
::
to_mut
(
vec
::
from_elem
(
n_tps
,
0u
))};
match
ty
::
get
(
ty
::
lookup_item_type
(
cx
.ccx.tcx
,
fn_id
)
.ty
)
.st
ruct
{
match
ty
::
get
(
ty
::
lookup_item_type
(
cx
.ccx.tcx
,
fn_id
)
.ty
)
.st
y
{
ty
::
ty_fn
(
ref
fn_ty
)
=>
{
ty
::
ty_fn
(
ref
fn_ty
)
=>
{
for
vec
::
each
(
fn_ty
.sig.inputs
)
|
arg
|
{
for
vec
::
each
(
fn_ty
.sig.inputs
)
|
arg
|
{
if
arg
.mode
==
expl
(
by_val
)
{
type_needs
(
cx
,
use_repr
,
arg
.ty
);
}
if
arg
.mode
==
expl
(
by_val
)
{
type_needs
(
cx
,
use_repr
,
arg
.ty
);
}
...
@@ -130,7 +130,7 @@ fn type_needs_inner(cx: ctx, use_: uint, ty: ty::t,
...
@@ -130,7 +130,7 @@ fn type_needs_inner(cx: ctx, use_: uint, ty: ty::t,
enums_seen
:
@
List
<
def_id
>
)
{
enums_seen
:
@
List
<
def_id
>
)
{
do
ty
::
maybe_walk_ty
(
ty
)
|
ty
|
{
do
ty
::
maybe_walk_ty
(
ty
)
|
ty
|
{
if
ty
::
type_has_params
(
ty
)
{
if
ty
::
type_has_params
(
ty
)
{
match
ty
::
get
(
ty
)
.st
ruct
{
match
ty
::
get
(
ty
)
.st
y
{
/*
/*
This previously included ty_box -- that was wrong
This previously included ty_box -- that was wrong
because if we cast an @T to an trait (for example) and return
because if we cast an @T to an trait (for example) and return
...
@@ -178,7 +178,7 @@ fn mark_for_expr(cx: ctx, e: @expr) {
...
@@ -178,7 +178,7 @@ fn mark_for_expr(cx: ctx, e: @expr) {
}
}
expr_cast
(
base
,
_
)
=>
{
expr_cast
(
base
,
_
)
=>
{
let
result_t
=
ty
::
node_id_to_type
(
cx
.ccx.tcx
,
e
.id
);
let
result_t
=
ty
::
node_id_to_type
(
cx
.ccx.tcx
,
e
.id
);
match
ty
::
get
(
result_t
)
.st
ruct
{
match
ty
::
get
(
result_t
)
.st
y
{
ty
::
ty_trait
(
*
)
=>
{
ty
::
ty_trait
(
*
)
=>
{
// When we're casting to an trait, we need the
// When we're casting to an trait, we need the
// tydesc for the expr that's being cast.
// tydesc for the expr that's being cast.
...
...
src/rustc/middle/ty.rs
浏览文件 @
27cc0a36
...
@@ -247,18 +247,18 @@ fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
...
@@ -247,18 +247,18 @@ fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
}
}
}
}
type
intern_key
=
{
st
ruct
:
sty
,
o_def_id
:
Option
<
ast
::
def_id
>
};
type
intern_key
=
{
st
y
:
sty
,
o_def_id
:
Option
<
ast
::
def_id
>
};
impl
intern_key
:
cmp
::
Eq
{
impl
intern_key
:
cmp
::
Eq
{
pure
fn
eq
(
&&
other
:
intern_key
)
->
bool
{
pure
fn
eq
(
&&
other
:
intern_key
)
->
bool
{
self
.st
ruct
==
other
.struct
&&
self
.o_def_id
==
other
.o_def_id
self
.st
y
==
other
.sty
&&
self
.o_def_id
==
other
.o_def_id
}
}
pure
fn
ne
(
&&
other
:
intern_key
)
->
bool
{
!
self
.eq
(
other
)
}
pure
fn
ne
(
&&
other
:
intern_key
)
->
bool
{
!
self
.eq
(
other
)
}
}
}
impl
intern_key
:
to_bytes
::
IterBytes
{
impl
intern_key
:
to_bytes
::
IterBytes
{
fn
iter_bytes
(
lsb0
:
bool
,
f
:
to_bytes
::
Cb
)
{
fn
iter_bytes
(
lsb0
:
bool
,
f
:
to_bytes
::
Cb
)
{
to_bytes
::
iter_bytes_2
(
&
self
.st
ruct
,
&
self
.o_def_id
,
lsb0
,
f
);
to_bytes
::
iter_bytes_2
(
&
self
.st
y
,
&
self
.o_def_id
,
lsb0
,
f
);
}
}
}
}
...
@@ -356,7 +356,7 @@ enum tbox_flag {
...
@@ -356,7 +356,7 @@ enum tbox_flag {
needs_subst
=
1
|
2
|
8
needs_subst
=
1
|
2
|
8
}
}
type
t_box
=
@
{
st
ruct
:
sty
,
type
t_box
=
@
{
st
y
:
sty
,
id
:
uint
,
id
:
uint
,
flags
:
uint
,
flags
:
uint
,
o_def_id
:
Option
<
ast
::
def_id
>
};
o_def_id
:
Option
<
ast
::
def_id
>
};
...
@@ -854,7 +854,7 @@ fn mk_t(cx: ctxt, +st: sty) -> t { mk_t_with_id(cx, st, None) }
...
@@ -854,7 +854,7 @@ fn mk_t(cx: ctxt, +st: sty) -> t { mk_t_with_id(cx, st, None) }
// Interns a type/name combination, stores the resulting box in cx.interner,
// Interns a type/name combination, stores the resulting box in cx.interner,
// and returns the box as cast to an unsafe ptr (see comments for t above).
// and returns the box as cast to an unsafe ptr (see comments for t above).
fn
mk_t_with_id
(
cx
:
ctxt
,
+
st
:
sty
,
o_def_id
:
Option
<
ast
::
def_id
>
)
->
t
{
fn
mk_t_with_id
(
cx
:
ctxt
,
+
st
:
sty
,
o_def_id
:
Option
<
ast
::
def_id
>
)
->
t
{
let
key
=
{
st
ruct
:
st
,
o_def_id
:
o_def_id
};
let
key
=
{
st
y
:
st
,
o_def_id
:
o_def_id
};
match
cx
.interner
.find
(
key
)
{
match
cx
.interner
.find
(
key
)
{
Some
(
t
)
=>
unsafe
{
return
unsafe
::
reinterpret_cast
(
&
t
);
},
Some
(
t
)
=>
unsafe
{
return
unsafe
::
reinterpret_cast
(
&
t
);
},
_
=>
()
_
=>
()
...
@@ -911,7 +911,7 @@ fn sflags(substs: &substs) -> uint {
...
@@ -911,7 +911,7 @@ fn sflags(substs: &substs) -> uint {
flags
|
=
get
(
f
.sig.output
)
.flags
;
flags
|
=
get
(
f
.sig.output
)
.flags
;
}
}
}
}
let
t
=
@
{
st
ruct
:
st
,
id
:
cx
.next_id
,
flags
:
flags
,
o_def_id
:
o_def_id
};
let
t
=
@
{
st
y
:
st
,
id
:
cx
.next_id
,
flags
:
flags
,
o_def_id
:
o_def_id
};
cx
.interner
.insert
(
key
,
t
);
cx
.interner
.insert
(
key
,
t
);
cx
.next_id
+=
1u
;
cx
.next_id
+=
1u
;
unsafe
{
unsafe
::
reinterpret_cast
(
&
t
)
}
unsafe
{
unsafe
::
reinterpret_cast
(
&
t
)
}
...
@@ -1046,12 +1046,12 @@ fn mk_opaque_closure_ptr(cx: ctxt, ck: closure_kind) -> t {
...
@@ -1046,12 +1046,12 @@ fn mk_opaque_closure_ptr(cx: ctxt, ck: closure_kind) -> t {
fn
mk_opaque_box
(
cx
:
ctxt
)
->
t
{
mk_t
(
cx
,
ty_opaque_box
)
}
fn
mk_opaque_box
(
cx
:
ctxt
)
->
t
{
mk_t
(
cx
,
ty_opaque_box
)
}
fn
mk_with_id
(
cx
:
ctxt
,
base
:
t
,
def_id
:
ast
::
def_id
)
->
t
{
fn
mk_with_id
(
cx
:
ctxt
,
base
:
t
,
def_id
:
ast
::
def_id
)
->
t
{
mk_t_with_id
(
cx
,
get
(
base
)
.st
ruct
,
Some
(
def_id
))
mk_t_with_id
(
cx
,
get
(
base
)
.st
y
,
Some
(
def_id
))
}
}
// Converts s to its machine type equivalent
// Converts s to its machine type equivalent
pure
fn
mach_sty
(
cfg
:
@
session
::
config
,
t
:
t
)
->
sty
{
pure
fn
mach_sty
(
cfg
:
@
session
::
config
,
t
:
t
)
->
sty
{
match
get
(
t
)
.st
ruct
{
match
get
(
t
)
.st
y
{
ty_int
(
ast
::
ty_i
)
=>
ty_int
(
cfg
.int_type
),
ty_int
(
ast
::
ty_i
)
=>
ty_int
(
cfg
.int_type
),
ty_uint
(
ast
::
ty_u
)
=>
ty_uint
(
cfg
.uint_type
),
ty_uint
(
ast
::
ty_u
)
=>
ty_uint
(
cfg
.uint_type
),
ty_float
(
ast
::
ty_f
)
=>
ty_float
(
cfg
.float_type
),
ty_float
(
ast
::
ty_f
)
=>
ty_float
(
cfg
.float_type
),
...
@@ -1079,7 +1079,7 @@ fn walk_ty(ty: t, f: fn(t)) {
...
@@ -1079,7 +1079,7 @@ fn walk_ty(ty: t, f: fn(t)) {
fn
maybe_walk_ty
(
ty
:
t
,
f
:
fn
(
t
)
->
bool
)
{
fn
maybe_walk_ty
(
ty
:
t
,
f
:
fn
(
t
)
->
bool
)
{
if
!
f
(
ty
)
{
return
;
}
if
!
f
(
ty
)
{
return
;
}
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_nil
|
ty_bot
|
ty_bool
|
ty_int
(
_
)
|
ty_uint
(
_
)
|
ty_float
(
_
)
|
ty_nil
|
ty_bot
|
ty_bool
|
ty_int
(
_
)
|
ty_uint
(
_
)
|
ty_float
(
_
)
|
ty_estr
(
_
)
|
ty_type
|
ty_opaque_box
|
ty_self
|
ty_estr
(
_
)
|
ty_type
|
ty_opaque_box
|
ty_self
|
ty_opaque_closure_ptr
(
_
)
|
ty_infer
(
_
)
|
ty_param
(
_
)
=>
{
ty_opaque_closure_ptr
(
_
)
|
ty_infer
(
_
)
|
ty_param
(
_
)
=>
{
...
@@ -1176,7 +1176,7 @@ fn fold_substs(substs: &substs, fldop: fn(t) -> t) -> substs {
...
@@ -1176,7 +1176,7 @@ fn fold_substs(substs: &substs, fldop: fn(t) -> t) -> substs {
// Folds types from the bottom up.
// Folds types from the bottom up.
fn
fold_ty
(
cx
:
ctxt
,
t0
:
t
,
fldop
:
fn
(
t
)
->
t
)
->
t
{
fn
fold_ty
(
cx
:
ctxt
,
t0
:
t
,
fldop
:
fn
(
t
)
->
t
)
->
t
{
let
sty
=
fold_sty
(
&
get
(
t0
)
.st
ruct
,
|
t
|
fold_ty
(
cx
,
fldop
(
t
),
fldop
));
let
sty
=
fold_sty
(
&
get
(
t0
)
.st
y
,
|
t
|
fold_ty
(
cx
,
fldop
(
t
),
fldop
));
fldop
(
mk_t
(
cx
,
sty
))
fldop
(
mk_t
(
cx
,
sty
))
}
}
...
@@ -1213,7 +1213,7 @@ fn fold_substs(
...
@@ -1213,7 +1213,7 @@ fn fold_substs(
}
}
let
tb
=
ty
::
get
(
ty
);
let
tb
=
ty
::
get
(
ty
);
match
tb
.st
ruct
{
match
tb
.st
y
{
ty
::
ty_rptr
(
r
,
mt
)
=>
{
ty
::
ty_rptr
(
r
,
mt
)
=>
{
let
m_r
=
fldr
(
r
);
let
m_r
=
fldr
(
r
);
let
m_t
=
fldt
(
mt
.ty
);
let
m_t
=
fldt
(
mt
.ty
);
...
@@ -1288,7 +1288,7 @@ fn do_fold(cx: ctxt, t0: t, under_r: bool,
...
@@ -1288,7 +1288,7 @@ fn do_fold(cx: ctxt, t0: t, under_r: bool,
fldop
:
fn
(
region
,
bool
)
->
region
)
->
t
{
fldop
:
fn
(
region
,
bool
)
->
region
)
->
t
{
let
tb
=
get
(
t0
);
let
tb
=
get
(
t0
);
if
!
tbox_has_flag
(
tb
,
has_regions
)
{
return
t0
;
}
if
!
tbox_has_flag
(
tb
,
has_regions
)
{
return
t0
;
}
match
tb
.st
ruct
{
match
tb
.st
y
{
ty_rptr
(
r
,
{
ty
:
t1
,
mutbl
:
m
})
=>
{
ty_rptr
(
r
,
{
ty
:
t1
,
mutbl
:
m
})
=>
{
let
m_r
=
fldop
(
r
,
under_r
);
let
m_r
=
fldop
(
r
,
under_r
);
let
m_t1
=
do_fold
(
cx
,
t1
,
true
,
fldop
);
let
m_t1
=
do_fold
(
cx
,
t1
,
true
,
fldop
);
...
@@ -1323,7 +1323,7 @@ fn subst_tps(cx: ctxt, tps: &[t], typ: t) -> t {
...
@@ -1323,7 +1323,7 @@ fn subst_tps(cx: ctxt, tps: &[t], typ: t) -> t {
if
tps
.len
()
==
0u
{
return
typ
;
}
if
tps
.len
()
==
0u
{
return
typ
;
}
let
tb
=
ty
::
get
(
typ
);
let
tb
=
ty
::
get
(
typ
);
if
!
tbox_has_flag
(
tb
,
has_params
)
{
return
typ
;
}
if
!
tbox_has_flag
(
tb
,
has_params
)
{
return
typ
;
}
match
tb
.st
ruct
{
match
tb
.st
y
{
ty_param
(
p
)
=>
tps
[
p
.idx
],
ty_param
(
p
)
=>
tps
[
p
.idx
],
ref
sty
=>
fold_sty_to_ty
(
cx
,
sty
,
|
t
|
subst_tps
(
cx
,
tps
,
t
))
ref
sty
=>
fold_sty_to_ty
(
cx
,
sty
,
|
t
|
subst_tps
(
cx
,
tps
,
t
))
}
}
...
@@ -1374,7 +1374,7 @@ fn do_subst(cx: ctxt,
...
@@ -1374,7 +1374,7 @@ fn do_subst(cx: ctxt,
typ
:
t
)
->
t
{
typ
:
t
)
->
t
{
let
tb
=
get
(
typ
);
let
tb
=
get
(
typ
);
if
!
tbox_has_flag
(
tb
,
needs_subst
)
{
return
typ
;
}
if
!
tbox_has_flag
(
tb
,
needs_subst
)
{
return
typ
;
}
match
tb
.st
ruct
{
match
tb
.st
y
{
ty_param
(
p
)
=>
substs
.tps
[
p
.idx
],
ty_param
(
p
)
=>
substs
.tps
[
p
.idx
],
ty_self
=>
substs
.self_ty
.get
(),
ty_self
=>
substs
.self_ty
.get
(),
_
=>
{
_
=>
{
...
@@ -1393,21 +1393,21 @@ fn do_subst(cx: ctxt,
...
@@ -1393,21 +1393,21 @@ fn do_subst(cx: ctxt,
// Type utilities
// Type utilities
fn
type_is_nil
(
ty
:
t
)
->
bool
{
get
(
ty
)
.st
ruct
==
ty_nil
}
fn
type_is_nil
(
ty
:
t
)
->
bool
{
get
(
ty
)
.st
y
==
ty_nil
}
fn
type_is_bot
(
ty
:
t
)
->
bool
{
get
(
ty
)
.st
ruct
==
ty_bot
}
fn
type_is_bot
(
ty
:
t
)
->
bool
{
get
(
ty
)
.st
y
==
ty_bot
}
fn
type_is_ty_var
(
ty
:
t
)
->
bool
{
fn
type_is_ty_var
(
ty
:
t
)
->
bool
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_infer
(
TyVar
(
_
))
=>
true
,
ty_infer
(
TyVar
(
_
))
=>
true
,
_
=>
false
_
=>
false
}
}
}
}
fn
type_is_bool
(
ty
:
t
)
->
bool
{
get
(
ty
)
.st
ruct
==
ty_bool
}
fn
type_is_bool
(
ty
:
t
)
->
bool
{
get
(
ty
)
.st
y
==
ty_bool
}
fn
type_is_structural
(
ty
:
t
)
->
bool
{
fn
type_is_structural
(
ty
:
t
)
->
bool
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_rec
(
_
)
|
ty_class
(
*
)
|
ty_tup
(
_
)
|
ty_enum
(
*
)
|
ty_fn
(
_
)
|
ty_rec
(
_
)
|
ty_class
(
*
)
|
ty_tup
(
_
)
|
ty_enum
(
*
)
|
ty_fn
(
_
)
|
ty_trait
(
*
)
|
ty_trait
(
*
)
|
ty_evec
(
_
,
vstore_fixed
(
_
))
|
ty_estr
(
vstore_fixed
(
_
))
|
ty_evec
(
_
,
vstore_fixed
(
_
))
|
ty_estr
(
vstore_fixed
(
_
))
|
...
@@ -1422,21 +1422,21 @@ fn type_is_copyable(cx: ctxt, ty: t) -> bool {
...
@@ -1422,21 +1422,21 @@ fn type_is_copyable(cx: ctxt, ty: t) -> bool {
}
}
fn
type_is_sequence
(
ty
:
t
)
->
bool
{
fn
type_is_sequence
(
ty
:
t
)
->
bool
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_estr
(
_
)
|
ty_evec
(
_
,
_
)
=>
true
,
ty_estr
(
_
)
|
ty_evec
(
_
,
_
)
=>
true
,
_
=>
false
_
=>
false
}
}
}
}
fn
type_is_str
(
ty
:
t
)
->
bool
{
fn
type_is_str
(
ty
:
t
)
->
bool
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_estr
(
_
)
=>
true
,
ty_estr
(
_
)
=>
true
,
_
=>
false
_
=>
false
}
}
}
}
fn
sequence_element_type
(
cx
:
ctxt
,
ty
:
t
)
->
t
{
fn
sequence_element_type
(
cx
:
ctxt
,
ty
:
t
)
->
t
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_estr
(
_
)
=>
return
mk_mach_uint
(
cx
,
ast
::
ty_u8
),
ty_estr
(
_
)
=>
return
mk_mach_uint
(
cx
,
ast
::
ty_u8
),
ty_evec
(
mt
,
_
)
|
ty_unboxed_vec
(
mt
)
=>
return
mt
.ty
,
ty_evec
(
mt
,
_
)
|
ty_unboxed_vec
(
mt
)
=>
return
mt
.ty
,
_
=>
cx
.sess
.bug
(
_
=>
cx
.sess
.bug
(
...
@@ -1445,7 +1445,7 @@ fn sequence_element_type(cx: ctxt, ty: t) -> t {
...
@@ -1445,7 +1445,7 @@ fn sequence_element_type(cx: ctxt, ty: t) -> t {
}
}
fn
get_element_type
(
ty
:
t
,
i
:
uint
)
->
t
{
fn
get_element_type
(
ty
:
t
,
i
:
uint
)
->
t
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_rec
(
flds
)
=>
return
flds
[
i
]
.mt.ty
,
ty_rec
(
flds
)
=>
return
flds
[
i
]
.mt.ty
,
ty_tup
(
ts
)
=>
return
ts
[
i
],
ty_tup
(
ts
)
=>
return
ts
[
i
],
_
=>
fail
~
"get_element_type called on invalid type"
_
=>
fail
~
"get_element_type called on invalid type"
...
@@ -1453,14 +1453,14 @@ fn get_element_type(ty: t, i: uint) -> t {
...
@@ -1453,14 +1453,14 @@ fn get_element_type(ty: t, i: uint) -> t {
}
}
pure
fn
type_is_box
(
ty
:
t
)
->
bool
{
pure
fn
type_is_box
(
ty
:
t
)
->
bool
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_box
(
_
)
=>
return
true
,
ty_box
(
_
)
=>
return
true
,
_
=>
return
false
_
=>
return
false
}
}
}
}
pure
fn
type_is_boxed
(
ty
:
t
)
->
bool
{
pure
fn
type_is_boxed
(
ty
:
t
)
->
bool
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_box
(
_
)
|
ty_opaque_box
|
ty_box
(
_
)
|
ty_opaque_box
|
ty_evec
(
_
,
vstore_box
)
|
ty_estr
(
vstore_box
)
=>
true
,
ty_evec
(
_
,
vstore_box
)
|
ty_estr
(
vstore_box
)
=>
true
,
_
=>
false
_
=>
false
...
@@ -1468,35 +1468,35 @@ fn get_element_type(ty: t, i: uint) -> t {
...
@@ -1468,35 +1468,35 @@ fn get_element_type(ty: t, i: uint) -> t {
}
}
pure
fn
type_is_region_ptr
(
ty
:
t
)
->
bool
{
pure
fn
type_is_region_ptr
(
ty
:
t
)
->
bool
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_rptr
(
_
,
_
)
=>
true
,
ty_rptr
(
_
,
_
)
=>
true
,
_
=>
false
_
=>
false
}
}
}
}
pure
fn
type_is_slice
(
ty
:
t
)
->
bool
{
pure
fn
type_is_slice
(
ty
:
t
)
->
bool
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_evec
(
_
,
vstore_slice
(
_
))
|
ty_estr
(
vstore_slice
(
_
))
=>
true
,
ty_evec
(
_
,
vstore_slice
(
_
))
|
ty_estr
(
vstore_slice
(
_
))
=>
true
,
_
=>
return
false
_
=>
return
false
}
}
}
}
pure
fn
type_is_unique_box
(
ty
:
t
)
->
bool
{
pure
fn
type_is_unique_box
(
ty
:
t
)
->
bool
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_uniq
(
_
)
=>
return
true
,
ty_uniq
(
_
)
=>
return
true
,
_
=>
return
false
_
=>
return
false
}
}
}
}
pure
fn
type_is_unsafe_ptr
(
ty
:
t
)
->
bool
{
pure
fn
type_is_unsafe_ptr
(
ty
:
t
)
->
bool
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_ptr
(
_
)
=>
return
true
,
ty_ptr
(
_
)
=>
return
true
,
_
=>
return
false
_
=>
return
false
}
}
}
}
pure
fn
type_is_vec
(
ty
:
t
)
->
bool
{
pure
fn
type_is_vec
(
ty
:
t
)
->
bool
{
return
match
get
(
ty
)
.st
ruct
{
return
match
get
(
ty
)
.st
y
{
ty_evec
(
_
,
_
)
|
ty_unboxed_vec
(
_
)
=>
true
,
ty_evec
(
_
,
_
)
|
ty_unboxed_vec
(
_
)
=>
true
,
ty_estr
(
_
)
=>
true
,
ty_estr
(
_
)
=>
true
,
_
=>
false
_
=>
false
...
@@ -1504,7 +1504,7 @@ fn get_element_type(ty: t, i: uint) -> t {
...
@@ -1504,7 +1504,7 @@ fn get_element_type(ty: t, i: uint) -> t {
}
}
pure
fn
type_is_unique
(
ty
:
t
)
->
bool
{
pure
fn
type_is_unique
(
ty
:
t
)
->
bool
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_uniq
(
_
)
=>
return
true
,
ty_uniq
(
_
)
=>
return
true
,
ty_evec
(
_
,
vstore_uniq
)
=>
true
,
ty_evec
(
_
,
vstore_uniq
)
=>
true
,
ty_estr
(
vstore_uniq
)
=>
true
,
ty_estr
(
vstore_uniq
)
=>
true
,
...
@@ -1518,7 +1518,7 @@ fn get_element_type(ty: t, i: uint) -> t {
...
@@ -1518,7 +1518,7 @@ fn get_element_type(ty: t, i: uint) -> t {
contents are abstract to rustc.)
contents are abstract to rustc.)
*/
*/
pure
fn
type_is_scalar
(
ty
:
t
)
->
bool
{
pure
fn
type_is_scalar
(
ty
:
t
)
->
bool
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_nil
|
ty_bool
|
ty_int
(
_
)
|
ty_float
(
_
)
|
ty_uint
(
_
)
|
ty_nil
|
ty_bool
|
ty_int
(
_
)
|
ty_float
(
_
)
|
ty_uint
(
_
)
|
ty_infer
(
IntVar
(
_
))
|
ty_type
|
ty_ptr
(
_
)
=>
true
,
ty_infer
(
IntVar
(
_
))
|
ty_type
|
ty_ptr
(
_
)
=>
true
,
_
=>
false
_
=>
false
...
@@ -1537,7 +1537,7 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool {
...
@@ -1537,7 +1537,7 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool {
}
}
let
mut
accum
=
false
;
let
mut
accum
=
false
;
let
result
=
match
get
(
ty
)
.st
ruct
{
let
result
=
match
get
(
ty
)
.st
y
{
// scalar types
// scalar types
ty_nil
|
ty_bot
|
ty_bool
|
ty_int
(
_
)
|
ty_float
(
_
)
|
ty_uint
(
_
)
|
ty_nil
|
ty_bot
|
ty_bool
|
ty_int
(
_
)
|
ty_float
(
_
)
|
ty_uint
(
_
)
|
ty_type
|
ty_ptr
(
_
)
|
ty_rptr
(
_
,
_
)
|
ty_type
|
ty_ptr
(
_
)
|
ty_rptr
(
_
,
_
)
|
...
@@ -1620,7 +1620,7 @@ fn type_needs_unwind_cleanup_(cx: ctxt, ty: t,
...
@@ -1620,7 +1620,7 @@ fn type_needs_unwind_cleanup_(cx: ctxt, ty: t,
let
mut
needs_unwind_cleanup
=
false
;
let
mut
needs_unwind_cleanup
=
false
;
do
maybe_walk_ty
(
ty
)
|
ty
|
{
do
maybe_walk_ty
(
ty
)
|
ty
|
{
let
old_encountered_box
=
encountered_box
;
let
old_encountered_box
=
encountered_box
;
let
result
=
match
get
(
ty
)
.st
ruct
{
let
result
=
match
get
(
ty
)
.st
y
{
ty_box
(
_
)
|
ty_opaque_box
=>
{
ty_box
(
_
)
|
ty_opaque_box
=>
{
encountered_box
=
true
;
encountered_box
=
true
;
true
true
...
@@ -1873,7 +1873,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
...
@@ -1873,7 +1873,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
// Insert a default in case we loop back on self recursively.
// Insert a default in case we loop back on self recursively.
cx
.kind_cache
.insert
(
ty
,
kind_top
());
cx
.kind_cache
.insert
(
ty
,
kind_top
());
let
mut
result
=
match
get
(
ty
)
.st
ruct
{
let
mut
result
=
match
get
(
ty
)
.st
y
{
// Scalar and unique types are sendable, constant, and owned
// Scalar and unique types are sendable, constant, and owned
ty_nil
|
ty_bot
|
ty_bool
|
ty_int
(
_
)
|
ty_uint
(
_
)
|
ty_float
(
_
)
|
ty_nil
|
ty_bot
|
ty_bool
|
ty_int
(
_
)
|
ty_uint
(
_
)
|
ty_float
(
_
)
|
ty_ptr
(
_
)
=>
{
ty_ptr
(
_
)
=>
{
...
@@ -2025,7 +2025,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
...
@@ -2025,7 +2025,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
/// gives a rough estimate of how much space it takes to represent
/// gives a rough estimate of how much space it takes to represent
/// an instance of `ty`. Used for the mode transition.
/// an instance of `ty`. Used for the mode transition.
fn
type_size
(
cx
:
ctxt
,
ty
:
t
)
->
uint
{
fn
type_size
(
cx
:
ctxt
,
ty
:
t
)
->
uint
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_nil
|
ty_bot
|
ty_bool
|
ty_int
(
_
)
|
ty_uint
(
_
)
|
ty_float
(
_
)
|
ty_nil
|
ty_bot
|
ty_bool
|
ty_int
(
_
)
|
ty_uint
(
_
)
|
ty_float
(
_
)
|
ty_ptr
(
_
)
|
ty_box
(
_
)
|
ty_uniq
(
_
)
|
ty_estr
(
vstore_uniq
)
|
ty_ptr
(
_
)
|
ty_box
(
_
)
|
ty_uniq
(
_
)
|
ty_estr
(
vstore_uniq
)
|
ty_trait
(
*
)
|
ty_rptr
(
*
)
|
ty_evec
(
_
,
vstore_uniq
)
|
ty_trait
(
*
)
|
ty_rptr
(
*
)
|
ty_evec
(
_
,
vstore_uniq
)
|
...
@@ -2093,7 +2093,7 @@ fn type_requires(cx: ctxt, seen: @mut ~[def_id],
...
@@ -2093,7 +2093,7 @@ fn type_requires(cx: ctxt, seen: @mut ~[def_id],
ty_to_str
(
cx
,
ty
));
ty_to_str
(
cx
,
ty
));
let
r
=
{
let
r
=
{
get
(
r_ty
)
.st
ruct
==
get
(
ty
)
.struct
||
get
(
r_ty
)
.st
y
==
get
(
ty
)
.sty
||
subtypes_require
(
cx
,
seen
,
r_ty
,
ty
)
subtypes_require
(
cx
,
seen
,
r_ty
,
ty
)
};
};
...
@@ -2110,7 +2110,7 @@ fn subtypes_require(cx: ctxt, seen: @mut ~[def_id],
...
@@ -2110,7 +2110,7 @@ fn subtypes_require(cx: ctxt, seen: @mut ~[def_id],
ty_to_str
(
cx
,
r_ty
),
ty_to_str
(
cx
,
r_ty
),
ty_to_str
(
cx
,
ty
));
ty_to_str
(
cx
,
ty
));
let
r
=
match
get
(
ty
)
.st
ruct
{
let
r
=
match
get
(
ty
)
.st
y
{
ty_nil
|
ty_nil
|
ty_bot
|
ty_bot
|
ty_bool
|
ty_bool
|
...
@@ -2197,7 +2197,7 @@ fn subtypes_require(cx: ctxt, seen: @mut ~[def_id],
...
@@ -2197,7 +2197,7 @@ fn subtypes_require(cx: ctxt, seen: @mut ~[def_id],
fn
type_structurally_contains
(
cx
:
ctxt
,
ty
:
t
,
test
:
fn
(
x
:
&
sty
)
->
bool
)
->
fn
type_structurally_contains
(
cx
:
ctxt
,
ty
:
t
,
test
:
fn
(
x
:
&
sty
)
->
bool
)
->
bool
{
bool
{
let
sty
=
&
get
(
ty
)
.st
ruct
;
let
sty
=
&
get
(
ty
)
.st
y
;
debug!
(
"type_structurally_contains: %s"
,
ty_to_str
(
cx
,
ty
));
debug!
(
"type_structurally_contains: %s"
,
ty_to_str
(
cx
,
ty
));
if
test
(
sty
)
{
return
true
;
}
if
test
(
sty
)
{
return
true
;
}
match
*
sty
{
match
*
sty
{
...
@@ -2251,14 +2251,14 @@ fn type_structurally_contains_uniques(cx: ctxt, ty: t) -> bool {
...
@@ -2251,14 +2251,14 @@ fn type_structurally_contains_uniques(cx: ctxt, ty: t) -> bool {
}
}
fn
type_is_integral
(
ty
:
t
)
->
bool
{
fn
type_is_integral
(
ty
:
t
)
->
bool
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_infer
(
IntVar
(
_
))
|
ty_int
(
_
)
|
ty_uint
(
_
)
|
ty_bool
=>
true
,
ty_infer
(
IntVar
(
_
))
|
ty_int
(
_
)
|
ty_uint
(
_
)
|
ty_bool
=>
true
,
_
=>
false
_
=>
false
}
}
}
}
fn
type_is_fp
(
ty
:
t
)
->
bool
{
fn
type_is_fp
(
ty
:
t
)
->
bool
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_float
(
_
)
=>
true
,
ty_float
(
_
)
=>
true
,
_
=>
false
_
=>
false
}
}
...
@@ -2269,7 +2269,7 @@ fn type_is_numeric(ty: t) -> bool {
...
@@ -2269,7 +2269,7 @@ fn type_is_numeric(ty: t) -> bool {
}
}
fn
type_is_signed
(
ty
:
t
)
->
bool
{
fn
type_is_signed
(
ty
:
t
)
->
bool
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_int
(
_
)
=>
true
,
ty_int
(
_
)
=>
true
,
_
=>
false
_
=>
false
}
}
...
@@ -2279,7 +2279,7 @@ fn type_is_signed(ty: t) -> bool {
...
@@ -2279,7 +2279,7 @@ fn type_is_signed(ty: t) -> bool {
// that the cycle collector might care about.
// that the cycle collector might care about.
fn
type_is_pod
(
cx
:
ctxt
,
ty
:
t
)
->
bool
{
fn
type_is_pod
(
cx
:
ctxt
,
ty
:
t
)
->
bool
{
let
mut
result
=
true
;
let
mut
result
=
true
;
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
// Scalar types
// Scalar types
ty_nil
|
ty_bot
|
ty_bool
|
ty_int
(
_
)
|
ty_float
(
_
)
|
ty_uint
(
_
)
|
ty_nil
|
ty_bot
|
ty_bool
|
ty_int
(
_
)
|
ty_float
(
_
)
|
ty_uint
(
_
)
|
ty_type
|
ty_ptr
(
_
)
=>
result
=
true
,
ty_type
|
ty_ptr
(
_
)
=>
result
=
true
,
...
@@ -2334,7 +2334,7 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool {
...
@@ -2334,7 +2334,7 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool {
}
}
fn
type_is_enum
(
ty
:
t
)
->
bool
{
fn
type_is_enum
(
ty
:
t
)
->
bool
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_enum
(
_
,
_
)
=>
return
true
,
ty_enum
(
_
,
_
)
=>
return
true
,
_
=>
return
false
_
=>
return
false
}
}
...
@@ -2343,7 +2343,7 @@ fn type_is_enum(ty: t) -> bool {
...
@@ -2343,7 +2343,7 @@ fn type_is_enum(ty: t) -> bool {
// Whether a type is enum like, that is a enum type with only nullary
// Whether a type is enum like, that is a enum type with only nullary
// constructors
// constructors
fn
type_is_c_like_enum
(
cx
:
ctxt
,
ty
:
t
)
->
bool
{
fn
type_is_c_like_enum
(
cx
:
ctxt
,
ty
:
t
)
->
bool
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_enum
(
did
,
_
)
=>
{
ty_enum
(
did
,
_
)
=>
{
let
variants
=
enum_variants
(
cx
,
did
);
let
variants
=
enum_variants
(
cx
,
did
);
let
some_n_ary
=
vec
::
any
(
*
variants
,
|
v
|
vec
::
len
(
v
.args
)
>
0u
);
let
some_n_ary
=
vec
::
any
(
*
variants
,
|
v
|
vec
::
len
(
v
.args
)
>
0u
);
...
@@ -2354,7 +2354,7 @@ fn type_is_c_like_enum(cx: ctxt, ty: t) -> bool {
...
@@ -2354,7 +2354,7 @@ fn type_is_c_like_enum(cx: ctxt, ty: t) -> bool {
}
}
fn
type_param
(
ty
:
t
)
->
Option
<
uint
>
{
fn
type_param
(
ty
:
t
)
->
Option
<
uint
>
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_param
(
p
)
=>
return
Some
(
p
.idx
),
ty_param
(
p
)
=>
return
Some
(
p
.idx
),
_
=>
{
/* fall through */
}
_
=>
{
/* fall through */
}
}
}
...
@@ -2366,7 +2366,7 @@ fn type_param(ty: t) -> Option<uint> {
...
@@ -2366,7 +2366,7 @@ fn type_param(ty: t) -> Option<uint> {
// The parameter `expl` indicates if this is an *explicit* dereference. Some
// The parameter `expl` indicates if this is an *explicit* dereference. Some
// types---notably unsafe ptrs---can only be dereferenced explicitly.
// types---notably unsafe ptrs---can only be dereferenced explicitly.
fn
deref
(
cx
:
ctxt
,
t
:
t
,
expl
:
bool
)
->
Option
<
mt
>
{
fn
deref
(
cx
:
ctxt
,
t
:
t
,
expl
:
bool
)
->
Option
<
mt
>
{
deref_sty
(
cx
,
&
get
(
t
)
.st
ruct
,
expl
)
deref_sty
(
cx
,
&
get
(
t
)
.st
y
,
expl
)
}
}
fn
deref_sty
(
cx
:
ctxt
,
sty
:
&
sty
,
expl
:
bool
)
->
Option
<
mt
>
{
fn
deref_sty
(
cx
:
ctxt
,
sty
:
&
sty
,
expl
:
bool
)
->
Option
<
mt
>
{
match
*
sty
{
match
*
sty
{
...
@@ -2404,7 +2404,7 @@ fn type_autoderef(cx: ctxt, t: t) -> t {
...
@@ -2404,7 +2404,7 @@ fn type_autoderef(cx: ctxt, t: t) -> t {
// Returns the type and mutability of t[i]
// Returns the type and mutability of t[i]
fn
index
(
cx
:
ctxt
,
t
:
t
)
->
Option
<
mt
>
{
fn
index
(
cx
:
ctxt
,
t
:
t
)
->
Option
<
mt
>
{
index_sty
(
cx
,
&
get
(
t
)
.st
ruct
)
index_sty
(
cx
,
&
get
(
t
)
.st
y
)
}
}
fn
index_sty
(
cx
:
ctxt
,
sty
:
&
sty
)
->
Option
<
mt
>
{
fn
index_sty
(
cx
:
ctxt
,
sty
:
&
sty
)
->
Option
<
mt
>
{
...
@@ -2714,49 +2714,49 @@ fn node_id_has_type_params(cx: ctxt, id: ast::node_id) -> bool {
...
@@ -2714,49 +2714,49 @@ fn node_id_has_type_params(cx: ctxt, id: ast::node_id) -> bool {
// Type accessors for substructures of types
// Type accessors for substructures of types
fn
ty_fn_args
(
fty
:
t
)
->
~
[
arg
]
{
fn
ty_fn_args
(
fty
:
t
)
->
~
[
arg
]
{
match
get
(
fty
)
.st
ruct
{
match
get
(
fty
)
.st
y
{
ty_fn
(
ref
f
)
=>
f
.sig.inputs
,
ty_fn
(
ref
f
)
=>
f
.sig.inputs
,
_
=>
fail
~
"ty_fn_args() called on non-fn type"
_
=>
fail
~
"ty_fn_args() called on non-fn type"
}
}
}
}
fn
ty_fn_proto
(
fty
:
t
)
->
fn_proto
{
fn
ty_fn_proto
(
fty
:
t
)
->
fn_proto
{
match
get
(
fty
)
.st
ruct
{
match
get
(
fty
)
.st
y
{
ty_fn
(
ref
f
)
=>
f
.meta.proto
,
ty_fn
(
ref
f
)
=>
f
.meta.proto
,
_
=>
fail
~
"ty_fn_proto() called on non-fn type"
_
=>
fail
~
"ty_fn_proto() called on non-fn type"
}
}
}
}
fn
ty_fn_purity
(
fty
:
t
)
->
ast
::
purity
{
fn
ty_fn_purity
(
fty
:
t
)
->
ast
::
purity
{
match
get
(
fty
)
.st
ruct
{
match
get
(
fty
)
.st
y
{
ty_fn
(
ref
f
)
=>
f
.meta.purity
,
ty_fn
(
ref
f
)
=>
f
.meta.purity
,
_
=>
fail
~
"ty_fn_purity() called on non-fn type"
_
=>
fail
~
"ty_fn_purity() called on non-fn type"
}
}
}
}
pure
fn
ty_fn_ret
(
fty
:
t
)
->
t
{
pure
fn
ty_fn_ret
(
fty
:
t
)
->
t
{
match
get
(
fty
)
.st
ruct
{
match
get
(
fty
)
.st
y
{
ty_fn
(
ref
f
)
=>
f
.sig.output
,
ty_fn
(
ref
f
)
=>
f
.sig.output
,
_
=>
fail
~
"ty_fn_ret() called on non-fn type"
_
=>
fail
~
"ty_fn_ret() called on non-fn type"
}
}
}
}
fn
ty_fn_ret_style
(
fty
:
t
)
->
ast
::
ret_style
{
fn
ty_fn_ret_style
(
fty
:
t
)
->
ast
::
ret_style
{
match
get
(
fty
)
.st
ruct
{
match
get
(
fty
)
.st
y
{
ty_fn
(
ref
f
)
=>
f
.meta.ret_style
,
ty_fn
(
ref
f
)
=>
f
.meta.ret_style
,
_
=>
fail
~
"ty_fn_ret_style() called on non-fn type"
_
=>
fail
~
"ty_fn_ret_style() called on non-fn type"
}
}
}
}
fn
is_fn_ty
(
fty
:
t
)
->
bool
{
fn
is_fn_ty
(
fty
:
t
)
->
bool
{
match
get
(
fty
)
.st
ruct
{
match
get
(
fty
)
.st
y
{
ty_fn
(
_
)
=>
true
,
ty_fn
(
_
)
=>
true
,
_
=>
false
_
=>
false
}
}
}
}
fn
ty_region
(
ty
:
t
)
->
region
{
fn
ty_region
(
ty
:
t
)
->
region
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_rptr
(
r
,
_
)
=>
r
,
ty_rptr
(
r
,
_
)
=>
r
,
s
=>
fail
fmt!
(
"ty_region() invoked on non-rptr: %?"
,
s
)
s
=>
fail
fmt!
(
"ty_region() invoked on non-rptr: %?"
,
s
)
}
}
...
@@ -2775,14 +2775,14 @@ fn is_pred_ty(fty: t) -> bool {
...
@@ -2775,14 +2775,14 @@ fn is_pred_ty(fty: t) -> bool {
/*
/*
fn ty_var_id(typ: t) -> TyVid {
fn ty_var_id(typ: t) -> TyVid {
match get(typ).st
ruct
{
match get(typ).st
y
{
ty_infer(TyVar(vid)) => return vid,
ty_infer(TyVar(vid)) => return vid,
_ => { error!("ty_var_id called on non-var ty"); fail; }
_ => { error!("ty_var_id called on non-var ty"); fail; }
}
}
}
}
fn int_var_id(typ: t) -> IntVid {
fn int_var_id(typ: t) -> IntVid {
match get(typ).st
ruct
{
match get(typ).st
y
{
ty_infer(IntVar(vid)) => return vid,
ty_infer(IntVar(vid)) => return vid,
_ => { error!("ty_var_integral_id called on ty other than \
_ => { error!("ty_var_integral_id called on ty other than \
ty_var_integral");
ty_var_integral");
...
@@ -3036,7 +3036,7 @@ fn get_field(tcx: ctxt, rec_ty: t, id: ast::ident) -> field {
...
@@ -3036,7 +3036,7 @@ fn get_field(tcx: ctxt, rec_ty: t, id: ast::ident) -> field {
}
}
fn
get_fields
(
rec_ty
:
t
)
->
~
[
field
]
{
fn
get_fields
(
rec_ty
:
t
)
->
~
[
field
]
{
match
get
(
rec_ty
)
.st
ruct
{
match
get
(
rec_ty
)
.st
y
{
ty_rec
(
fields
)
=>
fields
,
ty_rec
(
fields
)
=>
fields
,
// Can we check at the caller?
// Can we check at the caller?
_
=>
fail
~
"get_fields: not a record type"
_
=>
fail
~
"get_fields: not a record type"
...
@@ -3055,7 +3055,7 @@ fn method_idx(id: ast::ident, meths: &[method]) -> Option<uint> {
...
@@ -3055,7 +3055,7 @@ fn method_idx(id: ast::ident, meths: &[method]) -> Option<uint> {
fn
param_tys_in_type
(
ty
:
t
)
->
~
[
param_ty
]
{
fn
param_tys_in_type
(
ty
:
t
)
->
~
[
param_ty
]
{
let
mut
rslt
=
~
[];
let
mut
rslt
=
~
[];
do
walk_ty
(
ty
)
|
ty
|
{
do
walk_ty
(
ty
)
|
ty
|
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_param
(
p
)
=>
{
ty_param
(
p
)
=>
{
vec
::
push
(
rslt
,
p
);
vec
::
push
(
rslt
,
p
);
}
}
...
@@ -3072,7 +3072,7 @@ fn occurs_check(tcx: ctxt, sp: span, vid: TyVid, rt: t) {
...
@@ -3072,7 +3072,7 @@ fn occurs_check(tcx: ctxt, sp: span, vid: TyVid, rt: t) {
fn
vars_in_type
(
ty
:
t
)
->
~
[
TyVid
]
{
fn
vars_in_type
(
ty
:
t
)
->
~
[
TyVid
]
{
let
mut
rslt
=
~
[];
let
mut
rslt
=
~
[];
do
walk_ty
(
ty
)
|
ty
|
{
do
walk_ty
(
ty
)
|
ty
|
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_infer
(
TyVar
(
v
))
=>
vec
::
push
(
rslt
,
v
),
ty_infer
(
TyVar
(
v
))
=>
vec
::
push
(
rslt
,
v
),
_
=>
()
_
=>
()
}
}
...
@@ -3170,7 +3170,7 @@ fn set_default_mode(cx: ctxt, m: ast::mode, m_def: ast::rmode) {
...
@@ -3170,7 +3170,7 @@ fn set_default_mode(cx: ctxt, m: ast::mode, m_def: ast::rmode) {
}
}
fn
ty_sort_str
(
cx
:
ctxt
,
t
:
t
)
->
~
str
{
fn
ty_sort_str
(
cx
:
ctxt
,
t
:
t
)
->
~
str
{
match
get
(
t
)
.st
ruct
{
match
get
(
t
)
.st
y
{
ty_nil
|
ty_bot
|
ty_bool
|
ty_int
(
_
)
|
ty_nil
|
ty_bot
|
ty_bool
|
ty_int
(
_
)
|
ty_uint
(
_
)
|
ty_float
(
_
)
|
ty_estr
(
_
)
|
ty_uint
(
_
)
|
ty_float
(
_
)
|
ty_estr
(
_
)
|
ty_type
|
ty_opaque_box
|
ty_opaque_closure_ptr
(
_
)
=>
{
ty_type
|
ty_opaque_box
|
ty_opaque_closure_ptr
(
_
)
=>
{
...
@@ -3405,7 +3405,7 @@ fn impl_traits(cx: ctxt, id: ast::def_id) -> ~[t] {
...
@@ -3405,7 +3405,7 @@ fn impl_traits(cx: ctxt, id: ast::def_id) -> ~[t] {
}
}
fn
ty_to_def_id
(
ty
:
t
)
->
Option
<
ast
::
def_id
>
{
fn
ty_to_def_id
(
ty
:
t
)
->
Option
<
ast
::
def_id
>
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_trait
(
id
,
_
,
_
)
|
ty_class
(
id
,
_
)
|
ty_enum
(
id
,
_
)
=>
Some
(
id
),
ty_trait
(
id
,
_
,
_
)
|
ty_class
(
id
,
_
)
|
ty_enum
(
id
,
_
)
=>
Some
(
id
),
_
=>
None
_
=>
None
}
}
...
@@ -3512,7 +3512,7 @@ fn enum_is_univariant(cx: ctxt, id: ast::def_id) -> bool {
...
@@ -3512,7 +3512,7 @@ fn enum_is_univariant(cx: ctxt, id: ast::def_id) -> bool {
}
}
fn
type_is_empty
(
cx
:
ctxt
,
t
:
t
)
->
bool
{
fn
type_is_empty
(
cx
:
ctxt
,
t
:
t
)
->
bool
{
match
ty
::
get
(
t
)
.st
ruct
{
match
ty
::
get
(
t
)
.st
y
{
ty_enum
(
did
,
_
)
=>
(
*
enum_variants
(
cx
,
did
))
.is_empty
(),
ty_enum
(
did
,
_
)
=>
(
*
enum_variants
(
cx
,
did
))
.is_empty
(),
_
=>
false
_
=>
false
}
}
...
@@ -3816,7 +3816,7 @@ fn opcat(op: ast::binop) -> int {
...
@@ -3816,7 +3816,7 @@ fn opcat(op: ast::binop) -> int {
}
}
fn
tycat
(
ty
:
t
)
->
int
{
fn
tycat
(
ty
:
t
)
->
int
{
match
get
(
ty
)
.st
ruct
{
match
get
(
ty
)
.st
y
{
ty_bool
=>
tycat_bool
,
ty_bool
=>
tycat_bool
,
ty_int
(
_
)
|
ty_uint
(
_
)
|
ty_infer
(
IntVar
(
_
))
=>
tycat_int
,
ty_int
(
_
)
|
ty_uint
(
_
)
|
ty_infer
(
IntVar
(
_
))
=>
tycat_int
,
ty_float
(
_
)
=>
tycat_float
,
ty_float
(
_
)
=>
tycat_float
,
...
@@ -3866,7 +3866,7 @@ fn normalize_vstore(vstore: vstore) -> vstore {
...
@@ -3866,7 +3866,7 @@ fn normalize_vstore(vstore: vstore) -> vstore {
None
=>
()
None
=>
()
}
}
let
t
=
match
get
(
t
)
.st
ruct
{
let
t
=
match
get
(
t
)
.st
y
{
ty_evec
(
mt
,
vstore
)
=>
ty_evec
(
mt
,
vstore
)
=>
// This type has a vstore. Get rid of it
// This type has a vstore. Get rid of it
mk_evec
(
cx
,
normalize_mt
(
cx
,
mt
),
normalize_vstore
(
vstore
)),
mk_evec
(
cx
,
normalize_mt
(
cx
,
mt
),
normalize_vstore
(
vstore
)),
...
@@ -3917,7 +3917,7 @@ fn normalize_vstore(vstore: vstore) -> vstore {
...
@@ -3917,7 +3917,7 @@ fn normalize_vstore(vstore: vstore) -> vstore {
// types, which isn't necessary after #2187
// types, which isn't necessary after #2187
let
t
=
mk_t
(
cx
,
mach_sty
(
cx
.sess.targ_cfg
,
t
));
let
t
=
mk_t
(
cx
,
mach_sty
(
cx
.sess.targ_cfg
,
t
));
let
sty
=
fold_sty
(
&
get
(
t
)
.st
ruct
,
|
t
|
{
normalize_ty
(
cx
,
t
)
});
let
sty
=
fold_sty
(
&
get
(
t
)
.st
y
,
|
t
|
{
normalize_ty
(
cx
,
t
)
});
let
t_norm
=
mk_t
(
cx
,
sty
);
let
t_norm
=
mk_t
(
cx
,
sty
);
cx
.normalized_cache
.insert
(
t
,
t_norm
);
cx
.normalized_cache
.insert
(
t
,
t_norm
);
return
t_norm
;
return
t_norm
;
...
...
src/rustc/middle/typeck.rs
浏览文件 @
27cc0a36
...
@@ -261,10 +261,10 @@ fn require_same_types(
...
@@ -261,10 +261,10 @@ fn require_same_types(
}
}
fn
arg_is_argv_ty
(
_
tcx
:
ty
::
ctxt
,
a
:
ty
::
arg
)
->
bool
{
fn
arg_is_argv_ty
(
_
tcx
:
ty
::
ctxt
,
a
:
ty
::
arg
)
->
bool
{
match
ty
::
get
(
a
.ty
)
.st
ruct
{
match
ty
::
get
(
a
.ty
)
.st
y
{
ty
::
ty_evec
(
mt
,
vstore_uniq
)
=>
{
ty
::
ty_evec
(
mt
,
vstore_uniq
)
=>
{
if
mt
.mutbl
!=
ast
::
m_imm
{
return
false
;
}
if
mt
.mutbl
!=
ast
::
m_imm
{
return
false
;
}
match
ty
::
get
(
mt
.ty
)
.st
ruct
{
match
ty
::
get
(
mt
.ty
)
.st
y
{
ty
::
ty_estr
(
vstore_uniq
)
=>
return
true
,
ty
::
ty_estr
(
vstore_uniq
)
=>
return
true
,
_
=>
return
false
_
=>
return
false
}
}
...
@@ -279,7 +279,7 @@ fn check_main_fn_ty(ccx: @crate_ctxt,
...
@@ -279,7 +279,7 @@ fn check_main_fn_ty(ccx: @crate_ctxt,
let
tcx
=
ccx
.tcx
;
let
tcx
=
ccx
.tcx
;
let
main_t
=
ty
::
node_id_to_type
(
tcx
,
main_id
);
let
main_t
=
ty
::
node_id_to_type
(
tcx
,
main_id
);
match
ty
::
get
(
main_t
)
.st
ruct
{
match
ty
::
get
(
main_t
)
.st
y
{
ty
::
ty_fn
(
fn_ty
)
=>
{
ty
::
ty_fn
(
fn_ty
)
=>
{
match
tcx
.items
.find
(
main_id
)
{
match
tcx
.items
.find
(
main_id
)
{
Some
(
ast_map
::
node_item
(
it
,
_
))
=>
{
Some
(
ast_map
::
node_item
(
it
,
_
))
=>
{
...
...
src/rustc/middle/typeck/astconv.rs
浏览文件 @
27cc0a36
...
@@ -185,7 +185,7 @@ fn mk_maybe_vstore<AC: ast_conv, RS: region_scope Copy Owned>(
...
@@ -185,7 +185,7 @@ fn mk_maybe_vstore<AC: ast_conv, RS: region_scope Copy Owned>(
Some
(
ast
::
def_ty
(
type_def_id
))
=>
{
Some
(
ast
::
def_ty
(
type_def_id
))
=>
{
let
result
=
ast_path_to_substs_and_ty
(
self
,
rscope
,
let
result
=
ast_path_to_substs_and_ty
(
self
,
rscope
,
type_def_id
,
path
);
type_def_id
,
path
);
match
ty
::
get
(
result
.ty
)
.st
ruct
{
match
ty
::
get
(
result
.ty
)
.st
y
{
ty
::
ty_trait
(
trait_def_id
,
substs
,
_
)
=>
{
ty
::
ty_trait
(
trait_def_id
,
substs
,
_
)
=>
{
if
vst
!=
ty
::
vstore_box
{
if
vst
!=
ty
::
vstore_box
{
tcx
.sess
.span_unimpl
(
path
.span
,
tcx
.sess
.span_unimpl
(
path
.span
,
...
@@ -419,7 +419,7 @@ fn ty_of_arg<AC: ast_conv, RS: region_scope Copy Owned>(
...
@@ -419,7 +419,7 @@ fn ty_of_arg<AC: ast_conv, RS: region_scope Copy Owned>(
found
:
a
.mode
}))
found
:
a
.mode
}))
}
}
ast
::
infer
(
_
)
=>
{
ast
::
infer
(
_
)
=>
{
match
ty
::
get
(
ty
)
.st
ruct
{
match
ty
::
get
(
ty
)
.st
y
{
// If the type is not specified, then this must be a fn expr.
// If the type is not specified, then this must be a fn expr.
// Leave the mode as infer(_), it will get inferred based
// Leave the mode as infer(_), it will get inferred based
// on constraints elsewhere.
// on constraints elsewhere.
...
...
src/rustc/middle/typeck/check.rs
浏览文件 @
27cc0a36
...
@@ -201,7 +201,7 @@ fn check_bare_fn(ccx: @crate_ctxt,
...
@@ -201,7 +201,7 @@ fn check_bare_fn(ccx: @crate_ctxt,
id
:
ast
::
node_id
,
id
:
ast
::
node_id
,
self_info
:
Option
<
self_info
>
)
{
self_info
:
Option
<
self_info
>
)
{
let
fty
=
ty
::
node_id_to_type
(
ccx
.tcx
,
id
);
let
fty
=
ty
::
node_id_to_type
(
ccx
.tcx
,
id
);
match
ty
::
get
(
fty
)
.st
ruct
{
match
ty
::
get
(
fty
)
.st
y
{
ty
::
ty_fn
(
ref
fn_ty
)
=>
{
ty
::
ty_fn
(
ref
fn_ty
)
=>
{
check_fn
(
ccx
,
self_info
,
fn_ty
,
decl
,
body
,
false
,
None
)
check_fn
(
ccx
,
self_info
,
fn_ty
,
decl
,
body
,
false
,
None
)
}
}
...
@@ -763,7 +763,7 @@ fn do_autoderef(fcx: @fn_ctxt, sp: span, t: ty::t) -> ty::t {
...
@@ -763,7 +763,7 @@ fn do_autoderef(fcx: @fn_ctxt, sp: span, t: ty::t) -> ty::t {
match
sty
{
match
sty
{
ty
::
ty_box
(
inner
)
|
ty
::
ty_uniq
(
inner
)
|
ty
::
ty_box
(
inner
)
|
ty
::
ty_uniq
(
inner
)
|
ty
::
ty_rptr
(
_
,
inner
)
=>
{
ty
::
ty_rptr
(
_
,
inner
)
=>
{
match
ty
::
get
(
t1
)
.st
ruct
{
match
ty
::
get
(
t1
)
.st
y
{
ty
::
ty_infer
(
ty
::
TyVar
(
v1
))
=>
{
ty
::
ty_infer
(
ty
::
TyVar
(
v1
))
=>
{
ty
::
occurs_check
(
fcx
.ccx.tcx
,
sp
,
v1
,
ty
::
occurs_check
(
fcx
.ccx.tcx
,
sp
,
v1
,
ty
::
mk_box
(
fcx
.ccx.tcx
,
inner
));
ty
::
mk_box
(
fcx
.ccx.tcx
,
inner
));
...
@@ -1127,7 +1127,7 @@ fn check_binop(fcx: @fn_ctxt, expr: @ast::expr,
...
@@ -1127,7 +1127,7 @@ fn check_binop(fcx: @fn_ctxt, expr: @ast::expr,
}
}
let
lhs_t
=
structurally_resolved_type
(
fcx
,
lhs
.span
,
lhs_t
);
let
lhs_t
=
structurally_resolved_type
(
fcx
,
lhs
.span
,
lhs_t
);
return
match
(
op
,
ty
::
get
(
lhs_t
)
.st
ruct
)
{
return
match
(
op
,
ty
::
get
(
lhs_t
)
.st
y
)
{
(
_
,
_
)
if
ty
::
type_is_integral
(
lhs_t
)
&&
(
_
,
_
)
if
ty
::
type_is_integral
(
lhs_t
)
&&
ast_util
::
is_shift_binop
(
op
)
=>
{
ast_util
::
is_shift_binop
(
op
)
=>
{
// Shift is a special case: rhs can be any integral type
// Shift is a special case: rhs can be any integral type
...
@@ -1191,7 +1191,7 @@ fn check_user_binop(fcx: @fn_ctxt, ex: @ast::expr,
...
@@ -1191,7 +1191,7 @@ fn check_user_binop(fcx: @fn_ctxt, ex: @ast::expr,
// If the or operator is used it might be that the user forgot to
// If the or operator is used it might be that the user forgot to
// supply the do keyword. Let's be more helpful in that situation.
// supply the do keyword. Let's be more helpful in that situation.
if
op
==
ast
::
or
{
if
op
==
ast
::
or
{
match
ty
::
get
(
lhs_resolved_t
)
.st
ruct
{
match
ty
::
get
(
lhs_resolved_t
)
.st
y
{
ty
::
ty_fn
(
_
)
=>
{
ty
::
ty_fn
(
_
)
=>
{
tcx
.sess
.span_note
(
tcx
.sess
.span_note
(
ex
.span
,
~
"did you forget the 'do' keyword for the call?"
);
ex
.span
,
~
"did you forget the 'do' keyword for the call?"
);
...
@@ -1227,7 +1227,7 @@ fn unpack_expected<O: Copy>(fcx: @fn_ctxt, expected: Option<ty::t>,
...
@@ -1227,7 +1227,7 @@ fn unpack_expected<O: Copy>(fcx: @fn_ctxt, expected: Option<ty::t>,
match
expected
{
match
expected
{
Some
(
t
)
=>
{
Some
(
t
)
=>
{
match
resolve_type
(
fcx
.infcx
(),
t
,
force_tvar
)
{
match
resolve_type
(
fcx
.infcx
(),
t
,
force_tvar
)
{
Ok
(
t
)
=>
unpack
(
ty
::
get
(
t
)
.st
ruct
),
Ok
(
t
)
=>
unpack
(
ty
::
get
(
t
)
.st
y
),
_
=>
None
_
=>
None
}
}
}
}
...
@@ -1500,7 +1500,7 @@ fn check_field(fcx: @fn_ctxt, expr: @ast::expr, is_callee: bool,
...
@@ -1500,7 +1500,7 @@ fn check_field(fcx: @fn_ctxt, expr: @ast::expr, is_callee: bool,
ast
::
not
=>
{
ast
::
not
=>
{
oprnd_t
=
structurally_resolved_type
(
fcx
,
oprnd
.span
,
oprnd_t
);
oprnd_t
=
structurally_resolved_type
(
fcx
,
oprnd
.span
,
oprnd_t
);
if
!
(
ty
::
type_is_integral
(
oprnd_t
)
||
if
!
(
ty
::
type_is_integral
(
oprnd_t
)
||
ty
::
get
(
oprnd_t
)
.st
ruct
==
ty
::
ty_bool
)
{
ty
::
get
(
oprnd_t
)
.st
y
==
ty
::
ty_bool
)
{
oprnd_t
=
check_user_unop
(
fcx
,
~
"!"
,
~
"not"
,
expr
,
oprnd_t
=
check_user_unop
(
fcx
,
~
"!"
,
~
"not"
,
expr
,
oprnd
,
oprnd_t
);
oprnd
,
oprnd_t
);
}
}
...
@@ -1678,7 +1678,7 @@ fn check_field(fcx: @fn_ctxt, expr: @ast::expr, is_callee: bool,
...
@@ -1678,7 +1678,7 @@ fn check_field(fcx: @fn_ctxt, expr: @ast::expr, is_callee: bool,
}
}
let
block_ty
=
structurally_resolved_type
(
let
block_ty
=
structurally_resolved_type
(
fcx
,
expr
.span
,
fcx
.node_ty
(
b
.id
));
fcx
,
expr
.span
,
fcx
.node_ty
(
b
.id
));
match
ty
::
get
(
block_ty
)
.st
ruct
{
match
ty
::
get
(
block_ty
)
.st
y
{
ty
::
ty_fn
(
fty
)
=>
{
ty
::
ty_fn
(
fty
)
=>
{
fcx
.write_ty
(
expr
.id
,
ty
::
mk_fn
(
tcx
,
FnTyBase
{
fcx
.write_ty
(
expr
.id
,
ty
::
mk_fn
(
tcx
,
FnTyBase
{
meta
:
fty
.meta
,
meta
:
fty
.meta
,
...
@@ -1714,7 +1714,7 @@ fn check_field(fcx: @fn_ctxt, expr: @ast::expr, is_callee: bool,
...
@@ -1714,7 +1714,7 @@ fn check_field(fcx: @fn_ctxt, expr: @ast::expr, is_callee: bool,
}
}
let
block_ty
=
structurally_resolved_type
(
let
block_ty
=
structurally_resolved_type
(
fcx
,
expr
.span
,
fcx
.node_ty
(
b
.id
));
fcx
,
expr
.span
,
fcx
.node_ty
(
b
.id
));
match
ty
::
get
(
block_ty
)
.st
ruct
{
match
ty
::
get
(
block_ty
)
.st
y
{
ty
::
ty_fn
(
fty
)
=>
{
ty
::
ty_fn
(
fty
)
=>
{
fcx
.write_ty
(
expr
.id
,
ty
::
mk_fn
(
tcx
,
fty
));
fcx
.write_ty
(
expr
.id
,
ty
::
mk_fn
(
tcx
,
fty
));
}
}
...
@@ -1742,7 +1742,7 @@ fn check_field(fcx: @fn_ctxt, expr: @ast::expr, is_callee: bool,
...
@@ -1742,7 +1742,7 @@ fn check_field(fcx: @fn_ctxt, expr: @ast::expr, is_callee: bool,
debug!
(
"t_1=%s"
,
fcx
.infcx
()
.ty_to_str
(
t_1
));
debug!
(
"t_1=%s"
,
fcx
.infcx
()
.ty_to_str
(
t_1
));
debug!
(
"t_e=%s"
,
fcx
.infcx
()
.ty_to_str
(
t_e
));
debug!
(
"t_e=%s"
,
fcx
.infcx
()
.ty_to_str
(
t_e
));
match
ty
::
get
(
t_1
)
.st
ruct
{
match
ty
::
get
(
t_1
)
.st
y
{
// This will be looked up later on
// This will be looked up later on
ty
::
ty_trait
(
*
)
=>
(),
ty
::
ty_trait
(
*
)
=>
(),
...
@@ -2461,7 +2461,7 @@ fn structurally_resolved_type(fcx: @fn_ctxt, sp: span, tp: ty::t) -> ty::t {
...
@@ -2461,7 +2461,7 @@ fn structurally_resolved_type(fcx: @fn_ctxt, sp: span, tp: ty::t) -> ty::t {
// Returns the one-level-deep structure of the given type.
// Returns the one-level-deep structure of the given type.
fn
structure_of
(
fcx
:
@
fn_ctxt
,
sp
:
span
,
typ
:
ty
::
t
)
->
ty
::
sty
{
fn
structure_of
(
fcx
:
@
fn_ctxt
,
sp
:
span
,
typ
:
ty
::
t
)
->
ty
::
sty
{
ty
::
get
(
structurally_resolved_type
(
fcx
,
sp
,
typ
))
.st
ruct
ty
::
get
(
structurally_resolved_type
(
fcx
,
sp
,
typ
))
.st
y
}
}
fn
type_is_integral
(
fcx
:
@
fn_ctxt
,
sp
:
span
,
typ
:
ty
::
t
)
->
bool
{
fn
type_is_integral
(
fcx
:
@
fn_ctxt
,
sp
:
span
,
typ
:
ty
::
t
)
->
bool
{
...
@@ -2511,7 +2511,7 @@ fn check_bounds_are_used(ccx: @crate_ctxt,
...
@@ -2511,7 +2511,7 @@ fn check_bounds_are_used(ccx: @crate_ctxt,
ccx
.tcx
,
ty
,
ccx
.tcx
,
ty
,
|
_
r
|
{},
|
_
r
|
{},
|
t
|
{
|
t
|
{
match
ty
::
get
(
t
)
.st
ruct
{
match
ty
::
get
(
t
)
.st
y
{
ty
::
ty_param
({
idx
,
_
})
=>
{
tps_used
[
idx
]
=
true
;
}
ty
::
ty_param
({
idx
,
_
})
=>
{
tps_used
[
idx
]
=
true
;
}
_
=>
()
_
=>
()
}
}
...
...
src/rustc/middle/typeck/check/method.rs
浏览文件 @
27cc0a36
...
@@ -114,7 +114,7 @@ fn method() -> Option<method_map_entry> {
...
@@ -114,7 +114,7 @@ fn method() -> Option<method_map_entry> {
debug!
(
"method lookup(m_name=%s, self_ty=%s, %?)"
,
debug!
(
"method lookup(m_name=%s, self_ty=%s, %?)"
,
self
.fcx
.tcx
()
.sess
.str_of
(
self
.m_name
),
self
.fcx
.tcx
()
.sess
.str_of
(
self
.m_name
),
self
.fcx
.infcx
()
.ty_to_str
(
self
.self_ty
),
self
.fcx
.infcx
()
.ty_to_str
(
self
.self_ty
),
ty
::
get
(
self
.self_ty
)
.st
ruct
);
ty
::
get
(
self
.self_ty
)
.st
y
);
// Determine if there are any inherent methods we can call.
// Determine if there are any inherent methods we can call.
// (An inherent method is one that belongs to no trait, but is
// (An inherent method is one that belongs to no trait, but is
...
@@ -155,7 +155,7 @@ fn method() -> Option<method_map_entry> {
...
@@ -155,7 +155,7 @@ fn method() -> Option<method_map_entry> {
// autoderef.
// autoderef.
// Try each of the possible matching semantics in turn.
// Try each of the possible matching semantics in turn.
for
matching_modes
.each
|
mode
|
{
for
matching_modes
.each
|
mode
|
{
match
ty
::
get
(
self
.self_ty
)
.st
ruct
{
match
ty
::
get
(
self
.self_ty
)
.st
y
{
ty
::
ty_box
(
mt
)
|
ty
::
ty_uniq
(
mt
)
|
ty
::
ty_rptr
(
_
,
mt
)
=>
{
ty
::
ty_box
(
mt
)
|
ty
::
ty_uniq
(
mt
)
|
ty
::
ty_rptr
(
_
,
mt
)
=>
{
self
.add_candidates_from_type
(
mt
.ty
,
mode
);
self
.add_candidates_from_type
(
mt
.ty
,
mode
);
}
}
...
@@ -260,7 +260,7 @@ fn report_trait_candidate(idx: uint, did: ast::def_id) {
...
@@ -260,7 +260,7 @@ fn report_trait_candidate(idx: uint, did: ast::def_id) {
}
}
fn
add_candidates_from_type
(
inner_ty
:
ty
::
t
,
mode
:
method_lookup_mode
)
{
fn
add_candidates_from_type
(
inner_ty
:
ty
::
t
,
mode
:
method_lookup_mode
)
{
match
ty
::
get
(
inner_ty
)
.st
ruct
{
match
ty
::
get
(
inner_ty
)
.st
y
{
// First, see whether this is a bounded parameter.
// First, see whether this is a bounded parameter.
ty
::
ty_param
(
p
)
=>
{
ty
::
ty_param
(
p
)
=>
{
self
.add_candidates_from_param
(
inner_ty
,
mode
,
p
.idx
,
p
.def_id
);
self
.add_candidates_from_param
(
inner_ty
,
mode
,
p
.idx
,
p
.def_id
);
...
@@ -304,7 +304,7 @@ fn add_candidates_from_param(inner_ty: ty::t, mode: method_lookup_mode,
...
@@ -304,7 +304,7 @@ fn add_candidates_from_param(inner_ty: ty::t, mode: method_lookup_mode,
loop
;
/* ok */
loop
;
/* ok */
}
}
ty
::
bound_trait
(
bound_t
)
=>
{
ty
::
bound_trait
(
bound_t
)
=>
{
match
ty
::
get
(
bound_t
)
.st
ruct
{
match
ty
::
get
(
bound_t
)
.st
y
{
ty
::
ty_trait
(
i
,
substs
,
_
)
=>
(
i
,
substs
),
ty
::
ty_trait
(
i
,
substs
,
_
)
=>
(
i
,
substs
),
_
=>
fail
~
"add_candidates_from_param: non-trait bound"
_
=>
fail
~
"add_candidates_from_param: non-trait bound"
}
}
...
@@ -413,7 +413,7 @@ fn add_candidates_from_class(inner_ty: ty::t,
...
@@ -413,7 +413,7 @@ fn add_candidates_from_class(inner_ty: ty::t,
}
}
fn
ty_from_did
(
did
:
ast
::
def_id
)
->
ty
::
t
{
fn
ty_from_did
(
did
:
ast
::
def_id
)
->
ty
::
t
{
match
ty
::
get
(
ty
::
lookup_item_type
(
self
.tcx
(),
did
)
.ty
)
.st
ruct
{
match
ty
::
get
(
ty
::
lookup_item_type
(
self
.tcx
(),
did
)
.ty
)
.st
y
{
ty
::
ty_fn
(
ref
fty
)
=>
{
ty
::
ty_fn
(
ref
fty
)
=>
{
ty
::
mk_fn
(
self
.tcx
(),
FnTyBase
{
ty
::
mk_fn
(
self
.tcx
(),
FnTyBase
{
meta
:
FnMeta
{
proto
:
ty
::
proto_vstore
(
ty
::
vstore_box
),
meta
:
FnMeta
{
proto
:
ty
::
proto_vstore
(
ty
::
vstore_box
),
...
@@ -434,7 +434,7 @@ fn ty_from_did(did: ast::def_id) -> ty::t {
...
@@ -434,7 +434,7 @@ fn ty_from_did(did: ast::def_id) -> ty::t {
}
}
} else {
} else {
match check ty::get(csearch::get_type(self.tcx(), did).ty)
match check ty::get(csearch::get_type(self.tcx(), did).ty)
.st
ruct
{
.st
y
{
ty::ty_fn(fty) {
ty::ty_fn(fty) {
ty::mk_fn(self.tcx(), {proto: ast::proto_box with fty})
ty::mk_fn(self.tcx(), {proto: ast::proto_box with fty})
...
...
src/rustc/middle/typeck/check/regionck.rs
浏览文件 @
27cc0a36
...
@@ -189,7 +189,7 @@ fn visit_expr(e: @ast::expr, &&rcx: @rcx, v: rvt) {
...
@@ -189,7 +189,7 @@ fn visit_expr(e: @ast::expr, &&rcx: @rcx, v: rvt) {
match
rcx
.resolve_node_type
(
e
.id
)
{
match
rcx
.resolve_node_type
(
e
.id
)
{
result
::
Err
(
_
)
=>
{
return
;
/* typeck will fail anyhow */
}
result
::
Err
(
_
)
=>
{
return
;
/* typeck will fail anyhow */
}
result
::
Ok
(
target_ty
)
=>
{
result
::
Ok
(
target_ty
)
=>
{
match
ty
::
get
(
target_ty
)
.st
ruct
{
match
ty
::
get
(
target_ty
)
.st
y
{
ty
::
ty_trait
(
_
,
substs
,
_
)
=>
{
ty
::
ty_trait
(
_
,
substs
,
_
)
=>
{
let
trait_region
=
match
substs
.self_r
{
let
trait_region
=
match
substs
.self_r
{
Some
(
r
)
=>
{
r
}
Some
(
r
)
=>
{
r
}
...
@@ -215,7 +215,7 @@ fn visit_expr(e: @ast::expr, &&rcx: @rcx, v: rvt) {
...
@@ -215,7 +215,7 @@ fn visit_expr(e: @ast::expr, &&rcx: @rcx, v: rvt) {
match
rcx
.resolve_node_type
(
e
.id
)
{
match
rcx
.resolve_node_type
(
e
.id
)
{
result
::
Err
(
_
)
=>
return
,
// Typechecking will fail anyhow.
result
::
Err
(
_
)
=>
return
,
// Typechecking will fail anyhow.
result
::
Ok
(
function_type
)
=>
{
result
::
Ok
(
function_type
)
=>
{
match
ty
::
get
(
function_type
)
.st
ruct
{
match
ty
::
get
(
function_type
)
.st
y
{
ty
::
ty_fn
(
ref
fn_ty
)
=>
{
ty
::
ty_fn
(
ref
fn_ty
)
=>
{
match
fn_ty
.meta.proto
{
match
fn_ty
.meta.proto
{
proto_vstore
(
vstore_slice
(
region
))
=>
{
proto_vstore
(
vstore_slice
(
region
))
=>
{
...
...
src/rustc/middle/typeck/check/regionmanip.rs
浏览文件 @
27cc0a36
...
@@ -66,7 +66,7 @@ fn replace_bound_regions_in_fn_ty(
...
@@ -66,7 +66,7 @@ fn replace_bound_regions_in_fn_ty(
return
{
isr
:
isr
,
return
{
isr
:
isr
,
self_info
:
new_self_info
,
self_info
:
new_self_info
,
fn_ty
:
match
ty
::
get
(
t_fn
)
.st
ruct
{
ty
::
ty_fn
(
o
)
=>
o
,
fn_ty
:
match
ty
::
get
(
t_fn
)
.st
y
{
ty
::
ty_fn
(
o
)
=>
o
,
_
=>
tcx
.sess
.bug
(
~
"replace_bound_regions_in_fn_ty: impossible"
)}};
_
=>
tcx
.sess
.bug
(
~
"replace_bound_regions_in_fn_ty: impossible"
)}};
...
...
src/rustc/middle/typeck/check/vtable.rs
浏览文件 @
27cc0a36
...
@@ -69,7 +69,7 @@ fn fixup_substs(fcx: @fn_ctxt, expr: @ast::expr,
...
@@ -69,7 +69,7 @@ fn fixup_substs(fcx: @fn_ctxt, expr: @ast::expr,
// use a dummy type just to package up the substs that need fixing up
// use a dummy type just to package up the substs that need fixing up
let
t
=
ty
::
mk_trait
(
tcx
,
id
,
substs
,
ty
::
vstore_slice
(
ty
::
re_static
));
let
t
=
ty
::
mk_trait
(
tcx
,
id
,
substs
,
ty
::
vstore_slice
(
ty
::
re_static
));
do
fixup_ty
(
fcx
,
expr
,
t
,
is_early
)
.map
|
t_f
|
{
do
fixup_ty
(
fcx
,
expr
,
t
,
is_early
)
.map
|
t_f
|
{
match
ty
::
get
(
t_f
)
.st
ruct
{
match
ty
::
get
(
t_f
)
.st
y
{
ty
::
ty_trait
(
_
,
substs_f
,
_
)
=>
substs_f
,
ty
::
ty_trait
(
_
,
substs_f
,
_
)
=>
substs_f
,
_
=>
fail
~
"t_f should be a trait"
_
=>
fail
~
"t_f should be a trait"
}
}
...
@@ -99,7 +99,7 @@ fn lookup_vtable(fcx: @fn_ctxt,
...
@@ -99,7 +99,7 @@ fn lookup_vtable(fcx: @fn_ctxt,
let
_
i
=
indenter
();
let
_
i
=
indenter
();
let
tcx
=
fcx
.ccx.tcx
;
let
tcx
=
fcx
.ccx.tcx
;
let
(
trait_id
,
trait_substs
)
=
match
ty
::
get
(
trait_ty
)
.st
ruct
{
let
(
trait_id
,
trait_substs
)
=
match
ty
::
get
(
trait_ty
)
.st
y
{
ty
::
ty_trait
(
did
,
substs
,
_
)
=>
(
did
,
substs
),
ty
::
ty_trait
(
did
,
substs
,
_
)
=>
(
did
,
substs
),
_
=>
tcx
.sess
.impossible_case
(
expr
.span
,
_
=>
tcx
.sess
.impossible_case
(
expr
.span
,
"lookup_vtable:
\
"lookup_vtable:
\
...
@@ -117,7 +117,7 @@ fn lookup_vtable(fcx: @fn_ctxt,
...
@@ -117,7 +117,7 @@ fn lookup_vtable(fcx: @fn_ctxt,
}
}
};
};
match
ty
::
get
(
ty
)
.st
ruct
{
match
ty
::
get
(
ty
)
.st
y
{
ty
::
ty_param
({
idx
:
n
,
def_id
:
did
})
=>
{
ty
::
ty_param
({
idx
:
n
,
def_id
:
did
})
=>
{
let
mut
n_bound
=
0
;
let
mut
n_bound
=
0
;
for
vec
::
each
(
*
tcx
.ty_param_bounds
.get
(
did
.node
))
|
bound
|
{
for
vec
::
each
(
*
tcx
.ty_param_bounds
.get
(
did
.node
))
|
bound
|
{
...
@@ -127,7 +127,7 @@ fn lookup_vtable(fcx: @fn_ctxt,
...
@@ -127,7 +127,7 @@ fn lookup_vtable(fcx: @fn_ctxt,
/* ignore */
/* ignore */
}
}
ty
::
bound_trait
(
ity
)
=>
{
ty
::
bound_trait
(
ity
)
=>
{
match
ty
::
get
(
ity
)
.st
ruct
{
match
ty
::
get
(
ity
)
.st
y
{
ty
::
ty_trait
(
idid
,
_
,
_
)
=>
{
ty
::
ty_trait
(
idid
,
_
,
_
)
=>
{
if
trait_id
==
idid
{
if
trait_id
==
idid
{
debug!
(
"(checking vtable) @0 relating
\
debug!
(
"(checking vtable) @0 relating
\
...
@@ -214,7 +214,7 @@ fn lookup_vtable(fcx: @fn_ctxt,
...
@@ -214,7 +214,7 @@ fn lookup_vtable(fcx: @fn_ctxt,
// unify it with trait_ty in order to get all
// unify it with trait_ty in order to get all
// the ty vars sorted out.
// the ty vars sorted out.
for
vec
::
each
(
ty
::
impl_traits
(
tcx
,
im
.did
))
|
of_ty
|
{
for
vec
::
each
(
ty
::
impl_traits
(
tcx
,
im
.did
))
|
of_ty
|
{
match
ty
::
get
(
of_ty
)
.st
ruct
{
match
ty
::
get
(
of_ty
)
.st
y
{
ty
::
ty_trait
(
id
,
_
,
_
)
=>
{
ty
::
ty_trait
(
id
,
_
,
_
)
=>
{
// Not the trait we're looking for
// Not the trait we're looking for
if
id
!=
trait_id
{
loop
;
}
if
id
!=
trait_id
{
loop
;
}
...
@@ -389,8 +389,8 @@ fn connect_trait_tps(fcx: @fn_ctxt, expr: @ast::expr, impl_tys: ~[ty::t],
...
@@ -389,8 +389,8 @@ fn connect_trait_tps(fcx: @fn_ctxt, expr: @ast::expr, impl_tys: ~[ty::t],
let
ity
=
ty
::
impl_traits
(
tcx
,
impl_did
)[
0
];
let
ity
=
ty
::
impl_traits
(
tcx
,
impl_did
)[
0
];
let
trait_ty
=
ty
::
subst_tps
(
tcx
,
impl_tys
,
ity
);
let
trait_ty
=
ty
::
subst_tps
(
tcx
,
impl_tys
,
ity
);
debug!
(
"(connect trait tps) trait type is %?, impl did is %?"
,
debug!
(
"(connect trait tps) trait type is %?, impl did is %?"
,
ty
::
get
(
trait_ty
)
.st
ruct
,
impl_did
);
ty
::
get
(
trait_ty
)
.st
y
,
impl_did
);
match
ty
::
get
(
trait_ty
)
.st
ruct
{
match
ty
::
get
(
trait_ty
)
.st
y
{
ty
::
ty_trait
(
_
,
substs
,
_
)
=>
{
ty
::
ty_trait
(
_
,
substs
,
_
)
=>
{
vec
::
iter2
(
substs
.tps
,
trait_tys
,
vec
::
iter2
(
substs
.tps
,
trait_tys
,
|
a
,
b
|
demand
::
suptype
(
fcx
,
expr
.span
,
a
,
b
));
|
a
,
b
|
demand
::
suptype
(
fcx
,
expr
.span
,
a
,
b
));
...
@@ -450,7 +450,7 @@ fn early_resolve_expr(ex: @ast::expr, &&fcx: @fn_ctxt, is_early: bool) {
...
@@ -450,7 +450,7 @@ fn early_resolve_expr(ex: @ast::expr, &&fcx: @fn_ctxt, is_early: bool) {
}
}
ast
::
expr_cast
(
src
,
_
)
=>
{
ast
::
expr_cast
(
src
,
_
)
=>
{
let
target_ty
=
fcx
.expr_ty
(
ex
);
let
target_ty
=
fcx
.expr_ty
(
ex
);
match
ty
::
get
(
target_ty
)
.st
ruct
{
match
ty
::
get
(
target_ty
)
.st
y
{
ty
::
ty_trait
(
*
)
=>
{
ty
::
ty_trait
(
*
)
=>
{
/*
/*
Look up vtables for the type we're casting to,
Look up vtables for the type we're casting to,
...
...
src/rustc/middle/typeck/coherence.rs
浏览文件 @
27cc0a36
...
@@ -55,7 +55,7 @@ fn get_base_type(inference_context: infer_ctxt, span: span, original_type: t)
...
@@ -55,7 +55,7 @@ fn get_base_type(inference_context: infer_ctxt, span: span, original_type: t)
}
}
}
}
match
get
(
resolved_type
)
.st
ruct
{
match
get
(
resolved_type
)
.st
y
{
ty_box
(
base_mutability_and_type
)
|
ty_box
(
base_mutability_and_type
)
|
ty_uniq
(
base_mutability_and_type
)
|
ty_uniq
(
base_mutability_and_type
)
|
ty_ptr
(
base_mutability_and_type
)
|
ty_ptr
(
base_mutability_and_type
)
|
...
@@ -76,7 +76,7 @@ fn get_base_type(inference_context: infer_ctxt, span: span, original_type: t)
...
@@ -76,7 +76,7 @@ fn get_base_type(inference_context: infer_ctxt, span: span, original_type: t)
ty_param
(
*
)
|
ty_self
|
ty_type
|
ty_opaque_box
|
ty_param
(
*
)
|
ty_self
|
ty_type
|
ty_opaque_box
|
ty_opaque_closure_ptr
(
*
)
|
ty_unboxed_vec
(
*
)
=>
{
ty_opaque_closure_ptr
(
*
)
|
ty_unboxed_vec
(
*
)
=>
{
debug!
(
"(getting base type) no base type; found %?"
,
debug!
(
"(getting base type) no base type; found %?"
,
get
(
original_type
)
.st
ruct
);
get
(
original_type
)
.st
y
);
None
None
}
}
}
}
...
@@ -93,7 +93,7 @@ fn get_base_type_def_id(inference_context: infer_ctxt,
...
@@ -93,7 +93,7 @@ fn get_base_type_def_id(inference_context: infer_ctxt,
return
None
;
return
None
;
}
}
Some
(
base_type
)
=>
{
Some
(
base_type
)
=>
{
match
get
(
base_type
)
.st
ruct
{
match
get
(
base_type
)
.st
y
{
ty_enum
(
def_id
,
_
)
|
ty_enum
(
def_id
,
_
)
|
ty_class
(
def_id
,
_
)
|
ty_class
(
def_id
,
_
)
|
ty_trait
(
def_id
,
_
,
_
)
=>
{
ty_trait
(
def_id
,
_
,
_
)
=>
{
...
@@ -694,7 +694,7 @@ fn add_impls_for_module(impls_seen: HashMap<def_id,()>,
...
@@ -694,7 +694,7 @@ fn add_impls_for_module(impls_seen: HashMap<def_id,()>,
// Record all the trait methods.
// Record all the trait methods.
for
associated_traits
.each
|
trait_type
|
{
for
associated_traits
.each
|
trait_type
|
{
match
get
(
trait_type
)
.st
ruct
{
match
get
(
trait_type
)
.st
y
{
ty_trait
(
trait_id
,
_
,
_
)
=>
{
ty_trait
(
trait_id
,
_
,
_
)
=>
{
self
.add_trait_method
(
trait_id
,
implementation
);
self
.add_trait_method
(
trait_id
,
implementation
);
}
}
...
...
src/rustc/middle/typeck/collect.rs
浏览文件 @
27cc0a36
...
@@ -603,7 +603,7 @@ fn instantiate_trait_ref(ccx: @crate_ctxt, t: @ast::trait_ref,
...
@@ -603,7 +603,7 @@ fn instantiate_trait_ref(ccx: @crate_ctxt, t: @ast::trait_ref,
ast
::
def_ty
(
t_id
)
=>
{
ast
::
def_ty
(
t_id
)
=>
{
let
tpt
=
astconv
::
ast_path_to_ty
(
ccx
,
rscope
,
t_id
,
t
.path
,
let
tpt
=
astconv
::
ast_path_to_ty
(
ccx
,
rscope
,
t_id
,
t
.path
,
t
.ref_id
);
t
.ref_id
);
match
ty
::
get
(
tpt
.ty
)
.st
ruct
{
match
ty
::
get
(
tpt
.ty
)
.st
y
{
ty
::
ty_trait
(
*
)
=>
{
ty
::
ty_trait
(
*
)
=>
{
(
t_id
,
tpt
)
(
t_id
,
tpt
)
}
}
...
@@ -732,7 +732,7 @@ fn compute_bounds(ccx: @crate_ctxt,
...
@@ -732,7 +732,7 @@ fn compute_bounds(ccx: @crate_ctxt,
ast
::
bound_owned
=>
~
[
ty
::
bound_owned
],
ast
::
bound_owned
=>
~
[
ty
::
bound_owned
],
ast
::
bound_trait
(
t
)
=>
{
ast
::
bound_trait
(
t
)
=>
{
let
ity
=
ast_ty_to_ty
(
ccx
,
empty_rscope
,
t
);
let
ity
=
ast_ty_to_ty
(
ccx
,
empty_rscope
,
t
);
match
ty
::
get
(
ity
)
.st
ruct
{
match
ty
::
get
(
ity
)
.st
y
{
ty
::
ty_trait
(
*
)
=>
{
ty
::
ty_trait
(
*
)
=>
{
~
[
ty
::
bound_trait
(
ity
)]
~
[
ty
::
bound_trait
(
ity
)]
}
}
...
...
src/rustc/middle/typeck/infer/assignment.rs
浏览文件 @
27cc0a36
...
@@ -70,7 +70,7 @@ fn tys(a: ty::t, b: ty::t) -> ares {
...
@@ -70,7 +70,7 @@ fn tys(a: ty::t, b: ty::t) -> ares {
b
.to_str
(
self
.infcx
));
b
.to_str
(
self
.infcx
));
let
_
r
=
indenter
();
let
_
r
=
indenter
();
match
(
ty
::
get
(
a
)
.st
ruct
,
ty
::
get
(
b
)
.struct
)
{
match
(
ty
::
get
(
a
)
.st
y
,
ty
::
get
(
b
)
.sty
)
{
(
ty
::
ty_bot
,
_
)
=>
{
(
ty
::
ty_bot
,
_
)
=>
{
Ok
(
None
)
Ok
(
None
)
}
}
...
@@ -130,7 +130,7 @@ fn is_borrowable(v: ty::vstore) -> bool {
...
@@ -130,7 +130,7 @@ fn is_borrowable(v: ty::vstore) -> bool {
(
Some
(
a_bnd
),
Some
(
b_bnd
))
=>
{
(
Some
(
a_bnd
),
Some
(
b_bnd
))
=>
{
// check for a case where a non-region pointer (@, ~) is
// check for a case where a non-region pointer (@, ~) is
// being assigned to a region pointer:
// being assigned to a region pointer:
match
(
ty
::
get
(
a_bnd
)
.st
ruct
,
ty
::
get
(
b_bnd
)
.struct
)
{
match
(
ty
::
get
(
a_bnd
)
.st
y
,
ty
::
get
(
b_bnd
)
.sty
)
{
(
ty
::
ty_box
(
_
),
ty
::
ty_rptr
(
r_b
,
mt_b
))
=>
{
(
ty
::
ty_box
(
_
),
ty
::
ty_rptr
(
r_b
,
mt_b
))
=>
{
let
nr_b
=
ty
::
mk_box
(
self
.infcx.tcx
,
let
nr_b
=
ty
::
mk_box
(
self
.infcx.tcx
,
{
ty
:
mt_b
.ty
,
mutbl
:
m_const
});
{
ty
:
mt_b
.ty
,
mutbl
:
m_const
});
...
...
src/rustc/middle/typeck/infer/combine.rs
浏览文件 @
27cc0a36
...
@@ -354,7 +354,7 @@ fn super_tys<C:combine>(
...
@@ -354,7 +354,7 @@ fn super_tys<C:combine>(
self
:
&
C
,
a
:
ty
::
t
,
b
:
ty
::
t
)
->
cres
<
ty
::
t
>
{
self
:
&
C
,
a
:
ty
::
t
,
b
:
ty
::
t
)
->
cres
<
ty
::
t
>
{
let
tcx
=
self
.infcx
()
.tcx
;
let
tcx
=
self
.infcx
()
.tcx
;
match
(
ty
::
get
(
a
)
.st
ruct
,
ty
::
get
(
b
)
.struct
)
{
match
(
ty
::
get
(
a
)
.st
y
,
ty
::
get
(
b
)
.sty
)
{
// The "subtype" ought to be handling cases involving bot or var:
// The "subtype" ought to be handling cases involving bot or var:
(
ty
::
ty_bot
,
_
)
|
(
ty
::
ty_bot
,
_
)
|
(
_
,
ty
::
ty_bot
)
|
(
_
,
ty
::
ty_bot
)
|
...
@@ -383,8 +383,8 @@ fn super_tys<C:combine>(
...
@@ -383,8 +383,8 @@ fn super_tys<C:combine>(
(
ty
::
ty_int
(
_
),
_
)
|
(
ty
::
ty_int
(
_
),
_
)
|
(
ty
::
ty_uint
(
_
),
_
)
|
(
ty
::
ty_uint
(
_
),
_
)
|
(
ty
::
ty_float
(
_
),
_
)
=>
{
(
ty
::
ty_float
(
_
),
_
)
=>
{
let
as_
=
ty
::
get
(
a
)
.st
ruct
;
let
as_
=
ty
::
get
(
a
)
.st
y
;
let
bs
=
ty
::
get
(
b
)
.st
ruct
;
let
bs
=
ty
::
get
(
b
)
.st
y
;
if
as_
==
bs
{
if
as_
==
bs
{
Ok
(
a
)
Ok
(
a
)
}
else
{
}
else
{
...
...
src/rustc/middle/typeck/infer/integral.rs
浏览文件 @
27cc0a36
...
@@ -55,7 +55,7 @@ fn single_type_contained_in(tcx: ty::ctxt, a: int_ty_set) ->
...
@@ -55,7 +55,7 @@ fn single_type_contained_in(tcx: ty::ctxt, a: int_ty_set) ->
fn
convert_integral_ty_to_int_ty_set
(
tcx
:
ty
::
ctxt
,
t
:
ty
::
t
)
fn
convert_integral_ty_to_int_ty_set
(
tcx
:
ty
::
ctxt
,
t
:
ty
::
t
)
->
int_ty_set
{
->
int_ty_set
{
match
get
(
t
)
.st
ruct
{
match
get
(
t
)
.st
y
{
ty_int
(
int_ty
)
=>
match
int_ty
{
ty_int
(
int_ty
)
=>
match
int_ty
{
ast
::
ty_i8
=>
int_ty_set
(
INT_TY_SET_i8
),
ast
::
ty_i8
=>
int_ty_set
(
INT_TY_SET_i8
),
ast
::
ty_i16
=>
int_ty_set
(
INT_TY_SET_i16
),
ast
::
ty_i16
=>
int_ty_set
(
INT_TY_SET_i16
),
...
...
src/rustc/middle/typeck/infer/lattice.rs
浏览文件 @
27cc0a36
...
@@ -42,7 +42,7 @@ fn lattice_tys<L:lattice_ops combine>(
...
@@ -42,7 +42,7 @@ fn lattice_tys<L:lattice_ops combine>(
b
.to_str
(
self
.infcx
()));
b
.to_str
(
self
.infcx
()));
if
a
==
b
{
return
Ok
(
a
);
}
if
a
==
b
{
return
Ok
(
a
);
}
do
indent
{
do
indent
{
match
(
ty
::
get
(
a
)
.st
ruct
,
ty
::
get
(
b
)
.struct
)
{
match
(
ty
::
get
(
a
)
.st
y
,
ty
::
get
(
b
)
.sty
)
{
(
ty
::
ty_bot
,
_
)
=>
self
.ty_bot
(
b
),
(
ty
::
ty_bot
,
_
)
=>
self
.ty_bot
(
b
),
(
_
,
ty
::
ty_bot
)
=>
self
.ty_bot
(
a
),
(
_
,
ty
::
ty_bot
)
=>
self
.ty_bot
(
a
),
...
...
src/rustc/middle/typeck/infer/resolve.rs
浏览文件 @
27cc0a36
...
@@ -112,7 +112,7 @@ fn resolve_type(typ: ty::t) -> ty::t {
...
@@ -112,7 +112,7 @@ fn resolve_type(typ: ty::t) -> ty::t {
indent
(
fn
&
()
->
ty
::
t
{
indent
(
fn
&
()
->
ty
::
t
{
if
!
ty
::
type_needs_infer
(
typ
)
{
return
typ
;
}
if
!
ty
::
type_needs_infer
(
typ
)
{
return
typ
;
}
match
ty
::
get
(
typ
)
.st
ruct
{
match
ty
::
get
(
typ
)
.st
y
{
ty
::
ty_infer
(
TyVar
(
vid
))
=>
{
ty
::
ty_infer
(
TyVar
(
vid
))
=>
{
self
.resolve_ty_var
(
vid
)
self
.resolve_ty_var
(
vid
)
}
}
...
...
src/rustc/middle/typeck/infer/sub.rs
浏览文件 @
27cc0a36
...
@@ -101,7 +101,7 @@ fn tys(a: ty::t, b: ty::t) -> cres<ty::t> {
...
@@ -101,7 +101,7 @@ fn tys(a: ty::t, b: ty::t) -> cres<ty::t> {
a
.to_str
(
self
.infcx
),
b
.to_str
(
self
.infcx
));
a
.to_str
(
self
.infcx
),
b
.to_str
(
self
.infcx
));
if
a
==
b
{
return
Ok
(
a
);
}
if
a
==
b
{
return
Ok
(
a
);
}
do
indent
{
do
indent
{
match
(
ty
::
get
(
a
)
.st
ruct
,
ty
::
get
(
b
)
.struct
)
{
match
(
ty
::
get
(
a
)
.st
y
,
ty
::
get
(
b
)
.sty
)
{
(
ty
::
ty_bot
,
_
)
=>
{
(
ty
::
ty_bot
,
_
)
=>
{
Ok
(
a
)
Ok
(
a
)
}
}
...
...
src/rustc/util/ppaux.rs
浏览文件 @
27cc0a36
...
@@ -284,7 +284,7 @@ fn fn_to_str(cx: ctxt, purity: ast::purity, proto: ty::fn_proto,
...
@@ -284,7 +284,7 @@ fn fn_to_str(cx: ctxt, purity: ast::purity, proto: ty::fn_proto,
for
inputs
.each
|
a
|
{
vec
::
push
(
strs
,
fn_input_to_str
(
cx
,
a
));
}
for
inputs
.each
|
a
|
{
vec
::
push
(
strs
,
fn_input_to_str
(
cx
,
a
));
}
s
+=
str
::
connect
(
strs
,
~
", "
);
s
+=
str
::
connect
(
strs
,
~
", "
);
s
+=
~
")"
;
s
+=
~
")"
;
if
ty
::
get
(
output
)
.st
ruct
!=
ty_nil
{
if
ty
::
get
(
output
)
.st
y
!=
ty_nil
{
s
+=
~
" -> "
;
s
+=
~
" -> "
;
match
cf
{
match
cf
{
ast
::
noreturn
=>
{
s
+=
~
"!"
;
}
ast
::
noreturn
=>
{
s
+=
~
"!"
;
}
...
@@ -310,7 +310,7 @@ fn field_to_str(cx: ctxt, f: field) -> ~str {
...
@@ -310,7 +310,7 @@ fn field_to_str(cx: ctxt, f: field) -> ~str {
}
}
// pretty print the structural type representation:
// pretty print the structural type representation:
return
match
ty
::
get
(
typ
)
.st
ruct
{
return
match
ty
::
get
(
typ
)
.st
y
{
ty_nil
=>
~
"()"
,
ty_nil
=>
~
"()"
,
ty_bot
=>
~
"_|_"
,
ty_bot
=>
~
"_|_"
,
ty_bool
=>
~
"bool"
,
ty_bool
=>
~
"bool"
,
...
...
src/test/run-pass/alias-uninit-value.rs
浏览文件 @
27cc0a36
...
@@ -6,10 +6,10 @@
...
@@ -6,10 +6,10 @@
enum
sty
{
ty_nil
,
}
enum
sty
{
ty_nil
,
}
type
raw_t
=
{
struct
:
sty
,
cname
:
Option
<~
str
>
,
hash
:
uint
};
type
raw_t
=
{
struct
_
:
sty
,
cname
:
Option
<~
str
>
,
hash
:
uint
};
fn
mk_raw_ty
(
st
:
sty
,
cname
:
Option
<~
str
>
)
->
raw_t
{
fn
mk_raw_ty
(
st
:
sty
,
cname
:
Option
<~
str
>
)
->
raw_t
{
return
{
struct
:
st
,
cname
:
cname
,
hash
:
0u
};
return
{
struct
_
:
st
,
cname
:
cname
,
hash
:
0u
};
}
}
fn
main
()
{
mk_raw_ty
(
ty_nil
,
None
::
<~
str
>
);
}
fn
main
()
{
mk_raw_ty
(
ty_nil
,
None
::
<~
str
>
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录