Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
1a268f4d
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1a268f4d
编写于
7月 10, 2015
作者:
J
Jared Roesch
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename TypeWithMutability to TypeAndMut
上级
fe30f625
变更
31
隐藏空白更改
内联
并排
Showing
31 changed file
with
106 addition
and
106 deletion
+106
-106
src/librustc/metadata/tydecode.rs
src/librustc/metadata/tydecode.rs
+2
-2
src/librustc/metadata/tyencode.rs
src/librustc/metadata/tyencode.rs
+1
-1
src/librustc/middle/cast.rs
src/librustc/middle/cast.rs
+2
-2
src/librustc/middle/check_match.rs
src/librustc/middle/check_match.rs
+3
-3
src/librustc/middle/implicator.rs
src/librustc/middle/implicator.rs
+1
-1
src/librustc/middle/mem_categorization.rs
src/librustc/middle/mem_categorization.rs
+1
-1
src/librustc/middle/traits/select.rs
src/librustc/middle/traits/select.rs
+3
-3
src/librustc/middle/ty.rs
src/librustc/middle/ty.rs
+21
-21
src/librustc/middle/ty_fold.rs
src/librustc/middle/ty_fold.rs
+6
-6
src/librustc/middle/ty_relate/mod.rs
src/librustc/middle/ty_relate/mod.rs
+5
-5
src/librustc/util/ppaux.rs
src/librustc/util/ppaux.rs
+2
-2
src/librustc_trans/trans/adt.rs
src/librustc_trans/trans/adt.rs
+2
-2
src/librustc_trans/trans/attributes.rs
src/librustc_trans/trans/attributes.rs
+1
-1
src/librustc_trans/trans/common.rs
src/librustc_trans/trans/common.rs
+2
-2
src/librustc_trans/trans/consts.rs
src/librustc_trans/trans/consts.rs
+1
-1
src/librustc_trans/trans/debuginfo/metadata.rs
src/librustc_trans/trans/debuginfo/metadata.rs
+4
-4
src/librustc_trans/trans/debuginfo/type_names.rs
src/librustc_trans/trans/debuginfo/type_names.rs
+2
-2
src/librustc_trans/trans/expr.rs
src/librustc_trans/trans/expr.rs
+7
-7
src/librustc_trans/trans/tvec.rs
src/librustc_trans/trans/tvec.rs
+1
-1
src/librustc_trans/trans/type_of.rs
src/librustc_trans/trans/type_of.rs
+2
-2
src/librustc_typeck/astconv.rs
src/librustc_typeck/astconv.rs
+3
-3
src/librustc_typeck/check/_match.rs
src/librustc_typeck/check/_match.rs
+4
-4
src/librustc_typeck/check/cast.rs
src/librustc_typeck/check/cast.rs
+7
-7
src/librustc_typeck/check/coercion.rs
src/librustc_typeck/check/coercion.rs
+3
-3
src/librustc_typeck/check/method/confirm.rs
src/librustc_typeck/check/method/confirm.rs
+1
-1
src/librustc_typeck/check/method/mod.rs
src/librustc_typeck/check/method/mod.rs
+1
-1
src/librustc_typeck/check/method/probe.rs
src/librustc_typeck/check/method/probe.rs
+3
-3
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+11
-11
src/librustc_typeck/coherence/mod.rs
src/librustc_typeck/coherence/mod.rs
+1
-1
src/librustc_typeck/coherence/orphan.rs
src/librustc_typeck/coherence/orphan.rs
+2
-2
src/librustc_typeck/variance.rs
src/librustc_typeck/variance.rs
+1
-1
未找到文件。
src/librustc/metadata/tydecode.rs
浏览文件 @
1a268f4d
...
...
@@ -587,11 +587,11 @@ fn parse_mutability(st: &mut PState) -> ast::Mutability {
}
}
fn
parse_mt_
<
'a
,
'tcx
,
F
>
(
st
:
&
mut
PState
<
'a
,
'tcx
>
,
conv
:
&
mut
F
)
->
ty
::
Type
WithMutability
<
'tcx
>
where
fn
parse_mt_
<
'a
,
'tcx
,
F
>
(
st
:
&
mut
PState
<
'a
,
'tcx
>
,
conv
:
&
mut
F
)
->
ty
::
Type
AndMut
<
'tcx
>
where
F
:
FnMut
(
DefIdSource
,
ast
::
DefId
)
->
ast
::
DefId
,
{
let
m
=
parse_mutability
(
st
);
ty
::
Type
WithMutability
{
ty
:
parse_ty_
(
st
,
conv
),
mutbl
:
m
}
ty
::
Type
AndMut
{
ty
:
parse_ty_
(
st
,
conv
),
mutbl
:
m
}
}
fn
parse_def_
<
F
>
(
st
:
&
mut
PState
,
source
:
DefIdSource
,
conv
:
&
mut
F
)
->
ast
::
DefId
where
...
...
src/librustc/metadata/tyencode.rs
浏览文件 @
1a268f4d
...
...
@@ -183,7 +183,7 @@ fn enc_mutability(w: &mut Encoder, mt: ast::Mutability) {
}
fn
enc_mt
<
'a
,
'tcx
>
(
w
:
&
mut
Encoder
,
cx
:
&
ctxt
<
'a
,
'tcx
>
,
mt
:
ty
::
Type
WithMutability
<
'tcx
>
)
{
mt
:
ty
::
Type
AndMut
<
'tcx
>
)
{
enc_mutability
(
w
,
mt
.mutbl
);
enc_ty
(
w
,
cx
,
mt
.ty
);
}
...
...
src/librustc/middle/cast.rs
浏览文件 @
1a268f4d
...
...
@@ -36,9 +36,9 @@ pub enum CastTy<'tcx> {
/// Function Pointers
FnPtr
,
/// Raw pointers
Ptr
(
&
'tcx
ty
::
Type
WithMutability
<
'tcx
>
),
Ptr
(
&
'tcx
ty
::
Type
AndMut
<
'tcx
>
),
/// References
RPtr
(
&
'tcx
ty
::
Type
WithMutability
<
'tcx
>
),
RPtr
(
&
'tcx
ty
::
Type
AndMut
<
'tcx
>
),
}
/// Cast Kind. See RFC 401 (or librustc_typeck/check/cast.rs)
...
...
src/librustc/middle/check_match.rs
浏览文件 @
1a268f4d
...
...
@@ -535,7 +535,7 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
}
}
ty
::
TyRef
(
_
,
ty
::
Type
WithMutability
{
ty
,
mutbl
})
=>
{
ty
::
TyRef
(
_
,
ty
::
Type
AndMut
{
ty
,
mutbl
})
=>
{
match
ty
.sty
{
ty
::
TyArray
(
_
,
n
)
=>
match
ctor
{
&
Single
=>
{
...
...
@@ -600,7 +600,7 @@ fn all_constructors(cx: &MatchCheckCtxt, left_ty: Ty,
ty
::
TyBool
=>
[
true
,
false
]
.iter
()
.map
(|
b
|
ConstantValue
(
ConstVal
::
Bool
(
*
b
)))
.collect
(),
ty
::
TyRef
(
_
,
ty
::
Type
WithMutability
{
ty
,
..
})
=>
match
ty
.sty
{
ty
::
TyRef
(
_
,
ty
::
Type
AndMut
{
ty
,
..
})
=>
match
ty
.sty
{
ty
::
TySlice
(
_
)
=>
range_inclusive
(
0
,
max_slice_length
)
.map
(|
length
|
Slice
(
length
))
.collect
(),
_
=>
vec!
(
Single
)
...
...
@@ -808,7 +808,7 @@ pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: Ty) -> usi
match
ty
.sty
{
ty
::
TyTuple
(
ref
fs
)
=>
fs
.len
(),
ty
::
TyBox
(
_
)
=>
1
,
ty
::
TyRef
(
_
,
ty
::
Type
WithMutability
{
ty
,
..
})
=>
match
ty
.sty
{
ty
::
TyRef
(
_
,
ty
::
Type
AndMut
{
ty
,
..
})
=>
match
ty
.sty
{
ty
::
TySlice
(
_
)
=>
match
*
ctor
{
Slice
(
length
)
=>
length
,
ConstantValue
(
_
)
=>
0
,
...
...
src/librustc/middle/implicator.rs
浏览文件 @
1a268f4d
...
...
@@ -115,7 +115,7 @@ fn accumulate_from_ty(&mut self, ty: Ty<'tcx>) {
ty
::
TyArray
(
t
,
_
)
|
ty
::
TySlice
(
t
)
|
ty
::
TyRawPtr
(
ty
::
Type
WithMutability
{
ty
:
t
,
..
})
|
ty
::
TyRawPtr
(
ty
::
Type
AndMut
{
ty
:
t
,
..
})
|
ty
::
TyBox
(
t
)
=>
{
self
.accumulate_from_ty
(
t
)
}
...
...
src/librustc/middle/mem_categorization.rs
浏览文件 @
1a268f4d
...
...
@@ -1614,7 +1614,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn
element_kind
(
t
:
Ty
)
->
ElementKind
{
match
t
.sty
{
ty
::
TyRef
(
_
,
ty
::
Type
WithMutability
{
ty
,
..
})
|
ty
::
TyRef
(
_
,
ty
::
Type
AndMut
{
ty
,
..
})
|
ty
::
TyBox
(
ty
)
=>
match
ty
.sty
{
ty
::
TySlice
(
_
)
=>
VecElement
,
_
=>
OtherElement
...
...
src/librustc/middle/traits/select.rs
浏览文件 @
1a268f4d
...
...
@@ -1659,7 +1659,7 @@ fn builtin_bound(&mut self,
}
}
ty
::
TyRef
(
_
,
ty
::
Type
WithMutability
{
ty
:
_
,
mutbl
})
=>
{
ty
::
TyRef
(
_
,
ty
::
Type
AndMut
{
ty
:
_
,
mutbl
})
=>
{
// &mut T or &T
match
bound
{
ty
::
BoundCopy
=>
{
...
...
@@ -1851,8 +1851,8 @@ fn constituent_types_for_ty(&self, t: Ty<'tcx>) -> Option<Vec<Ty<'tcx>>> {
Some
(
vec!
[
referent_ty
])
}
ty
::
TyRawPtr
(
ty
::
Type
WithMutability
{
ty
:
element_ty
,
..
})
|
ty
::
TyRef
(
_
,
ty
::
Type
WithMutability
{
ty
:
element_ty
,
..
})
=>
{
ty
::
TyRawPtr
(
ty
::
Type
AndMut
{
ty
:
element_ty
,
..
})
|
ty
::
TyRef
(
_
,
ty
::
Type
AndMut
{
ty
:
element_ty
,
..
})
=>
{
Some
(
vec!
[
element_ty
])
},
...
...
src/librustc/middle/ty.rs
浏览文件 @
1a268f4d
...
...
@@ -110,7 +110,7 @@ pub struct CrateAnalysis {
#[derive(Copy,
Clone,
PartialEq,
Eq,
Hash)]
pub
struct
Field
<
'tcx
>
{
pub
name
:
ast
::
Name
,
pub
mt
:
Type
WithMutability
<
'tcx
>
pub
mt
:
Type
AndMut
<
'tcx
>
}
...
...
@@ -487,7 +487,7 @@ pub struct AssociatedType<'tcx> {
}
#[derive(Clone,
Copy,
PartialEq,
Eq,
Hash,
Debug)]
pub
struct
Type
WithMutability
<
'tcx
>
{
pub
struct
Type
AndMut
<
'tcx
>
{
pub
ty
:
Ty
<
'tcx
>
,
pub
mutbl
:
ast
::
Mutability
,
}
...
...
@@ -1746,11 +1746,11 @@ pub enum TypeVariants<'tcx> {
TySlice
(
Ty
<
'tcx
>
),
/// A raw pointer. Written as `*mut T` or `*const T`
TyRawPtr
(
Type
WithMutability
<
'tcx
>
),
TyRawPtr
(
Type
AndMut
<
'tcx
>
),
/// A reference; a pointer with an associated lifetime. Written as
/// `&a mut T` or `&'a T`.
TyRef
(
&
'tcx
Region
,
Type
WithMutability
<
'tcx
>
),
TyRef
(
&
'tcx
Region
,
Type
AndMut
<
'tcx
>
),
/// If the def-id is Some(_), then this is the type of a specific
/// fn item. Otherwise, if None(_), it a fn pointer type.
...
...
@@ -3564,28 +3564,28 @@ pub fn mk_box(&self, ty: Ty<'tcx>) -> Ty<'tcx> {
self
.mk_ty
(
TyBox
(
ty
))
}
pub
fn
mk_ptr
(
&
self
,
tm
:
Type
WithMutability
<
'tcx
>
)
->
Ty
<
'tcx
>
{
pub
fn
mk_ptr
(
&
self
,
tm
:
Type
AndMut
<
'tcx
>
)
->
Ty
<
'tcx
>
{
self
.mk_ty
(
TyRawPtr
(
tm
))
}
pub
fn
mk_ref
(
&
self
,
r
:
&
'tcx
Region
,
tm
:
Type
WithMutability
<
'tcx
>
)
->
Ty
<
'tcx
>
{
pub
fn
mk_ref
(
&
self
,
r
:
&
'tcx
Region
,
tm
:
Type
AndMut
<
'tcx
>
)
->
Ty
<
'tcx
>
{
self
.mk_ty
(
TyRef
(
r
,
tm
))
}
pub
fn
mk_mut_ref
(
&
self
,
r
:
&
'tcx
Region
,
ty
:
Ty
<
'tcx
>
)
->
Ty
<
'tcx
>
{
self
.mk_ref
(
r
,
Type
WithMutability
{
ty
:
ty
,
mutbl
:
ast
::
MutMutable
})
self
.mk_ref
(
r
,
Type
AndMut
{
ty
:
ty
,
mutbl
:
ast
::
MutMutable
})
}
pub
fn
mk_imm_ref
(
&
self
,
r
:
&
'tcx
Region
,
ty
:
Ty
<
'tcx
>
)
->
Ty
<
'tcx
>
{
self
.mk_ref
(
r
,
Type
WithMutability
{
ty
:
ty
,
mutbl
:
ast
::
MutImmutable
})
self
.mk_ref
(
r
,
Type
AndMut
{
ty
:
ty
,
mutbl
:
ast
::
MutImmutable
})
}
pub
fn
mk_mut_ptr
(
&
self
,
ty
:
Ty
<
'tcx
>
)
->
Ty
<
'tcx
>
{
self
.mk_ptr
(
Type
WithMutability
{
ty
:
ty
,
mutbl
:
ast
::
MutMutable
})
self
.mk_ptr
(
Type
AndMut
{
ty
:
ty
,
mutbl
:
ast
::
MutMutable
})
}
pub
fn
mk_imm_ptr
(
&
self
,
ty
:
Ty
<
'tcx
>
)
->
Ty
<
'tcx
>
{
self
.mk_ptr
(
Type
WithMutability
{
ty
:
ty
,
mutbl
:
ast
::
MutImmutable
})
self
.mk_ptr
(
Type
AndMut
{
ty
:
ty
,
mutbl
:
ast
::
MutImmutable
})
}
pub
fn
mk_nil_ptr
(
&
self
)
->
Ty
<
'tcx
>
{
...
...
@@ -4269,7 +4269,7 @@ fn tc_ty<'tcx>(cx: &ctxt<'tcx>,
}
fn
tc_mt
<
'tcx
>
(
cx
:
&
ctxt
<
'tcx
>
,
mt
:
Type
WithMutability
<
'tcx
>
,
mt
:
Type
AndMut
<
'tcx
>
,
cache
:
&
mut
FnvHashMap
<
Ty
<
'tcx
>
,
TypeContents
>
)
->
TypeContents
{
let
mc
=
TC
::
ReachesMutable
.when
(
mt
.mutbl
==
MutMutable
);
...
...
@@ -4341,11 +4341,11 @@ pub fn moves_by_default<'a>(&'tcx self, param_env: &ParameterEnvironment<'a,'tcx
// Fast-path for primitive types
let
result
=
match
self
.sty
{
TyBool
|
TyChar
|
TyInt
(
..
)
|
TyUint
(
..
)
|
TyFloat
(
..
)
|
TyRawPtr
(
..
)
|
TyBareFn
(
..
)
|
TyRef
(
_
,
Type
WithMutability
{
TyRawPtr
(
..
)
|
TyBareFn
(
..
)
|
TyRef
(
_
,
Type
AndMut
{
mutbl
:
ast
::
MutImmutable
,
..
})
=>
Some
(
false
),
TyStr
|
TyBox
(
..
)
|
TyRef
(
_
,
Type
WithMutability
{
TyStr
|
TyBox
(
..
)
|
TyRef
(
_
,
Type
AndMut
{
mutbl
:
ast
::
MutMutable
,
..
})
=>
Some
(
true
),
...
...
@@ -4780,10 +4780,10 @@ pub fn is_c_like_enum(&self, cx: &ctxt) -> bool {
//
// The parameter `explicit` indicates if this is an *explicit* dereference.
// Some types---notably unsafe ptrs---can only be dereferenced explicitly.
pub
fn
builtin_deref
(
&
self
,
explicit
:
bool
)
->
Option
<
Type
WithMutability
<
'tcx
>>
{
pub
fn
builtin_deref
(
&
self
,
explicit
:
bool
)
->
Option
<
Type
AndMut
<
'tcx
>>
{
match
self
.sty
{
TyBox
(
ty
)
=>
{
Some
(
Type
WithMutability
{
Some
(
Type
AndMut
{
ty
:
ty
,
mutbl
:
ast
::
MutImmutable
,
})
...
...
@@ -4922,10 +4922,10 @@ pub fn adjust_for_autoref(&'tcx self, cx: &ctxt<'tcx>,
match
autoref
{
None
=>
self
,
Some
(
AutoPtr
(
r
,
m
))
=>
{
cx
.mk_ref
(
r
,
Type
WithMutability
{
ty
:
self
,
mutbl
:
m
})
cx
.mk_ref
(
r
,
Type
AndMut
{
ty
:
self
,
mutbl
:
m
})
}
Some
(
AutoUnsafe
(
m
))
=>
{
cx
.mk_ptr
(
Type
WithMutability
{
ty
:
self
,
mutbl
:
m
})
cx
.mk_ptr
(
Type
AndMut
{
ty
:
self
,
mutbl
:
m
})
}
}
}
...
...
@@ -5416,7 +5416,7 @@ pub fn field_idx_strict(&self, name: ast::Name, fields: &[Field<'tcx>])
pub
fn
note_and_explain_type_err
(
&
self
,
err
:
&
TypeError
<
'tcx
>
,
sp
:
Span
)
{
use
self
::
TypeError
::
*
;
match
*
err
{
RegionsDoesNotOutlive
(
subregion
,
superregion
)
=>
{
self
.note_and_explain_region
(
""
,
subregion
,
"..."
);
...
...
@@ -5984,7 +5984,7 @@ pub fn struct_fields(&self, did: ast::DefId, substs: &Substs<'tcx>)
self
.lookup_struct_fields
(
did
)
.iter
()
.map
(|
f
|
{
Field
{
name
:
f
.name
,
mt
:
Type
WithMutability
{
mt
:
Type
AndMut
{
ty
:
self
.lookup_field_type
(
did
,
f
.id
,
substs
),
mutbl
:
MutImmutable
}
...
...
@@ -6070,7 +6070,7 @@ pub fn closure_upvars<'a>(typer: &infer::InferCtxt<'a, 'tcx>,
}
UpvarCapture
::
ByRef
(
borrow
)
=>
{
tcx
.mk_ref
(
tcx
.mk_region
(
borrow
.region
),
ty
::
Type
WithMutability
{
ty
::
Type
AndMut
{
ty
:
freevar_ty
,
mutbl
:
borrow
.kind
.to_mutbl_lossy
(),
})
...
...
@@ -6423,7 +6423,7 @@ fn helper<'tcx>(tcx: &ctxt<'tcx>, ty: Ty<'tcx>, svh: &Svh,
h
.as_str
()
.hash
(
state
);
did
.node
.hash
(
state
);
};
let
mt
=
|
state
:
&
mut
SipHasher
,
mt
:
Type
WithMutability
|
{
let
mt
=
|
state
:
&
mut
SipHasher
,
mt
:
Type
AndMut
|
{
mt
.mutbl
.hash
(
state
);
};
let
fn_sig
=
|
state
:
&
mut
SipHasher
,
sig
:
&
Binder
<
FnSig
<
'tcx
>>
|
{
...
...
src/librustc/middle/ty_fold.rs
浏览文件 @
1a268f4d
...
...
@@ -85,7 +85,7 @@ fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
super_fold_ty
(
self
,
t
)
}
fn
fold_mt
(
&
mut
self
,
t
:
&
ty
::
Type
WithMutability
<
'tcx
>
)
->
ty
::
TypeWithMutability
<
'tcx
>
{
fn
fold_mt
(
&
mut
self
,
t
:
&
ty
::
Type
AndMut
<
'tcx
>
)
->
ty
::
TypeAndMut
<
'tcx
>
{
super_fold_mt
(
self
,
t
)
}
...
...
@@ -251,8 +251,8 @@ fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::ClosureTy<'tcx>
}
}
impl
<
'tcx
>
TypeFoldable
<
'tcx
>
for
ty
::
Type
WithMutability
<
'tcx
>
{
fn
fold_with
<
F
:
TypeFolder
<
'tcx
>>
(
&
self
,
folder
:
&
mut
F
)
->
ty
::
Type
WithMutability
<
'tcx
>
{
impl
<
'tcx
>
TypeFoldable
<
'tcx
>
for
ty
::
Type
AndMut
<
'tcx
>
{
fn
fold_with
<
F
:
TypeFolder
<
'tcx
>>
(
&
self
,
folder
:
&
mut
F
)
->
ty
::
Type
AndMut
<
'tcx
>
{
folder
.fold_mt
(
self
)
}
}
...
...
@@ -685,9 +685,9 @@ pub fn super_fold_trait_ref<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
}
pub
fn
super_fold_mt
<
'tcx
,
T
:
TypeFolder
<
'tcx
>>
(
this
:
&
mut
T
,
mt
:
&
ty
::
Type
WithMutability
<
'tcx
>
)
->
ty
::
Type
WithMutability
<
'tcx
>
{
ty
::
Type
WithMutability
{
ty
:
mt
.ty
.fold_with
(
this
),
mt
:
&
ty
::
Type
AndMut
<
'tcx
>
)
->
ty
::
Type
AndMut
<
'tcx
>
{
ty
::
Type
AndMut
{
ty
:
mt
.ty
.fold_with
(
this
),
mutbl
:
mt
.mutbl
}
}
...
...
src/librustc/middle/ty_relate/mod.rs
浏览文件 @
1a268f4d
...
...
@@ -89,11 +89,11 @@ fn relate<R:TypeRelation<'a,'tcx>>(relation: &mut R,
///////////////////////////////////////////////////////////////////////////
// Relate impls
impl
<
'a
,
'tcx
:
'a
>
Relate
<
'a
,
'tcx
>
for
ty
::
Type
WithMutability
<
'tcx
>
{
impl
<
'a
,
'tcx
:
'a
>
Relate
<
'a
,
'tcx
>
for
ty
::
Type
AndMut
<
'tcx
>
{
fn
relate
<
R
>
(
relation
:
&
mut
R
,
a
:
&
ty
::
Type
WithMutability
<
'tcx
>
,
b
:
&
ty
::
Type
WithMutability
<
'tcx
>
)
->
RelateResult
<
'tcx
,
ty
::
Type
WithMutability
<
'tcx
>>
a
:
&
ty
::
Type
AndMut
<
'tcx
>
,
b
:
&
ty
::
Type
AndMut
<
'tcx
>
)
->
RelateResult
<
'tcx
,
ty
::
Type
AndMut
<
'tcx
>>
where
R
:
TypeRelation
<
'a
,
'tcx
>
{
debug!
(
"{}.mts({:?}, {:?})"
,
...
...
@@ -109,7 +109,7 @@ fn relate<R>(relation: &mut R,
ast
::
MutMutable
=>
ty
::
Invariant
,
};
let
ty
=
try!
(
relation
.relate_with_variance
(
variance
,
&
a
.ty
,
&
b
.ty
));
Ok
(
ty
::
Type
WithMutability
{
ty
:
ty
,
mutbl
:
mutbl
})
Ok
(
ty
::
Type
AndMut
{
ty
:
ty
,
mutbl
:
mutbl
})
}
}
}
...
...
src/librustc/util/ppaux.rs
浏览文件 @
1a268f4d
...
...
@@ -19,7 +19,7 @@
use
middle
::
ty
::{
TyParam
,
TyRawPtr
,
TyRef
,
TyTuple
};
use
middle
::
ty
::
TyClosure
;
use
middle
::
ty
::{
TyBox
,
TyTrait
,
TyInt
,
TyUint
,
TyInfer
};
use
middle
::
ty
::{
self
,
Type
WithMutability
,
Ty
,
HasTypeFlags
};
use
middle
::
ty
::{
self
,
Type
AndMut
,
Ty
,
HasTypeFlags
};
use
middle
::
ty_fold
::{
self
,
TypeFoldable
};
use
std
::
fmt
;
...
...
@@ -321,7 +321,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
}
}
impl
<
'tcx
>
fmt
::
Display
for
ty
::
Type
WithMutability
<
'tcx
>
{
impl
<
'tcx
>
fmt
::
Display
for
ty
::
Type
AndMut
<
'tcx
>
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
write!
(
f
,
"{}{}"
,
if
self
.mutbl
==
ast
::
MutMutable
{
"mut "
}
else
{
""
},
...
...
src/librustc_trans/trans/adt.rs
浏览文件 @
1a268f4d
...
...
@@ -398,7 +398,7 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>,
mut
path
:
DiscrField
)
->
Option
<
DiscrField
>
{
match
ty
.sty
{
// Fat &T/&mut T/Box<T> i.e. T is [T], str, or Trait
ty
::
TyRef
(
_
,
ty
::
Type
WithMutability
{
ty
,
..
})
|
ty
::
TyBox
(
ty
)
if
!
type_is_sized
(
tcx
,
ty
)
=>
{
ty
::
TyRef
(
_
,
ty
::
Type
AndMut
{
ty
,
..
})
|
ty
::
TyBox
(
ty
)
if
!
type_is_sized
(
tcx
,
ty
)
=>
{
path
.push
(
FAT_PTR_ADDR
);
Some
(
path
)
},
...
...
@@ -415,7 +415,7 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>,
assert_eq!
(
nonzero_fields
.len
(),
1
);
let
nonzero_field
=
tcx
.lookup_field_type
(
did
,
nonzero_fields
[
0
]
.id
,
substs
);
match
nonzero_field
.sty
{
ty
::
TyRawPtr
(
ty
::
Type
WithMutability
{
ty
,
..
})
if
!
type_is_sized
(
tcx
,
ty
)
=>
{
ty
::
TyRawPtr
(
ty
::
Type
AndMut
{
ty
,
..
})
if
!
type_is_sized
(
tcx
,
ty
)
=>
{
path
.push_all
(
&
[
0
,
FAT_PTR_ADDR
]);
Some
(
path
)
},
...
...
src/librustc_trans/trans/attributes.rs
浏览文件 @
1a268f4d
...
...
@@ -223,7 +223,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx
// We can also mark the return value as `dereferenceable` in certain cases
match
ret_ty
.sty
{
// These are not really pointers but pairs, (pointer, len)
ty
::
TyRef
(
_
,
ty
::
Type
WithMutability
{
ty
:
inner
,
..
})
ty
::
TyRef
(
_
,
ty
::
Type
AndMut
{
ty
:
inner
,
..
})
|
ty
::
TyBox
(
inner
)
if
common
::
type_is_sized
(
ccx
.tcx
(),
inner
)
=>
{
let
llret_sz
=
machine
::
llsize_of_real
(
ccx
,
type_of
::
type_of
(
ccx
,
inner
));
attrs
.ret
(
llvm
::
DereferenceableAttribute
(
llret_sz
));
...
...
src/librustc_trans/trans/common.rs
浏览文件 @
1a268f4d
...
...
@@ -130,8 +130,8 @@ pub fn type_is_sized<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
pub
fn
type_is_fat_ptr
<
'tcx
>
(
cx
:
&
ty
::
ctxt
<
'tcx
>
,
ty
:
Ty
<
'tcx
>
)
->
bool
{
match
ty
.sty
{
ty
::
TyRawPtr
(
ty
::
Type
WithMutability
{
ty
,
..
})
|
ty
::
TyRef
(
_
,
ty
::
Type
WithMutability
{
ty
,
..
})
|
ty
::
TyRawPtr
(
ty
::
Type
AndMut
{
ty
,
..
})
|
ty
::
TyRef
(
_
,
ty
::
Type
AndMut
{
ty
,
..
})
|
ty
::
TyBox
(
ty
)
=>
{
!
type_is_sized
(
cx
,
ty
)
}
...
...
src/librustc_trans/trans/consts.rs
浏览文件 @
1a268f4d
...
...
@@ -621,7 +621,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
let
len
=
unsafe
{
llvm
::
LLVMConstIntGetZExtValue
(
len
)
as
u64
};
let
len
=
match
bt
.sty
{
ty
::
TyBox
(
ty
)
|
ty
::
TyRef
(
_
,
ty
::
Type
WithMutability
{
ty
,
..
})
=>
match
ty
.sty
{
ty
::
TyBox
(
ty
)
|
ty
::
TyRef
(
_
,
ty
::
Type
AndMut
{
ty
,
..
})
=>
match
ty
.sty
{
ty
::
TyStr
=>
{
assert
!
(
len
>
0
);
len
-
1
...
...
src/librustc_trans/trans/debuginfo/metadata.rs
浏览文件 @
1a268f4d
...
...
@@ -206,7 +206,7 @@ fn get_unique_type_id_of_type<'a>(&mut self, cx: &CrateContext<'a, 'tcx>,
let
inner_type_id
=
self
.get_unique_type_id_as_string
(
inner_type_id
);
unique_type_id
.push_str
(
&
inner_type_id
[
..
]);
},
ty
::
TyRawPtr
(
ty
::
Type
WithMutability
{
ty
:
inner_type
,
mutbl
}
)
=>
{
ty
::
TyRawPtr
(
ty
::
Type
AndMut
{
ty
:
inner_type
,
mutbl
}
)
=>
{
unique_type_id
.push
(
'*'
);
if
mutbl
==
ast
::
MutMutable
{
unique_type_id
.push_str
(
"mut"
);
...
...
@@ -216,7 +216,7 @@ fn get_unique_type_id_of_type<'a>(&mut self, cx: &CrateContext<'a, 'tcx>,
let
inner_type_id
=
self
.get_unique_type_id_as_string
(
inner_type_id
);
unique_type_id
.push_str
(
&
inner_type_id
[
..
]);
},
ty
::
TyRef
(
_
,
ty
::
Type
WithMutability
{
ty
:
inner_type
,
mutbl
})
=>
{
ty
::
TyRef
(
_
,
ty
::
Type
AndMut
{
ty
:
inner_type
,
mutbl
})
=>
{
unique_type_id
.push
(
'&'
);
if
mutbl
==
ast
::
MutMutable
{
unique_type_id
.push_str
(
"mut"
);
...
...
@@ -561,7 +561,7 @@ fn vec_slice_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
unique_type_id
:
UniqueTypeId
,
span
:
Span
)
->
MetadataCreationResult
{
let
data_ptr_type
=
cx
.tcx
()
.mk_ptr
(
ty
::
Type
WithMutability
{
let
data_ptr_type
=
cx
.tcx
()
.mk_ptr
(
ty
::
Type
AndMut
{
ty
:
element_type
,
mutbl
:
ast
::
MutImmutable
});
...
...
@@ -765,7 +765,7 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
trait_pointer_metadata
(
cx
,
t
,
None
,
unique_type_id
),
false
)
}
ty
::
TyBox
(
ty
)
|
ty
::
TyRawPtr
(
ty
::
Type
WithMutability
{
ty
,
..
})
|
ty
::
TyRef
(
_
,
ty
::
TypeWithMutability
{
ty
,
..
})
=>
{
ty
::
TyBox
(
ty
)
|
ty
::
TyRawPtr
(
ty
::
Type
AndMut
{
ty
,
..
})
|
ty
::
TyRef
(
_
,
ty
::
TypeAndMut
{
ty
,
..
})
=>
{
match
ty
.sty
{
ty
::
TySlice
(
typ
)
=>
{
vec_slice_metadata
(
cx
,
t
,
typ
,
unique_type_id
,
usage_site_span
)
...
...
src/librustc_trans/trans/debuginfo/type_names.rs
浏览文件 @
1a268f4d
...
...
@@ -77,7 +77,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
push_debuginfo_type_name
(
cx
,
inner_type
,
true
,
output
);
output
.push
(
'>'
);
},
ty
::
TyRawPtr
(
ty
::
Type
WithMutability
{
ty
:
inner_type
,
mutbl
}
)
=>
{
ty
::
TyRawPtr
(
ty
::
Type
AndMut
{
ty
:
inner_type
,
mutbl
}
)
=>
{
output
.push
(
'*'
);
match
mutbl
{
ast
::
MutImmutable
=>
output
.push_str
(
"const "
),
...
...
@@ -86,7 +86,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
push_debuginfo_type_name
(
cx
,
inner_type
,
true
,
output
);
},
ty
::
TyRef
(
_
,
ty
::
Type
WithMutability
{
ty
:
inner_type
,
mutbl
})
=>
{
ty
::
TyRef
(
_
,
ty
::
Type
AndMut
{
ty
:
inner_type
,
mutbl
})
=>
{
output
.push
(
'&'
);
if
mutbl
==
ast
::
MutMutable
{
output
.push_str
(
"mut "
);
...
...
src/librustc_trans/trans/expr.rs
浏览文件 @
1a268f4d
...
...
@@ -440,9 +440,9 @@ fn coerce_unsized<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
match
(
&
source
.ty.sty
,
&
target
.ty.sty
)
{
(
&
ty
::
TyBox
(
a
),
&
ty
::
TyBox
(
b
))
|
(
&
ty
::
TyRef
(
_
,
ty
::
Type
WithMutability
{
ty
:
a
,
..
}),
&
ty
::
TyRef
(
_
,
ty
::
TypeWithMutability
{
ty
:
b
,
..
}))
|
(
&
ty
::
TyRef
(
_
,
ty
::
Type
WithMutability
{
ty
:
a
,
..
}),
&
ty
::
TyRawPtr
(
ty
::
TypeWithMutability
{
ty
:
b
,
..
}))
|
(
&
ty
::
TyRawPtr
(
ty
::
Type
WithMutability
{
ty
:
a
,
..
}),
&
ty
::
TyRawPtr
(
ty
::
TypeWithMutability
{
ty
:
b
,
..
}))
=>
{
(
&
ty
::
TyRef
(
_
,
ty
::
Type
AndMut
{
ty
:
a
,
..
}),
&
ty
::
TyRef
(
_
,
ty
::
TypeAndMut
{
ty
:
b
,
..
}))
|
(
&
ty
::
TyRef
(
_
,
ty
::
Type
AndMut
{
ty
:
a
,
..
}),
&
ty
::
TyRawPtr
(
ty
::
TypeAndMut
{
ty
:
b
,
..
}))
|
(
&
ty
::
TyRawPtr
(
ty
::
Type
AndMut
{
ty
:
a
,
..
}),
&
ty
::
TyRawPtr
(
ty
::
TypeAndMut
{
ty
:
b
,
..
}))
=>
{
let
(
inner_source
,
inner_target
)
=
(
a
,
b
);
let
(
base
,
old_info
)
=
if
!
type_is_sized
(
bcx
.tcx
(),
inner_source
)
{
...
...
@@ -1346,7 +1346,7 @@ pub fn with_field_tys<'tcx, R, F>(tcx: &ty::ctxt<'tcx>,
let
fields
:
Vec
<
_
>
=
v
.iter
()
.enumerate
()
.map
(|(
i
,
&
f
)|
{
ty
::
Field
{
name
:
token
::
intern
(
&
i
.to_string
()),
mt
:
ty
::
Type
WithMutability
{
mt
:
ty
::
Type
AndMut
{
ty
:
f
,
mutbl
:
ast
::
MutImmutable
}
...
...
@@ -1994,7 +1994,7 @@ pub fn cast_is_noop<'tcx>(tcx: &ty::ctxt<'tcx>,
}
match
(
t_in
.builtin_deref
(
true
),
t_out
.builtin_deref
(
true
))
{
(
Some
(
ty
::
Type
WithMutability
{
ty
:
t_in
,
..
}),
Some
(
ty
::
TypeWithMutability
{
ty
:
t_out
,
..
}))
=>
{
(
Some
(
ty
::
Type
AndMut
{
ty
:
t_in
,
..
}),
Some
(
ty
::
TypeAndMut
{
ty
:
t_out
,
..
}))
=>
{
t_in
==
t_out
}
_
=>
{
...
...
@@ -2275,8 +2275,8 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
}
}
ty
::
TyRawPtr
(
ty
::
Type
WithMutability
{
ty
:
content_ty
,
..
})
|
ty
::
TyRef
(
_
,
ty
::
Type
WithMutability
{
ty
:
content_ty
,
..
})
=>
{
ty
::
TyRawPtr
(
ty
::
Type
AndMut
{
ty
:
content_ty
,
..
})
|
ty
::
TyRef
(
_
,
ty
::
Type
AndMut
{
ty
:
content_ty
,
..
})
=>
{
if
type_is_sized
(
bcx
.tcx
(),
content_ty
)
{
let
ptr
=
datum
.to_llscalarish
(
bcx
);
...
...
src/librustc_trans/trans/tvec.rs
浏览文件 @
1a268f4d
...
...
@@ -315,7 +315,7 @@ pub fn get_base_and_len<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
}
// Only used for pattern matching.
ty
::
TyBox
(
ty
)
|
ty
::
TyRef
(
_
,
ty
::
Type
WithMutability
{
ty
,
..
})
=>
{
ty
::
TyBox
(
ty
)
|
ty
::
TyRef
(
_
,
ty
::
Type
AndMut
{
ty
,
..
})
=>
{
let
inner
=
if
type_is_sized
(
bcx
.tcx
(),
ty
)
{
Load
(
bcx
,
llval
)
}
else
{
...
...
src/librustc_trans/trans/type_of.rs
浏览文件 @
1a268f4d
...
...
@@ -193,7 +193,7 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
ty
::
TyUint
(
t
)
=>
Type
::
uint_from_ty
(
cx
,
t
),
ty
::
TyFloat
(
t
)
=>
Type
::
float_from_ty
(
cx
,
t
),
ty
::
TyBox
(
ty
)
|
ty
::
TyRef
(
_
,
ty
::
Type
WithMutability
{
ty
,
..
})
|
ty
::
TyRawPtr
(
ty
::
TypeWithMutability
{
ty
,
..
})
=>
{
ty
::
TyBox
(
ty
)
|
ty
::
TyRef
(
_
,
ty
::
Type
AndMut
{
ty
,
..
})
|
ty
::
TyRawPtr
(
ty
::
TypeAndMut
{
ty
,
..
})
=>
{
if
type_is_sized
(
cx
.tcx
(),
ty
)
{
Type
::
i8p
(
cx
)
}
else
{
...
...
@@ -352,7 +352,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) ->
adt
::
incomplete_type_of
(
cx
,
&*
repr
,
"closure"
)
}
ty
::
TyBox
(
ty
)
|
ty
::
TyRef
(
_
,
ty
::
Type
WithMutability
{
ty
,
..
})
|
ty
::
TyRawPtr
(
ty
::
TypeWithMutability
{
ty
,
..
})
=>
{
ty
::
TyBox
(
ty
)
|
ty
::
TyRef
(
_
,
ty
::
Type
AndMut
{
ty
,
..
})
|
ty
::
TyRawPtr
(
ty
::
TypeAndMut
{
ty
,
..
})
=>
{
if
!
type_is_sized
(
cx
.tcx
(),
ty
)
{
if
let
ty
::
TyStr
=
ty
.sty
{
// This means we get a nicer name in the output (str is always
...
...
src/librustc_typeck/astconv.rs
浏览文件 @
1a268f4d
...
...
@@ -1556,7 +1556,7 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
}
}
ast
::
TyPtr
(
ref
mt
)
=>
{
tcx
.mk_ptr
(
ty
::
Type
WithMutability
{
tcx
.mk_ptr
(
ty
::
Type
AndMut
{
ty
:
ast_ty_to_ty
(
this
,
rscope
,
&*
mt
.ty
),
mutbl
:
mt
.mutbl
})
...
...
@@ -1569,7 +1569,7 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
rscope
,
ty
::
ObjectLifetimeDefault
::
Specific
(
r
));
let
t
=
ast_ty_to_ty
(
this
,
rscope1
,
&*
mt
.ty
);
tcx
.mk_ref
(
tcx
.mk_region
(
r
),
ty
::
Type
WithMutability
{
ty
:
t
,
mutbl
:
mt
.mutbl
})
tcx
.mk_ref
(
tcx
.mk_region
(
r
),
ty
::
Type
AndMut
{
ty
:
t
,
mutbl
:
mt
.mutbl
})
}
ast
::
TyTup
(
ref
fields
)
=>
{
let
flds
=
fields
.iter
()
...
...
@@ -1755,7 +1755,7 @@ fn ty_of_method_or_bare_fn<'a, 'tcx>(this: &AstConv<'tcx>,
ty
::
ByReferenceExplicitSelfCategory
(
region
,
mutability
)
=>
{
(
Some
(
this
.tcx
()
.mk_ref
(
this
.tcx
()
.mk_region
(
region
),
ty
::
Type
WithMutability
{
ty
::
Type
AndMut
{
ty
:
self_info
.untransformed_self_ty
,
mutbl
:
mutability
})),
...
...
src/librustc_typeck/check/_match.rs
浏览文件 @
1a268f4d
...
...
@@ -170,7 +170,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
// then `x` is assigned a value of type `&M T` where M is the mutability
// and T is the expected type.
let
region_var
=
fcx
.infcx
()
.next_region_var
(
infer
::
PatternRegion
(
pat
.span
));
let
mt
=
ty
::
Type
WithMutability
{
ty
:
expected
,
mutbl
:
mutbl
};
let
mt
=
ty
::
Type
AndMut
{
ty
:
expected
,
mutbl
:
mutbl
};
let
region_ty
=
tcx
.mk_ref
(
tcx
.mk_region
(
region_var
),
mt
);
// `x` is assigned a value of type `&M T`, hence `&M T <: typeof(x)` is
...
...
@@ -272,7 +272,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
ast
::
PatRegion
(
ref
inner
,
mutbl
)
=>
{
let
inner_ty
=
fcx
.infcx
()
.next_ty_var
();
let
mt
=
ty
::
Type
WithMutability
{
ty
:
inner_ty
,
mutbl
:
mutbl
};
let
mt
=
ty
::
Type
AndMut
{
ty
:
inner_ty
,
mutbl
:
mutbl
};
let
region
=
fcx
.infcx
()
.next_region_var
(
infer
::
PatternRegion
(
pat
.span
));
let
rptr_ty
=
tcx
.mk_ref
(
tcx
.mk_region
(
region
),
mt
);
...
...
@@ -301,7 +301,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
}),
_
=>
{
let
region
=
fcx
.infcx
()
.next_region_var
(
infer
::
PatternRegion
(
pat
.span
));
tcx
.mk_ref
(
tcx
.mk_region
(
region
),
ty
::
Type
WithMutability
{
tcx
.mk_ref
(
tcx
.mk_region
(
region
),
ty
::
Type
AndMut
{
ty
:
tcx
.mk_slice
(
inner_ty
),
mutbl
:
expected_ty
.builtin_deref
(
true
)
.map
(|
mt
|
mt
.mutbl
)
.unwrap_or
(
ast
::
MutImmutable
)
...
...
@@ -324,7 +324,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
let
mutbl
=
expected_ty
.builtin_deref
(
true
)
.map_or
(
ast
::
MutImmutable
,
|
mt
|
mt
.mutbl
);
let
slice_ty
=
tcx
.mk_ref
(
tcx
.mk_region
(
region
),
ty
::
Type
WithMutability
{
let
slice_ty
=
tcx
.mk_ref
(
tcx
.mk_region
(
region
),
ty
::
Type
AndMut
{
ty
:
tcx
.mk_slice
(
inner_ty
),
mutbl
:
mutbl
});
...
...
src/librustc_typeck/check/cast.rs
浏览文件 @
1a268f4d
...
...
@@ -272,8 +272,8 @@ fn do_check<'a>(&self, fcx: &FnCtxt<'a, 'tcx>) -> Result<CastKind, CastError> {
fn
check_ptr_ptr_cast
<
'a
>
(
&
self
,
fcx
:
&
FnCtxt
<
'a
,
'tcx
>
,
m_expr
:
&
'tcx
ty
::
Type
WithMutability
<
'tcx
>
,
m_cast
:
&
'tcx
ty
::
Type
WithMutability
<
'tcx
>
)
m_expr
:
&
'tcx
ty
::
Type
AndMut
<
'tcx
>
,
m_cast
:
&
'tcx
ty
::
Type
AndMut
<
'tcx
>
)
->
Result
<
CastKind
,
CastError
>
{
debug!
(
"check_ptr_ptr_cast m_expr={:?} m_cast={:?}"
,
...
...
@@ -299,7 +299,7 @@ fn check_ptr_ptr_cast<'a>(&self,
fn
check_fptr_ptr_cast
<
'a
>
(
&
self
,
fcx
:
&
FnCtxt
<
'a
,
'tcx
>
,
m_cast
:
&
'tcx
ty
::
Type
WithMutability
<
'tcx
>
)
m_cast
:
&
'tcx
ty
::
Type
AndMut
<
'tcx
>
)
->
Result
<
CastKind
,
CastError
>
{
// fptr-ptr cast. must be to sized ptr
...
...
@@ -313,7 +313,7 @@ fn check_fptr_ptr_cast<'a>(&self,
fn
check_ptr_addr_cast
<
'a
>
(
&
self
,
fcx
:
&
FnCtxt
<
'a
,
'tcx
>
,
m_expr
:
&
'tcx
ty
::
Type
WithMutability
<
'tcx
>
)
m_expr
:
&
'tcx
ty
::
Type
AndMut
<
'tcx
>
)
->
Result
<
CastKind
,
CastError
>
{
// ptr-addr cast. must be from sized ptr
...
...
@@ -327,8 +327,8 @@ fn check_ptr_addr_cast<'a>(&self,
fn
check_ref_cast
<
'a
>
(
&
self
,
fcx
:
&
FnCtxt
<
'a
,
'tcx
>
,
m_expr
:
&
'tcx
ty
::
Type
WithMutability
<
'tcx
>
,
m_cast
:
&
'tcx
ty
::
Type
WithMutability
<
'tcx
>
)
m_expr
:
&
'tcx
ty
::
Type
AndMut
<
'tcx
>
,
m_cast
:
&
'tcx
ty
::
Type
AndMut
<
'tcx
>
)
->
Result
<
CastKind
,
CastError
>
{
// array-ptr-cast.
...
...
@@ -353,7 +353,7 @@ fn check_ref_cast<'a>(&self,
fn
check_addr_ptr_cast
<
'a
>
(
&
self
,
fcx
:
&
FnCtxt
<
'a
,
'tcx
>
,
m_cast
:
&
'tcx
ty
::
Type
WithMutability
<
'tcx
>
)
m_cast
:
&
'tcx
ty
::
Type
AndMut
<
'tcx
>
)
->
Result
<
CastKind
,
CastError
>
{
// ptr-addr cast. pointer must be thin.
...
...
src/librustc_typeck/check/coercion.rs
浏览文件 @
1a268f4d
...
...
@@ -66,7 +66,7 @@
use
middle
::
traits
::{
self
,
ObligationCause
};
use
middle
::
traits
::{
predicate_for_trait_def
,
report_selection_error
};
use
middle
::
ty
::{
AutoDerefRef
,
AdjustDerefRef
};
use
middle
::
ty
::{
self
,
Type
WithMutability
,
Ty
,
TypeError
};
use
middle
::
ty
::{
self
,
Type
AndMut
,
Ty
,
TypeError
};
use
middle
::
ty_relate
::
RelateResult
;
use
util
::
common
::
indent
;
...
...
@@ -202,7 +202,7 @@ fn coerce_borrowed_pointer(&self,
return
None
;
}
let
ty
=
self
.tcx
()
.mk_ref
(
r_borrow
,
Type
WithMutability
{
ty
:
inner_ty
,
mutbl
:
mutbl_b
});
Type
AndMut
{
ty
:
inner_ty
,
mutbl
:
mutbl_b
});
if
let
Err
(
err
)
=
self
.subtype
(
ty
,
b
)
{
if
first_error
.is_none
()
{
first_error
=
Some
(
err
);
...
...
@@ -411,7 +411,7 @@ fn coerce_unsafe_ptr(&self,
};
// Check that the types which they point at are compatible.
let
a_unsafe
=
self
.tcx
()
.mk_ptr
(
ty
::
Type
WithMutability
{
mutbl
:
mutbl_b
,
ty
:
mt_a
.ty
});
let
a_unsafe
=
self
.tcx
()
.mk_ptr
(
ty
::
Type
AndMut
{
mutbl
:
mutbl_b
,
ty
:
mt_a
.ty
});
try!
(
self
.subtype
(
a_unsafe
,
b
));
try!
(
coerce_mutbls
(
mt_a
.mutbl
,
mutbl_b
));
...
...
src/librustc_typeck/check/method/confirm.rs
浏览文件 @
1a268f4d
...
...
@@ -433,7 +433,7 @@ fn fixup_derefs_on_method_receiver_if_necessary(&self,
};
match
sig
.0
.inputs
[
0
]
.sty
{
ty
::
TyRef
(
_
,
ty
::
Type
WithMutability
{
ty
::
TyRef
(
_
,
ty
::
Type
AndMut
{
ty
:
_
,
mutbl
:
ast
::
MutMutable
,
})
=>
{}
...
...
src/librustc_typeck/check/method/mod.rs
浏览文件 @
1a268f4d
...
...
@@ -271,7 +271,7 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
// Trait method is fn(&self) or fn(&mut self), need an
// autoref. Pull the region etc out of the type of first argument.
match
transformed_self_ty
.sty
{
ty
::
TyRef
(
region
,
ty
::
Type
WithMutability
{
mutbl
,
ty
:
_
})
=>
{
ty
::
TyRef
(
region
,
ty
::
Type
AndMut
{
mutbl
,
ty
:
_
})
=>
{
fcx
.write_adjustment
(
self_expr
.id
,
ty
::
AdjustDerefRef
(
ty
::
AutoDerefRef
{
autoderefs
:
autoderefs
,
...
...
src/librustc_typeck/check/method/probe.rs
浏览文件 @
1a268f4d
...
...
@@ -311,11 +311,11 @@ fn assemble_probe(&mut self, self_ty: Ty<'tcx>) {
let
lang_def_id
=
self
.tcx
()
.lang_items
.slice_impl
();
self
.assemble_inherent_impl_for_primitive
(
lang_def_id
);
}
ty
::
TyRawPtr
(
ty
::
Type
WithMutability
{
ty
:
_
,
mutbl
:
ast
::
MutImmutable
})
=>
{
ty
::
TyRawPtr
(
ty
::
Type
AndMut
{
ty
:
_
,
mutbl
:
ast
::
MutImmutable
})
=>
{
let
lang_def_id
=
self
.tcx
()
.lang_items
.const_ptr_impl
();
self
.assemble_inherent_impl_for_primitive
(
lang_def_id
);
}
ty
::
TyRawPtr
(
ty
::
Type
WithMutability
{
ty
:
_
,
mutbl
:
ast
::
MutMutable
})
=>
{
ty
::
TyRawPtr
(
ty
::
Type
AndMut
{
ty
:
_
,
mutbl
:
ast
::
MutMutable
})
=>
{
let
lang_def_id
=
self
.tcx
()
.lang_items
.mut_ptr_impl
();
self
.assemble_inherent_impl_for_primitive
(
lang_def_id
);
}
...
...
@@ -951,7 +951,7 @@ fn pick_autorefd_method(&mut self,
// Search through mutabilities in order to find one where pick works:
[
ast
::
MutImmutable
,
ast
::
MutMutable
]
.iter
()
.filter_map
(|
&
m
|
{
let
autoref_ty
=
tcx
.mk_ref
(
region
,
ty
::
Type
WithMutability
{
let
autoref_ty
=
tcx
.mk_ref
(
region
,
ty
::
Type
AndMut
{
ty
:
step
.self_ty
,
mutbl
:
m
});
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
1a268f4d
...
...
@@ -1030,7 +1030,7 @@ fn report_cast_to_unsized_type<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
format!
(
"cast to unsized type: `{}` as `{}`"
,
actual
,
tstr
)
},
t_expr
,
None
);
match
t_expr
.sty
{
ty
::
TyRef
(
_
,
ty
::
Type
WithMutability
{
mutbl
:
mt
,
..
})
=>
{
ty
::
TyRef
(
_
,
ty
::
Type
AndMut
{
mutbl
:
mt
,
..
})
=>
{
let
mtstr
=
match
mt
{
ast
::
MutMutable
=>
"mut "
,
ast
::
MutImmutable
=>
""
...
...
@@ -1895,7 +1895,7 @@ fn try_overloaded_deref<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
base_expr
:
Option
<&
ast
::
Expr
>
,
base_ty
:
Ty
<
'tcx
>
,
lvalue_pref
:
LvaluePreference
)
->
Option
<
ty
::
Type
WithMutability
<
'tcx
>>
->
Option
<
ty
::
Type
AndMut
<
'tcx
>>
{
// Try DerefMut first, if preferred.
let
method
=
match
(
lvalue_pref
,
fcx
.tcx
()
.lang_items
.deref_mut_trait
())
{
...
...
@@ -1926,7 +1926,7 @@ fn try_overloaded_deref<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
fn
make_overloaded_lvalue_return_type
<
'a
,
'tcx
>
(
fcx
:
&
FnCtxt
<
'a
,
'tcx
>
,
method_call
:
Option
<
MethodCall
>
,
method
:
Option
<
MethodCallee
<
'tcx
>>
)
->
Option
<
ty
::
Type
WithMutability
<
'tcx
>>
->
Option
<
ty
::
Type
AndMut
<
'tcx
>>
{
match
method
{
Some
(
method
)
=>
{
...
...
@@ -3111,7 +3111,7 @@ fn check_struct_fields_on_error<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
hint
,
lvalue_pref
);
let
tm
=
ty
::
Type
WithMutability
{
ty
:
fcx
.expr_ty
(
&**
oprnd
),
mutbl
:
mutbl
};
let
tm
=
ty
::
Type
AndMut
{
ty
:
fcx
.expr_ty
(
&**
oprnd
),
mutbl
:
mutbl
};
let
oprnd_t
=
if
tm
.ty
.references_error
()
{
tcx
.types.err
}
else
{
...
...
@@ -4909,13 +4909,13 @@ fn param<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, n: u32) -> Ty<'tcx> {
"offset"
|
"arith_offset"
=>
{
(
1
,
vec!
(
tcx
.mk_ptr
(
ty
::
Type
WithMutability
{
tcx
.mk_ptr
(
ty
::
Type
AndMut
{
ty
:
param
(
ccx
,
0
),
mutbl
:
ast
::
MutImmutable
}),
ccx
.tcx.types.isize
),
tcx
.mk_ptr
(
ty
::
Type
WithMutability
{
tcx
.mk_ptr
(
ty
::
Type
AndMut
{
ty
:
param
(
ccx
,
0
),
mutbl
:
ast
::
MutImmutable
}))
...
...
@@ -4923,11 +4923,11 @@ fn param<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, n: u32) -> Ty<'tcx> {
"copy"
|
"copy_nonoverlapping"
=>
{
(
1
,
vec!
(
tcx
.mk_ptr
(
ty
::
Type
WithMutability
{
tcx
.mk_ptr
(
ty
::
Type
AndMut
{
ty
:
param
(
ccx
,
0
),
mutbl
:
ast
::
MutImmutable
}),
tcx
.mk_ptr
(
ty
::
Type
WithMutability
{
tcx
.mk_ptr
(
ty
::
Type
AndMut
{
ty
:
param
(
ccx
,
0
),
mutbl
:
ast
::
MutMutable
}),
...
...
@@ -4938,11 +4938,11 @@ fn param<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, n: u32) -> Ty<'tcx> {
"volatile_copy_memory"
|
"volatile_copy_nonoverlapping_memory"
=>
{
(
1
,
vec!
(
tcx
.mk_ptr
(
ty
::
Type
WithMutability
{
tcx
.mk_ptr
(
ty
::
Type
AndMut
{
ty
:
param
(
ccx
,
0
),
mutbl
:
ast
::
MutMutable
}),
tcx
.mk_ptr
(
ty
::
Type
WithMutability
{
tcx
.mk_ptr
(
ty
::
Type
AndMut
{
ty
:
param
(
ccx
,
0
),
mutbl
:
ast
::
MutImmutable
}),
...
...
@@ -4953,7 +4953,7 @@ fn param<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, n: u32) -> Ty<'tcx> {
"write_bytes"
|
"volatile_set_memory"
=>
{
(
1
,
vec!
(
tcx
.mk_ptr
(
ty
::
Type
WithMutability
{
tcx
.mk_ptr
(
ty
::
Type
AndMut
{
ty
:
param
(
ccx
,
0
),
mutbl
:
ast
::
MutMutable
}),
...
...
src/librustc_typeck/coherence/mod.rs
浏览文件 @
1a268f4d
...
...
@@ -450,7 +450,7 @@ fn check_implementations_of_coerce_unsized(&self) {
let
infcx
=
new_infer_ctxt
(
tcx
,
&
tcx
.tables
,
Some
(
param_env
),
true
);
let
check_mutbl
=
|
mt_a
:
ty
::
Type
WithMutability
<
'tcx
>
,
mt_b
:
ty
::
TypeWithMutability
<
'tcx
>
,
let
check_mutbl
=
|
mt_a
:
ty
::
Type
AndMut
<
'tcx
>
,
mt_b
:
ty
::
TypeAndMut
<
'tcx
>
,
mk_ptr
:
&
Fn
(
Ty
<
'tcx
>
)
->
Ty
<
'tcx
>
|
{
if
(
mt_a
.mutbl
,
mt_b
.mutbl
)
==
(
ast
::
MutImmutable
,
ast
::
MutMutable
)
{
infcx
.report_mismatched_types
(
span
,
mk_ptr
(
mt_b
.ty
),
...
...
src/librustc_typeck/coherence/orphan.rs
浏览文件 @
1a268f4d
...
...
@@ -100,14 +100,14 @@ fn check_item(&self, item: &ast::Item) {
"[T]"
,
item
.span
);
}
ty
::
TyRawPtr
(
ty
::
Type
WithMutability
{
ty
:
_
,
mutbl
:
ast
::
MutImmutable
})
=>
{
ty
::
TyRawPtr
(
ty
::
Type
AndMut
{
ty
:
_
,
mutbl
:
ast
::
MutImmutable
})
=>
{
self
.check_primitive_impl
(
def_id
,
self
.tcx.lang_items
.const_ptr_impl
(),
"const_ptr"
,
"*const T"
,
item
.span
);
}
ty
::
TyRawPtr
(
ty
::
Type
WithMutability
{
ty
:
_
,
mutbl
:
ast
::
MutMutable
})
=>
{
ty
::
TyRawPtr
(
ty
::
Type
AndMut
{
ty
:
_
,
mutbl
:
ast
::
MutMutable
})
=>
{
self
.check_primitive_impl
(
def_id
,
self
.tcx.lang_items
.mut_ptr_impl
(),
"mut_ptr"
,
...
...
src/librustc_typeck/variance.rs
浏览文件 @
1a268f4d
...
...
@@ -1074,7 +1074,7 @@ fn add_constraints_from_region(&mut self,
/// appearing in a context with ambient variance `variance`
fn
add_constraints_from_mt
(
&
mut
self
,
generics
:
&
ty
::
Generics
<
'tcx
>
,
mt
:
&
ty
::
Type
WithMutability
<
'tcx
>
,
mt
:
&
ty
::
Type
AndMut
<
'tcx
>
,
variance
:
VarianceTermPtr
<
'a
>
)
{
match
mt
.mutbl
{
ast
::
MutMutable
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录