Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
5f64adc4
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,发现更多精彩内容 >>
提交
5f64adc4
编写于
3月 08, 2014
作者:
B
bors
浏览文件
操作
浏览文件
下载
差异文件
auto merge of #12706 : pongad/rust/issue_12698, r=brson
Fixes #12698
上级
e1681df8
438893b3
变更
28
隐藏空白更改
内联
并排
Showing
28 changed file
with
36 addition
and
367 deletion
+36
-367
src/libstd/cell.rs
src/libstd/cell.rs
+1
-8
src/libstd/clone.rs
src/libstd/clone.rs
+0
-100
src/libstd/gc.rs
src/libstd/gc.rs
+1
-22
src/libstd/iter.rs
src/libstd/iter.rs
+6
-6
src/libstd/num/mod.rs
src/libstd/num/mod.rs
+1
-2
src/libstd/option.rs
src/libstd/option.rs
+3
-4
src/libstd/path/posix.rs
src/libstd/path/posix.rs
+1
-1
src/libstd/path/windows.rs
src/libstd/path/windows.rs
+2
-2
src/libstd/prelude.rs
src/libstd/prelude.rs
+1
-1
src/libstd/rc.rs
src/libstd/rc.rs
+1
-18
src/libstd/result.rs
src/libstd/result.rs
+1
-1
src/libstd/str.rs
src/libstd/str.rs
+1
-25
src/libstd/vec.rs
src/libstd/vec.rs
+1
-19
src/libsyntax/ext/deriving/clone.rs
src/libsyntax/ext/deriving/clone.rs
+0
-30
src/libsyntax/ext/deriving/mod.rs
src/libsyntax/ext/deriving/mod.rs
+0
-1
src/libtime/lib.rs
src/libtime/lib.rs
+2
-2
src/test/compile-fail/deriving-span-DeepClone-enum-struct-variant.rs
...mpile-fail/deriving-span-DeepClone-enum-struct-variant.rs
+0
-26
src/test/compile-fail/deriving-span-DeepClone-enum.rs
src/test/compile-fail/deriving-span-DeepClone-enum.rs
+0
-26
src/test/compile-fail/deriving-span-DeepClone-struct.rs
src/test/compile-fail/deriving-span-DeepClone-struct.rs
+0
-24
src/test/compile-fail/deriving-span-DeepClone-tuple-struct.rs
...test/compile-fail/deriving-span-DeepClone-tuple-struct.rs
+0
-24
src/test/run-pass/deriving-clone-enum.rs
src/test/run-pass/deriving-clone-enum.rs
+1
-2
src/test/run-pass/deriving-clone-generic-enum.rs
src/test/run-pass/deriving-clone-generic-enum.rs
+1
-2
src/test/run-pass/deriving-clone-generic-struct.rs
src/test/run-pass/deriving-clone-generic-struct.rs
+2
-2
src/test/run-pass/deriving-clone-generic-tuple-struct.rs
src/test/run-pass/deriving-clone-generic-tuple-struct.rs
+2
-2
src/test/run-pass/deriving-clone-struct.rs
src/test/run-pass/deriving-clone-struct.rs
+1
-1
src/test/run-pass/deriving-global.rs
src/test/run-pass/deriving-global.rs
+3
-3
src/test/run-pass/send_str_hashmap.rs
src/test/run-pass/send_str_hashmap.rs
+2
-7
src/test/run-pass/send_str_treemap.rs
src/test/run-pass/send_str_treemap.rs
+2
-6
未找到文件。
src/libstd/cell.rs
浏览文件 @
5f64adc4
...
...
@@ -11,7 +11,7 @@
//! Types dealing with dynamic mutability
use
cast
;
use
clone
::
{
Clone
,
DeepClone
}
;
use
clone
::
Clone
;
use
cmp
::
Eq
;
use
fmt
;
use
kinds
::{
marker
,
Pod
};
...
...
@@ -222,13 +222,6 @@ fn clone(&self) -> RefCell<T> {
}
}
impl
<
T
:
DeepClone
>
DeepClone
for
RefCell
<
T
>
{
fn
deep_clone
(
&
self
)
->
RefCell
<
T
>
{
let
x
=
self
.borrow
();
RefCell
::
new
(
x
.get
()
.deep_clone
())
}
}
impl
<
T
:
Eq
>
Eq
for
RefCell
<
T
>
{
fn
eq
(
&
self
,
other
:
&
RefCell
<
T
>
)
->
bool
{
let
a
=
self
.borrow
();
...
...
src/libstd/clone.rs
浏览文件 @
5f64adc4
...
...
@@ -21,8 +21,6 @@
*/
use
std
::
kinds
::
Freeze
;
/// A common trait for cloning an object.
pub
trait
Clone
{
/// Returns a copy of the value. The contents of owned pointers
...
...
@@ -125,92 +123,6 @@ fn clone(&self) -> extern "Rust" fn($($A),*) -> ReturnType { *self }
extern_fn_clone!
(
A
,
B
,
C
,
D
,
E
,
F
,
G
)
extern_fn_clone!
(
A
,
B
,
C
,
D
,
E
,
F
,
G
,
H
)
/// A trait distinct from `Clone` which represents "deep copies" of things like
/// managed boxes which would otherwise not be copied.
pub
trait
DeepClone
:
Clone
{
/// Return a deep copy of the value. Unlike `Clone`, the contents of shared pointer types
/// *are* copied.
fn
deep_clone
(
&
self
)
->
Self
;
/// Perform deep copy-assignment from `source`.
///
/// `a.deep_clone_from(&b)` is equivalent to `a = b.deep_clone()` in
/// functionality, but can be overridden to reuse the resources of `a` to
/// avoid unnecessary allocations.
#[inline(always)]
fn
deep_clone_from
(
&
mut
self
,
source
:
&
Self
)
{
*
self
=
source
.deep_clone
()
}
}
impl
<
T
:
DeepClone
>
DeepClone
for
~
T
{
/// Return a deep copy of the owned box.
#[inline]
fn
deep_clone
(
&
self
)
->
~
T
{
~
(
**
self
)
.deep_clone
()
}
/// Perform deep copy-assignment from `source` by reusing the existing allocation.
fn
deep_clone_from
(
&
mut
self
,
source
:
&~
T
)
{
**
self
=
(
**
source
)
.deep_clone
()
}
}
// FIXME: #6525: should also be implemented for `T: Send + DeepClone`
impl
<
T
:
Freeze
+
DeepClone
+
'static
>
DeepClone
for
@
T
{
/// Return a deep copy of the managed box. The `Freeze` trait is required to prevent performing
/// a deep clone of a potentially cyclical type.
#[inline]
fn
deep_clone
(
&
self
)
->
@
T
{
@
(
**
self
)
.deep_clone
()
}
}
macro_rules!
deep_clone_impl
(
(
$t:ty
)
=>
{
impl
DeepClone
for
$t
{
/// Return a deep copy of the value.
#[inline]
fn
deep_clone
(
&
self
)
->
$t
{
*
self
}
}
}
)
deep_clone_impl!
(
int
)
deep_clone_impl!
(
i8
)
deep_clone_impl!
(
i16
)
deep_clone_impl!
(
i32
)
deep_clone_impl!
(
i64
)
deep_clone_impl!
(
uint
)
deep_clone_impl!
(
u8
)
deep_clone_impl!
(
u16
)
deep_clone_impl!
(
u32
)
deep_clone_impl!
(
u64
)
deep_clone_impl!
(
f32
)
deep_clone_impl!
(
f64
)
deep_clone_impl!
(())
deep_clone_impl!
(
bool
)
deep_clone_impl!
(
char
)
macro_rules!
extern_fn_deep_clone
(
(
$
(
$A:ident
),
*
)
=>
(
impl
<
$
(
$A
,)
*
ReturnType
>
DeepClone
for
extern
"Rust"
fn
(
$
(
$A
),
*
)
->
ReturnType
{
/// Return a copy of a function pointer
#[inline]
fn
deep_clone
(
&
self
)
->
extern
"Rust"
fn
(
$
(
$A
),
*
)
->
ReturnType
{
*
self
}
}
)
)
extern_fn_deep_clone!
()
extern_fn_deep_clone!
(
A
)
extern_fn_deep_clone!
(
A
,
B
)
extern_fn_deep_clone!
(
A
,
B
,
C
)
extern_fn_deep_clone!
(
A
,
B
,
C
,
D
)
extern_fn_deep_clone!
(
A
,
B
,
C
,
D
,
E
)
extern_fn_deep_clone!
(
A
,
B
,
C
,
D
,
E
,
F
)
extern_fn_deep_clone!
(
A
,
B
,
C
,
D
,
E
,
F
,
G
)
extern_fn_deep_clone!
(
A
,
B
,
C
,
D
,
E
,
F
,
G
,
H
)
#[test]
fn
test_owned_clone
()
{
let
a
=
~
5
i
;
...
...
@@ -241,14 +153,6 @@ fn test_clone_from() {
assert_eq!
(
*
b
,
5
);
}
#[test]
fn
test_deep_clone_from
()
{
let
a
=
~
5
;
let
mut
b
=
~
10
;
b
.deep_clone_from
(
&
a
);
assert_eq!
(
*
b
,
5
);
}
#[test]
fn
test_extern_fn_clone
()
{
trait
Empty
{}
...
...
@@ -261,8 +165,4 @@ fn test_fn_c(_: int, _: f64, _: ~[int], _: int, _: int, _: int) {}
let
_
=
test_fn_a
.clone
();
let
_
=
test_fn_b
::
<
int
>
.clone
();
let
_
=
test_fn_c
.clone
();
let
_
=
test_fn_a
.deep_clone
();
let
_
=
test_fn_b
::
<
int
>
.deep_clone
();
let
_
=
test_fn_c
.deep_clone
();
}
src/libstd/gc.rs
浏览文件 @
5f64adc4
...
...
@@ -19,8 +19,7 @@
#[allow(experimental)]
;
use
kinds
::
marker
;
use
kinds
::
Send
;
use
clone
::{
Clone
,
DeepClone
};
use
clone
::
Clone
;
use
managed
;
/// Immutable garbage-collected pointer type
...
...
@@ -78,16 +77,6 @@ fn clone(&self) -> Gc<T> {
#[cfg(test)]
pub
static
GC
:
()
=
();
/// The `Send` bound restricts this to acyclic graphs where it is well-defined.
///
/// A `Freeze` bound would also work, but `Send` *or* `Freeze` cannot be expressed.
impl
<
T
:
DeepClone
+
Send
+
'static
>
DeepClone
for
Gc
<
T
>
{
#[inline]
fn
deep_clone
(
&
self
)
->
Gc
<
T
>
{
Gc
::
new
(
self
.borrow
()
.deep_clone
())
}
}
#[cfg(test)]
mod
tests
{
use
prelude
::
*
;
...
...
@@ -104,16 +93,6 @@ fn test_clone() {
assert_eq!
(
y
.borrow
()
.with
(|
x
|
*
x
),
20
);
}
#[test]
fn
test_deep_clone
()
{
let
x
=
Gc
::
new
(
RefCell
::
new
(
5
));
let
y
=
x
.deep_clone
();
x
.borrow
()
.with_mut
(|
inner
|
{
*
inner
=
20
;
});
assert_eq!
(
y
.borrow
()
.with
(|
x
|
*
x
),
5
);
}
#[test]
fn
test_simple
()
{
let
x
=
Gc
::
new
(
5
);
...
...
src/libstd/iter.rs
浏览文件 @
5f64adc4
...
...
@@ -1757,7 +1757,7 @@ fn next_back(&mut self) -> Option<B> {
/// An iterator that yields `None` forever after the underlying iterator
/// yields `None` once.
#[deriving(Clone
,
DeepClone
)]
#[deriving(Clone)]
pub
struct
Fuse
<
T
>
{
priv
iter
:
T
,
priv
done
:
bool
...
...
@@ -1946,7 +1946,7 @@ fn size_hint(&self) -> (uint, Option<uint>) {
}
/// An iterator over the range [start, stop)
#[deriving(Clone
,
DeepClone
)]
#[deriving(Clone)]
pub
struct
Range
<
A
>
{
priv
state
:
A
,
priv
stop
:
A
,
...
...
@@ -2020,7 +2020,7 @@ fn next_back(&mut self) -> Option<A> {
}
/// An iterator over the range [start, stop]
#[deriving(Clone
,
DeepClone
)]
#[deriving(Clone)]
pub
struct
RangeInclusive
<
A
>
{
priv
range
:
Range
<
A
>
,
priv
done
:
bool
...
...
@@ -2083,7 +2083,7 @@ fn next_back(&mut self) -> Option<A> {
}
/// An iterator over the range [start, stop) by `step`. It handles overflow by stopping.
#[deriving(Clone
,
DeepClone
)]
#[deriving(Clone)]
pub
struct
RangeStep
<
A
>
{
priv
state
:
A
,
priv
stop
:
A
,
...
...
@@ -2115,7 +2115,7 @@ fn next(&mut self) -> Option<A> {
}
/// An iterator over the range [start, stop] by `step`. It handles overflow by stopping.
#[deriving(Clone
,
DeepClone
)]
#[deriving(Clone)]
pub
struct
RangeStepInclusive
<
A
>
{
priv
state
:
A
,
priv
stop
:
A
,
...
...
@@ -2150,7 +2150,7 @@ fn next(&mut self) -> Option<A> {
}
/// An iterator that repeats an element endlessly
#[deriving(Clone
,
DeepClone
)]
#[deriving(Clone)]
pub
struct
Repeat
<
A
>
{
priv
element
:
A
}
...
...
src/libstd/num/mod.rs
浏览文件 @
5f64adc4
...
...
@@ -15,7 +15,7 @@
#[allow(missing_doc)]
;
use
clone
::
{
Clone
,
DeepClone
}
;
use
clone
::
Clone
;
use
cmp
::{
Eq
,
Ord
};
use
kinds
::
Pod
;
use
mem
::
size_of
;
...
...
@@ -247,7 +247,6 @@ fn count_zeros(&self) -> Self {
/// may be useful for systems programming.
pub
trait
Primitive
:
Pod
+
Clone
+
DeepClone
+
Num
+
NumCast
+
Ord
...
...
src/libstd/option.rs
浏览文件 @
5f64adc4
...
...
@@ -39,8 +39,7 @@
use
any
::
Any
;
use
clone
::
Clone
;
use
clone
::
DeepClone
;
use
cmp
::{
Eq
,
TotalOrd
};
use
cmp
::{
Eq
,
TotalEq
,
TotalOrd
};
use
default
::
Default
;
use
iter
::{
Iterator
,
DoubleEndedIterator
,
FromIterator
,
ExactSize
};
use
kinds
::
Send
;
...
...
@@ -48,7 +47,7 @@
use
vec
;
/// The option type
#[deriving(Clone,
DeepClone,
Eq,
Ord,
TotalEq,
TotalOrd,
Show)]
#[deriving(Clone,
Eq,
Ord,
TotalEq,
TotalOrd,
Show)]
pub
enum
Option
<
T
>
{
/// No value
None
,
...
...
@@ -387,7 +386,7 @@ fn default() -> Option<T> { None }
/////////////////////////////////////////////////////////////////////////////
/// An iterator that yields either one or zero elements
#[deriving(Clone
,
DeepClone
)]
#[deriving(Clone)]
pub
struct
Item
<
A
>
{
priv
opt
:
Option
<
A
>
}
...
...
src/libstd/path/posix.rs
浏览文件 @
5f64adc4
...
...
@@ -38,7 +38,7 @@
RevComponents
<
'a
>>
;
/// Represents a POSIX file path
#[deriving(Clone
,
DeepClone
)]
#[deriving(Clone)]
pub
struct
Path
{
priv
repr
:
~
[
u8
],
// assumed to never be empty or contain NULs
priv
sepidx
:
Option
<
uint
>
// index of the final separator in repr
...
...
src/libstd/path/windows.rs
浏览文件 @
5f64adc4
...
...
@@ -79,7 +79,7 @@
//
// The only error condition imposed here is valid utf-8. All other invalid paths are simply
// preserved by the data structure; let the Windows API error out on them.
#[deriving(Clone
,
DeepClone
)]
#[deriving(Clone)]
pub
struct
Path
{
priv
repr
:
~
str
,
// assumed to never be empty
priv
prefix
:
Option
<
PathPrefix
>
,
...
...
@@ -942,7 +942,7 @@ pub fn is_sep_byte_verbatim(u: &u8) -> bool {
}
/// Prefix types for Path
#[deriving(Eq,
Clone
,
DeepClone
)]
#[deriving(Eq,
Clone)]
pub
enum
PathPrefix
{
/// Prefix `\\?\`, uint is the length of the following component
VerbatimPrefix
(
uint
),
...
...
src/libstd/prelude.rs
浏览文件 @
5f64adc4
...
...
@@ -38,7 +38,7 @@
pub
use
ascii
::{
Ascii
,
AsciiCast
,
OwnedAsciiCast
,
AsciiStr
,
IntoBytes
};
pub
use
c_str
::
ToCStr
;
pub
use
char
::
Char
;
pub
use
clone
::
{
Clone
,
DeepClone
}
;
pub
use
clone
::
Clone
;
pub
use
cmp
::{
Eq
,
Ord
,
TotalEq
,
TotalOrd
,
Ordering
,
Less
,
Equal
,
Greater
,
Equiv
};
pub
use
container
::{
Container
,
Mutable
,
Map
,
MutableMap
,
Set
,
MutableSet
};
pub
use
iter
::{
FromIterator
,
Extendable
};
...
...
src/libstd/rc.rs
浏览文件 @
5f64adc4
...
...
@@ -24,7 +24,7 @@
*/
use
cast
::
transmute
;
use
clone
::
{
Clone
,
DeepClone
}
;
use
clone
::
Clone
;
use
cmp
::{
Eq
,
Ord
};
use
kinds
::
marker
;
use
ops
::{
Deref
,
Drop
};
...
...
@@ -118,13 +118,6 @@ fn clone(&self) -> Rc<T> {
}
}
impl
<
T
:
DeepClone
>
DeepClone
for
Rc
<
T
>
{
#[inline]
fn
deep_clone
(
&
self
)
->
Rc
<
T
>
{
Rc
::
new
(
self
.borrow
()
.deep_clone
())
}
}
impl
<
T
:
Eq
>
Eq
for
Rc
<
T
>
{
#[inline(always)]
fn
eq
(
&
self
,
other
:
&
Rc
<
T
>
)
->
bool
{
*
self
.borrow
()
==
*
other
.borrow
()
}
...
...
@@ -210,16 +203,6 @@ fn test_clone() {
assert_eq!
(
y
.borrow
()
.with
(|
v
|
*
v
),
20
);
}
#[test]
fn
test_deep_clone
()
{
let
x
=
Rc
::
new
(
RefCell
::
new
(
5
));
let
y
=
x
.deep_clone
();
x
.borrow
()
.with_mut
(|
inner
|
{
*
inner
=
20
;
});
assert_eq!
(
y
.borrow
()
.with
(|
v
|
*
v
),
5
);
}
#[test]
fn
test_simple
()
{
let
x
=
Rc
::
new
(
5
);
...
...
src/libstd/result.rs
浏览文件 @
5f64adc4
...
...
@@ -16,7 +16,7 @@
use
option
::{
None
,
Option
,
Some
};
/// `Result` is a type that represents either success (`Ok`) or failure (`Err`).
#[deriving(Clone,
DeepClone,
Eq,
Ord,
TotalEq,
TotalOrd,
Show)]
#[deriving(Clone,
Eq,
Ord,
TotalEq,
TotalOrd,
Show)]
#[must_use]
pub
enum
Result
<
T
,
E
>
{
/// Contains the success value
...
...
src/libstd/str.rs
浏览文件 @
5f64adc4
...
...
@@ -85,7 +85,7 @@ fn main() {
use
cast
::
transmute
;
use
char
;
use
char
::
Char
;
use
clone
::
{
Clone
,
DeepClone
}
;
use
clone
::
Clone
;
use
cmp
::{
Eq
,
TotalEq
,
Ord
,
TotalOrd
,
Equiv
,
Ordering
};
use
container
::{
Container
,
Mutable
};
use
fmt
;
...
...
@@ -1326,16 +1326,6 @@ fn clone(&self) -> MaybeOwned<'a> {
}
}
impl
<
'a
>
DeepClone
for
MaybeOwned
<
'a
>
{
#[inline]
fn
deep_clone
(
&
self
)
->
MaybeOwned
<
'a
>
{
match
*
self
{
Slice
(
s
)
=>
Slice
(
s
),
Owned
(
ref
s
)
=>
Owned
(
s
.to_owned
())
}
}
}
impl
<
'a
>
Default
for
MaybeOwned
<
'a
>
{
#[inline]
fn
default
()
->
MaybeOwned
<
'a
>
{
Slice
(
""
)
}
...
...
@@ -3031,13 +3021,6 @@ fn clone(&self) -> ~str {
}
}
impl
DeepClone
for
~
str
{
#[inline]
fn
deep_clone
(
&
self
)
->
~
str
{
self
.to_owned
()
}
}
impl
FromIterator
<
char
>
for
~
str
{
#[inline]
fn
from_iterator
<
T
:
Iterator
<
char
>>
(
iterator
:
&
mut
T
)
->
~
str
{
...
...
@@ -4465,16 +4448,9 @@ fn test_maybe_owned_methods() {
#[test]
fn
test_maybe_owned_clone
()
{
assert_eq!
(
Owned
(
~
"abcde"
),
Slice
(
"abcde"
)
.clone
());
assert_eq!
(
Owned
(
~
"abcde"
),
Slice
(
"abcde"
)
.deep_clone
());
assert_eq!
(
Owned
(
~
"abcde"
),
Owned
(
~
"abcde"
)
.clone
());
assert_eq!
(
Owned
(
~
"abcde"
),
Owned
(
~
"abcde"
)
.deep_clone
());
assert_eq!
(
Slice
(
"abcde"
),
Slice
(
"abcde"
)
.clone
());
assert_eq!
(
Slice
(
"abcde"
),
Slice
(
"abcde"
)
.deep_clone
());
assert_eq!
(
Slice
(
"abcde"
),
Owned
(
~
"abcde"
)
.clone
());
assert_eq!
(
Slice
(
"abcde"
),
Owned
(
~
"abcde"
)
.deep_clone
());
}
#[test]
...
...
src/libstd/vec.rs
浏览文件 @
5f64adc4
...
...
@@ -104,7 +104,7 @@
use
cast
;
use
cast
::
transmute
;
use
ops
::
Drop
;
use
clone
::
{
Clone
,
DeepClone
}
;
use
clone
::
Clone
;
use
container
::{
Container
,
Mutable
};
use
cmp
::{
Eq
,
TotalOrd
,
Ordering
,
Less
,
Equal
,
Greater
};
use
cmp
;
...
...
@@ -2635,24 +2635,6 @@ fn clone_from(&mut self, source: &~[A]) {
}
}
impl
<
A
:
DeepClone
>
DeepClone
for
~
[
A
]
{
#[inline]
fn
deep_clone
(
&
self
)
->
~
[
A
]
{
self
.iter
()
.map
(|
item
|
item
.deep_clone
())
.collect
()
}
fn
deep_clone_from
(
&
mut
self
,
source
:
&~
[
A
])
{
if
self
.len
()
<
source
.len
()
{
*
self
=
source
.deep_clone
()
}
else
{
self
.truncate
(
source
.len
());
for
(
x
,
y
)
in
self
.mut_iter
()
.zip
(
source
.iter
())
{
x
.deep_clone_from
(
y
);
}
}
}
}
impl
<
'a
,
T
:
fmt
::
Show
>
fmt
::
Show
for
&
'a
[
T
]
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
try!
(
write!
(
f
.buf
,
"["
));
...
...
src/libsyntax/ext/deriving/clone.rs
浏览文件 @
5f64adc4
...
...
@@ -44,36 +44,6 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt,
trait_def
.expand
(
cx
,
mitem
,
item
,
push
)
}
pub
fn
expand_deriving_deep_clone
(
cx
:
&
mut
ExtCtxt
,
span
:
Span
,
mitem
:
@
MetaItem
,
item
:
@
Item
,
push
:
|
@
Item
|)
{
let
trait_def
=
TraitDef
{
span
:
span
,
attributes
:
Vec
::
new
(),
path
:
Path
::
new
(
vec!
(
"std"
,
"clone"
,
"DeepClone"
)),
additional_bounds
:
Vec
::
new
(),
generics
:
LifetimeBounds
::
empty
(),
methods
:
vec!
(
MethodDef
{
name
:
"deep_clone"
,
generics
:
LifetimeBounds
::
empty
(),
explicit_self
:
borrowed_explicit_self
(),
args
:
Vec
::
new
(),
ret_ty
:
Self
,
inline
:
true
,
const_nonmatching
:
false
,
// cs_clone uses the ident passed to it, i.e. it will
// call deep_clone (not clone) here.
combine_substructure
:
|
c
,
s
,
sub
|
cs_clone
(
"DeepClone"
,
c
,
s
,
sub
)
}
)
};
trait_def
.expand
(
cx
,
mitem
,
item
,
push
)
}
fn
cs_clone
(
name
:
&
str
,
cx
:
&
mut
ExtCtxt
,
trait_span
:
Span
,
...
...
src/libsyntax/ext/deriving/mod.rs
浏览文件 @
5f64adc4
...
...
@@ -70,7 +70,6 @@ pub fn expand_meta_deriving(cx: &mut ExtCtxt,
|
i
|
push
(
i
))));
match
tname
.get
()
{
"Clone"
=>
expand!
(
clone
::
expand_deriving_clone
),
"DeepClone"
=>
expand!
(
clone
::
expand_deriving_deep_clone
),
"Hash"
=>
expand!
(
hash
::
expand_deriving_hash
),
...
...
src/libtime/lib.rs
浏览文件 @
5f64adc4
...
...
@@ -64,7 +64,7 @@ mod imp {
/// A record specifying a time value in seconds and nanoseconds.
#[deriving(Clone,
DeepClone,
Eq,
Encodable,
Decodable,
Show)]
#[deriving(Clone,
Eq,
Encodable,
Decodable,
Show)]
pub
struct
Timespec
{
sec
:
i64
,
nsec
:
i32
}
/*
* Timespec assumes that pre-epoch Timespecs have negative sec and positive
...
...
@@ -191,7 +191,7 @@ pub fn tzset() {
}
}
#[deriving(Clone,
DeepClone,
Eq,
Encodable,
Decodable,
Show)]
#[deriving(Clone,
Eq,
Encodable,
Decodable,
Show)]
pub
struct
Tm
{
tm_sec
:
i32
,
// seconds after the minute ~[0-60]
tm_min
:
i32
,
// minutes after the hour ~[0-59]
...
...
src/test/compile-fail/deriving-span-DeepClone-enum-struct-variant.rs
已删除
100644 → 0
浏览文件 @
e1681df8
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
#[feature(struct_variant)]
;
extern
crate
extra
;
#[deriving(Clone)]
struct
Error
;
#[deriving(DeepClone,Clone)]
enum
Enum
{
A
{
x
:
Error
//~ ERROR
}
}
fn
main
()
{}
src/test/compile-fail/deriving-span-DeepClone-enum.rs
已删除
100644 → 0
浏览文件 @
e1681df8
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
#[feature(struct_variant)]
;
extern
crate
extra
;
#[deriving(Clone)]
struct
Error
;
#[deriving(DeepClone,Clone)]
enum
Enum
{
A
(
Error
//~ ERROR
)
}
fn
main
()
{}
src/test/compile-fail/deriving-span-DeepClone-struct.rs
已删除
100644 → 0
浏览文件 @
e1681df8
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
#[feature(struct_variant)]
;
extern
crate
extra
;
#[deriving(Clone)]
struct
Error
;
#[deriving(DeepClone,Clone)]
struct
Struct
{
x
:
Error
//~ ERROR
}
fn
main
()
{}
src/test/compile-fail/deriving-span-DeepClone-tuple-struct.rs
已删除
100644 → 0
浏览文件 @
e1681df8
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// This file was auto-generated using 'src/etc/generate-keyword-span-tests.py'
#[feature(struct_variant)]
;
extern
crate
extra
;
#[deriving(Clone)]
struct
Error
;
#[deriving(DeepClone,Clone)]
struct
Struct
(
Error
//~ ERROR
);
fn
main
()
{}
src/test/run-pass/deriving-clone-enum.rs
浏览文件 @
5f64adc4
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deriving(Clone
,
DeepClone
)]
#[deriving(Clone)]
enum
E
{
A
,
B
(()),
...
...
@@ -17,5 +17,4 @@ enum E {
pub
fn
main
()
{
let
_
=
A
.clone
();
let
_
=
B
(())
.deep_clone
();
}
src/test/run-pass/deriving-clone-generic-enum.rs
浏览文件 @
5f64adc4
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deriving(Clone
,
DeepClone
)]
#[deriving(Clone)]
enum
E
<
T
,
U
>
{
A
(
T
),
B
(
T
,
U
),
...
...
@@ -17,5 +17,4 @@ enum E<T,U> {
pub
fn
main
()
{
let
_
=
A
::
<
int
,
int
>
(
1
i
)
.clone
();
let
_
=
B
(
1
i
,
1.234
)
.deep_clone
();
}
src/test/run-pass/deriving-clone-generic-struct.rs
浏览文件 @
5f64adc4
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deriving(Clone
,
DeepClone
)]
#[deriving(Clone)]
struct
S
<
T
>
{
foo
:
(),
bar
:
(),
...
...
@@ -16,5 +16,5 @@ struct S<T> {
}
pub
fn
main
()
{
let
_
=
S
{
foo
:
(),
bar
:
(),
baz
:
1
i
}
.clone
()
.deep_clone
()
;
let
_
=
S
{
foo
:
(),
bar
:
(),
baz
:
1
i
}
.clone
();
}
src/test/run-pass/deriving-clone-generic-tuple-struct.rs
浏览文件 @
5f64adc4
...
...
@@ -8,9 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deriving(Clone
,
DeepClone
)]
#[deriving(Clone)]
struct
S
<
T
>
(
T
,
());
pub
fn
main
()
{
let
_
=
S
(
1
i
,
())
.clone
()
.deep_clone
()
;
let
_
=
S
(
1
i
,
())
.clone
();
}
src/test/run-pass/deriving-clone-struct.rs
浏览文件 @
5f64adc4
...
...
@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deriving(Clone
,
DeepClone
)]
#[deriving(Clone)]
struct
S
{
_
int
:
int
,
_i8
:
i8
,
...
...
src/test/run-pass/deriving-global.rs
浏览文件 @
5f64adc4
...
...
@@ -28,21 +28,21 @@ mod submod {
// cause errors about unrecognised module `std` (or `extra`)
#[deriving(Eq,
Ord,
TotalEq,
TotalOrd,
Hash,
Clone,
DeepClone,
Clone,
Show,
Rand,
Encodable,
Decodable)]
enum
A
{
A1
(
uint
),
A2
(
int
)
}
#[deriving(Eq,
Ord,
TotalEq,
TotalOrd,
Hash,
Clone,
DeepClone,
Clone,
Show,
Rand,
Encodable,
Decodable)]
struct
B
{
x
:
uint
,
y
:
int
}
#[deriving(Eq,
Ord,
TotalEq,
TotalOrd,
Hash,
Clone,
DeepClone,
Clone,
Show,
Rand,
Encodable,
Decodable)]
struct
C
(
uint
,
int
);
...
...
src/test/run-pass/send_str_hashmap.rs
浏览文件 @
5f64adc4
...
...
@@ -10,13 +10,8 @@
extern
crate
collections
;
use
std
::
clone
::{
Clone
,
DeepClone
};
use
std
::
cmp
::{
TotalEq
,
Ord
,
TotalOrd
,
Equiv
};
use
std
::
cmp
::
Equal
;
use
std
::
container
::{
Container
,
Map
,
MutableMap
};
use
std
::
default
::
Default
;
use
std
::
str
::{
Str
,
SendStr
,
Owned
,
Slice
};
use
std
::
to_str
::
ToStr
;
use
std
::
container
::{
Map
,
MutableMap
};
use
std
::
str
::{
SendStr
,
Owned
,
Slice
};
use
collections
::
HashMap
;
use
std
::
option
::
Some
;
...
...
src/test/run-pass/send_str_treemap.rs
浏览文件 @
5f64adc4
...
...
@@ -10,12 +10,8 @@
extern
crate
collections
;
use
std
::
clone
::{
Clone
,
DeepClone
};
use
std
::
cmp
::{
TotalEq
,
Ord
,
TotalOrd
,
Equiv
};
use
std
::
cmp
::
Equal
;
use
std
::
container
::{
Container
,
Map
,
MutableMap
};
use
std
::
default
::
Default
;
use
std
::
str
::{
Str
,
SendStr
,
Owned
,
Slice
};
use
std
::
container
::{
Map
,
MutableMap
};
use
std
::
str
::{
SendStr
,
Owned
,
Slice
};
use
std
::
to_str
::
ToStr
;
use
self
::
collections
::
TreeMap
;
use
std
::
option
::
Some
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录