Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
bdf5b6c3
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,发现更多精彩内容 >>
提交
bdf5b6c3
编写于
7月 12, 2014
作者:
B
Ben Gamari
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
middle: Derive Show impls
And change some uses of the `{:?}` format string to `{}`.
上级
69ffcdcc
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
35 addition
and
21 deletion
+35
-21
src/librustc/middle/def.rs
src/librustc/middle/def.rs
+2
-2
src/librustc/middle/kind.rs
src/librustc/middle/kind.rs
+1
-1
src/librustc/middle/subst.rs
src/librustc/middle/subst.rs
+14
-2
src/librustc/middle/ty.rs
src/librustc/middle/ty.rs
+14
-13
src/librustc/middle/typeck/astconv.rs
src/librustc/middle/typeck/astconv.rs
+3
-2
src/librustc/middle/typeck/infer/region_inference/mod.rs
src/librustc/middle/typeck/infer/region_inference/mod.rs
+1
-1
未找到文件。
src/librustc/middle/def.rs
浏览文件 @
bdf5b6c3
...
...
@@ -14,7 +14,7 @@
use
std
::
gc
::
Gc
;
#[deriving(Clone,
PartialEq,
Eq,
Encodable,
Decodable,
Hash)]
#[deriving(Clone,
PartialEq,
Eq,
Encodable,
Decodable,
Hash
,
Show
)]
pub
enum
Def
{
DefFn
(
ast
::
DefId
,
ast
::
FnStyle
),
DefStaticMethod
(
/* method */
ast
::
DefId
,
MethodProvenance
,
ast
::
FnStyle
),
...
...
@@ -51,7 +51,7 @@ pub enum Def {
DefMethod
(
ast
::
DefId
/* method */
,
Option
<
ast
::
DefId
>
/* trait */
),
}
#[deriving(Clone,
PartialEq,
Eq,
Encodable,
Decodable,
Hash)]
#[deriving(Clone,
PartialEq,
Eq,
Encodable,
Decodable,
Hash
,
Show
)]
pub
enum
MethodProvenance
{
FromTrait
(
ast
::
DefId
),
FromImpl
(
ast
::
DefId
),
...
...
src/librustc/middle/kind.rs
浏览文件 @
bdf5b6c3
...
...
@@ -121,7 +121,7 @@ fn check_impl_of_trait(cx: &mut Context, it: &Item, trait_ref: &TraitRef, self_t
// If this trait has builtin-kind supertraits, meet them.
let
self_ty
:
ty
::
t
=
ty
::
node_id_to_type
(
cx
.tcx
,
it
.id
);
debug!
(
"checking impl with self type {
:?
}"
,
ty
::
get
(
self_ty
)
.sty
);
debug!
(
"checking impl with self type {}"
,
ty
::
get
(
self_ty
)
.sty
);
check_builtin_bounds
(
cx
,
self_ty
,
trait_def
.bounds
,
|
missing
|
{
cx
.tcx.sess
.span_err
(
self_type
.span
,
format!
(
"the type `{}', which does not fulfill `{}`, cannot implement this
\
...
...
src/librustc/middle/subst.rs
浏览文件 @
bdf5b6c3
...
...
@@ -15,6 +15,7 @@
use
middle
::
ty_fold
::{
TypeFoldable
,
TypeFolder
};
use
util
::
ppaux
::
Repr
;
use
std
::
fmt
;
use
std
::
mem
;
use
std
::
raw
;
use
std
::
slice
::{
Items
,
MutItems
};
...
...
@@ -83,7 +84,7 @@ fn get_mut<'a>(&'a mut self, index: uint) -> Option<&'a mut T> {
* space* (which indices where the parameter is defined; see
* `ParamSpace`).
*/
#[deriving(Clone,
PartialEq,
Eq,
Hash)]
#[deriving(Clone,
PartialEq,
Eq,
Hash
,
Show
)]
pub
struct
Substs
{
pub
types
:
VecPerParamSpace
<
ty
::
t
>
,
pub
regions
:
RegionSubsts
,
...
...
@@ -93,7 +94,7 @@ pub struct Substs {
* Represents the values to use when substituting lifetime parameters.
* If the value is `ErasedRegions`, then this subst is occurring during
* trans, and all region parameters will be replaced with `ty::ReStatic`. */
#[deriving(Clone,
PartialEq,
Eq,
Hash)]
#[deriving(Clone,
PartialEq,
Eq,
Hash
,
Show
)]
pub
enum
RegionSubsts
{
ErasedRegions
,
NonerasedRegions
(
VecPerParamSpace
<
ty
::
Region
>
)
...
...
@@ -275,6 +276,17 @@ pub struct VecPerParamSpace<T> {
content
:
Vec
<
T
>
,
}
impl
<
T
:
fmt
::
Show
>
fmt
::
Show
for
VecPerParamSpace
<
T
>
{
fn
fmt
(
&
self
,
fmt
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
try!
(
write!
(
fmt
,
"VecPerParamSpace {{"
));
for
space
in
ParamSpace
::
all
()
.iter
()
{
try!
(
write!
(
fmt
,
"{}: {}, "
,
*
space
,
self
.get_slice
(
*
space
)));
}
try!
(
write!
(
fmt
,
"}}"
));
Ok
(())
}
}
impl
<
T
:
Clone
>
VecPerParamSpace
<
T
>
{
pub
fn
push_all
(
&
mut
self
,
space
:
ParamSpace
,
values
:
&
[
T
])
{
// FIXME (#15435): slow; O(n^2); could enhance vec to make it O(n).
...
...
src/librustc/middle/ty.rs
浏览文件 @
bdf5b6c3
...
...
@@ -124,7 +124,7 @@ pub fn container_id(&self) -> ast::DefId {
}
}
#[deriving(Clone,
PartialEq,
Eq,
Hash)]
#[deriving(Clone,
PartialEq,
Eq,
Hash
,
Show
)]
pub
struct
mt
{
pub
ty
:
t
,
pub
mutbl
:
ast
::
Mutability
,
...
...
@@ -138,7 +138,7 @@ pub enum TraitStore {
RegionTraitStore
(
Region
,
ast
::
Mutability
),
}
#[deriving(Clone)]
#[deriving(Clone
,
Show
)]
pub
struct
field_ty
{
pub
name
:
Name
,
pub
id
:
DefId
,
...
...
@@ -394,6 +394,7 @@ pub enum tbox_flag {
pub
type
t_box
=
&
'static
t_box_
;
#[deriving(Show)]
pub
struct
t_box_
{
pub
sty
:
sty
,
pub
id
:
uint
,
...
...
@@ -436,14 +437,14 @@ pub fn type_needs_infer(t: t) -> bool {
}
pub
fn
type_id
(
t
:
t
)
->
uint
{
get
(
t
)
.id
}
#[deriving(Clone,
PartialEq,
Eq,
Hash)]
#[deriving(Clone,
PartialEq,
Eq,
Hash
,
Show
)]
pub
struct
BareFnTy
{
pub
fn_style
:
ast
::
FnStyle
,
pub
abi
:
abi
::
Abi
,
pub
sig
:
FnSig
,
}
#[deriving(Clone,
PartialEq,
Eq,
Hash)]
#[deriving(Clone,
PartialEq,
Eq,
Hash
,
Show
)]
pub
struct
ClosureTy
{
pub
fn_style
:
ast
::
FnStyle
,
pub
onceness
:
ast
::
Onceness
,
...
...
@@ -472,7 +473,7 @@ pub struct FnSig {
pub
variadic
:
bool
}
#[deriving(Clone,
PartialEq,
Eq,
Hash)]
#[deriving(Clone,
PartialEq,
Eq,
Hash
,
Show
)]
pub
struct
ParamTy
{
pub
space
:
subst
::
ParamSpace
,
pub
idx
:
uint
,
...
...
@@ -712,7 +713,7 @@ mod primitives {
// NB: If you change this, you'll probably want to change the corresponding
// AST structure in libsyntax/ast.rs as well.
#[deriving(Clone,
PartialEq,
Eq,
Hash)]
#[deriving(Clone,
PartialEq,
Eq,
Hash
,
Show
)]
pub
enum
sty
{
ty_nil
,
ty_bot
,
...
...
@@ -741,14 +742,14 @@ pub enum sty {
// on non-useful type error messages)
}
#[deriving(Clone,
PartialEq,
Eq,
Hash)]
#[deriving(Clone,
PartialEq,
Eq,
Hash
,
Show
)]
pub
struct
TyTrait
{
pub
def_id
:
DefId
,
pub
substs
:
Substs
,
pub
bounds
:
BuiltinBounds
}
#[deriving(PartialEq,
Eq,
Hash)]
#[deriving(PartialEq,
Eq,
Hash
,
Show
)]
pub
struct
TraitRef
{
pub
def_id
:
DefId
,
pub
substs
:
Substs
,
...
...
@@ -808,7 +809,7 @@ pub enum type_err {
terr_variadic_mismatch
(
expected_found
<
bool
>
)
}
#[deriving(PartialEq,
Eq,
Hash)]
#[deriving(PartialEq,
Eq,
Hash
,
Show
)]
pub
struct
ParamBounds
{
pub
builtin_bounds
:
BuiltinBounds
,
pub
trait_bounds
:
Vec
<
Rc
<
TraitRef
>>
...
...
@@ -948,7 +949,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
}
}
#[deriving(Clone)]
#[deriving(Clone
,
Show
)]
pub
struct
TypeParameterDef
{
pub
ident
:
ast
::
Ident
,
pub
def_id
:
ast
::
DefId
,
...
...
@@ -958,7 +959,7 @@ pub struct TypeParameterDef {
pub
default
:
Option
<
ty
::
t
>
}
#[deriving(Encodable,
Decodable,
Clone)]
#[deriving(Encodable,
Decodable,
Clone
,
Show
)]
pub
struct
RegionParameterDef
{
pub
name
:
ast
::
Name
,
pub
def_id
:
ast
::
DefId
,
...
...
@@ -968,7 +969,7 @@ pub struct RegionParameterDef {
/// Information about the type/lifetime parameters associated with an
/// item or method. Analogous to ast::Generics.
#[deriving(Clone)]
#[deriving(Clone
,
Show
)]
pub
struct
Generics
{
pub
types
:
VecPerParamSpace
<
TypeParameterDef
>
,
pub
regions
:
VecPerParamSpace
<
RegionParameterDef
>
,
...
...
@@ -1014,7 +1015,7 @@ pub struct ParameterEnvironment {
/// - `generics`: the set of type parameters and their bounds
/// - `ty`: the base types, which may reference the parameters defined
/// in `generics`
#[deriving(Clone)]
#[deriving(Clone
,
Show
)]
pub
struct
Polytype
{
pub
generics
:
Generics
,
pub
ty
:
t
...
...
src/librustc/middle/typeck/astconv.rs
浏览文件 @
bdf5b6c3
...
...
@@ -141,7 +141,7 @@ pub fn opt_ast_region_to_region<AC:AstConv,RS:RegionScope>(
}
};
debug!
(
"opt_ast_region_to_region(opt_lifetime={
:?
}) yields {}"
,
debug!
(
"opt_ast_region_to_region(opt_lifetime={}) yields {}"
,
opt_lifetime
.as_ref
()
.map
(|
e
|
lifetime_to_string
(
e
)),
r
.repr
(
this
.tcx
()));
...
...
@@ -504,6 +504,7 @@ pub fn ast_ty_to_builtin_ty<AC:AstConv,
}
}
#[deriving(Show)]
enum
PointerTy
{
Box
,
RPtr
(
ty
::
Region
),
...
...
@@ -565,7 +566,7 @@ fn mk_pointer<AC:AstConv,
constr
:
|
ty
::
t
|
->
ty
::
t
)
->
ty
::
t
{
let
tcx
=
this
.tcx
();
debug!
(
"mk_pointer(ptr_ty={
:?
})"
,
ptr_ty
);
debug!
(
"mk_pointer(ptr_ty={})"
,
ptr_ty
);
match
a_seq_ty
.ty.node
{
ast
::
TyVec
(
ref
ty
)
=>
{
...
...
src/librustc/middle/typeck/infer/region_inference/mod.rs
浏览文件 @
bdf5b6c3
...
...
@@ -246,7 +246,7 @@ pub fn new_region_var(&self, origin: RegionVariableOrigin) -> RegionVid {
if
self
.in_snapshot
()
{
self
.undo_log
.borrow_mut
()
.push
(
AddVar
(
vid
));
}
debug!
(
"created new region variable {
:?} with origin {:?
}"
,
debug!
(
"created new region variable {
} with origin {
}"
,
vid
,
origin
.repr
(
self
.tcx
));
return
vid
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录