Skip to content

Commit f8924aa

Browse files
committed
---
yaml --- r: 275935 b: refs/heads/master c: 1d2846d h: refs/heads/master i: 275933: 99529da 275931: b76cc4b 275927: 4ac1ab7 275919: 514f7e8 275903: bce9c94
1 parent 93ed59d commit f8924aa

File tree

14 files changed

+43
-206
lines changed

14 files changed

+43
-206
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 8f552181895921a377ab8c235340ea3d80ec7fc0
2+
refs/heads/master: 1d2846dcdaaffb36a30949e529dba81fe8aa2634
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
44
refs/heads/try: 49312a405e14a449b98fe0056b12a40ac128be4a
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

trunk/src/libcore/clone.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,6 @@ pub trait Clone : Sized {
7575
}
7676
}
7777

78-
// FIXME(aburka): this method is used solely by #[derive] to
79-
// assert that every component of a type implements Clone.
80-
//
81-
// This should never be called by user code.
82-
#[doc(hidden)]
83-
#[inline(always)]
84-
#[unstable(feature = "derive_clone_copy",
85-
reason = "deriving hack, should not be public",
86-
issue = "0")]
87-
pub fn assert_receiver_is_clone<T: Clone + ?Sized>(_: &T) {}
88-
8978
#[stable(feature = "rust1", since = "1.0.0")]
9079
impl<'a, T: ?Sized> Clone for &'a T {
9180
/// Returns a shallow copy of the reference.

trunk/src/libsyntax_ext/deriving/clone.rs

Lines changed: 30 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -11,68 +11,26 @@
1111
use deriving::generic::*;
1212
use deriving::generic::ty::*;
1313

14-
use syntax::ast::{Expr, ItemKind, Generics, MetaItem, VariantData};
15-
use syntax::attr::{self, AttrMetaMethods};
14+
use syntax::ast::{MetaItem, Expr, VariantData};
1615
use syntax::codemap::Span;
1716
use syntax::ext::base::{ExtCtxt, Annotatable};
1817
use syntax::ext::build::AstBuilder;
1918
use syntax::parse::token::InternedString;
2019
use syntax::ptr::P;
2120

22-
#[derive(PartialEq)]
23-
enum Mode { Deep, Shallow }
24-
2521
pub fn expand_deriving_clone(cx: &mut ExtCtxt,
2622
span: Span,
2723
mitem: &MetaItem,
2824
item: &Annotatable,
2925
push: &mut FnMut(Annotatable))
3026
{
31-
// check if we can use a short form
32-
//
33-
// the short form is `fn clone(&self) -> Self { *self }`
34-
//
35-
// we can use the short form if:
36-
// - the item is Copy (unfortunately, all we can check is whether it's also deriving Copy)
37-
// - there are no generic parameters (after specialization this limitation can be removed)
38-
// if we used the short form with generics, we'd have to bound the generics with
39-
// Clone + Copy, and then there'd be no Clone impl at all if the user fills in something
40-
// that is Clone but not Copy. and until specialization we can't write both impls.
41-
let bounds;
42-
let substructure;
43-
match *item {
44-
Annotatable::Item(ref annitem) => {
45-
match annitem.node {
46-
ItemKind::Struct(_, Generics { ref ty_params, .. }) |
47-
ItemKind::Enum(_, Generics { ref ty_params, .. })
48-
if ty_params.is_empty()
49-
&& attr::contains_name(&annitem.attrs, "derive_Copy") => {
50-
51-
bounds = vec![Literal(path_std!(cx, core::marker::Copy))];
52-
substructure = combine_substructure(Box::new(|c, s, sub| {
53-
cs_clone("Clone", c, s, sub, Mode::Shallow)
54-
}));
55-
}
56-
57-
_ => {
58-
bounds = vec![];
59-
substructure = combine_substructure(Box::new(|c, s, sub| {
60-
cs_clone("Clone", c, s, sub, Mode::Deep)
61-
}));
62-
}
63-
}
64-
}
65-
66-
_ => cx.span_bug(span, "#[derive(Clone)] on trait item or impl item")
67-
}
68-
6927
let inline = cx.meta_word(span, InternedString::new("inline"));
7028
let attrs = vec!(cx.attribute(span, inline));
7129
let trait_def = TraitDef {
7230
span: span,
7331
attributes: Vec::new(),
7432
path: path_std!(cx, core::clone::Clone),
75-
additional_bounds: bounds,
33+
additional_bounds: Vec::new(),
7634
generics: LifetimeBounds::empty(),
7735
is_unsafe: false,
7836
methods: vec!(
@@ -84,7 +42,9 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt,
8442
ret_ty: Self_,
8543
attributes: attrs,
8644
is_unsafe: false,
87-
combine_substructure: substructure,
45+
combine_substructure: combine_substructure(Box::new(|c, s, sub| {
46+
cs_clone("Clone", c, s, sub)
47+
})),
8848
}
8949
),
9050
associated_types: Vec::new(),
@@ -96,24 +56,14 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt,
9656
fn cs_clone(
9757
name: &str,
9858
cx: &mut ExtCtxt, trait_span: Span,
99-
substr: &Substructure,
100-
mode: Mode) -> P<Expr> {
59+
substr: &Substructure) -> P<Expr> {
10160
let ctor_path;
10261
let all_fields;
103-
let fn_path = match mode {
104-
Mode::Shallow => cx.std_path(&["clone", "assert_receiver_is_clone"]),
105-
Mode::Deep => cx.std_path(&["clone", "Clone", "clone"]),
106-
};
62+
let fn_path = cx.std_path(&["clone", "Clone", "clone"]);
10763
let subcall = |field: &FieldInfo| {
10864
let args = vec![cx.expr_addr_of(field.span, field.self_.clone())];
10965

110-
let span = if mode == Mode::Shallow {
111-
// set the expn ID so we can call the unstable method
112-
Span { expn_id: cx.backtrace(), .. trait_span }
113-
} else {
114-
field.span
115-
};
116-
cx.expr_call_global(span, fn_path.clone(), args)
66+
cx.expr_call_global(field.span, fn_path.clone(), args)
11767
};
11868

11969
let vdata;
@@ -139,41 +89,29 @@ fn cs_clone(
13989
}
14090
}
14191

142-
match mode {
143-
Mode::Shallow => {
144-
cx.expr_block(cx.block(trait_span,
145-
all_fields.iter()
146-
.map(subcall)
147-
.map(|e| cx.stmt_expr(e))
148-
.collect(),
149-
Some(cx.expr_deref(trait_span, cx.expr_self(trait_span)))))
150-
}
151-
Mode::Deep => {
152-
match *vdata {
153-
VariantData::Struct(..) => {
154-
let fields = all_fields.iter().map(|field| {
155-
let ident = match field.name {
156-
Some(i) => i,
157-
None => {
158-
cx.span_bug(trait_span,
159-
&format!("unnamed field in normal struct in \
160-
`derive({})`", name))
161-
}
162-
};
163-
cx.field_imm(field.span, ident, subcall(field))
164-
}).collect::<Vec<_>>();
92+
match *vdata {
93+
VariantData::Struct(..) => {
94+
let fields = all_fields.iter().map(|field| {
95+
let ident = match field.name {
96+
Some(i) => i,
97+
None => {
98+
cx.span_bug(trait_span,
99+
&format!("unnamed field in normal struct in \
100+
`derive({})`", name))
101+
}
102+
};
103+
cx.field_imm(field.span, ident, subcall(field))
104+
}).collect::<Vec<_>>();
165105

166-
cx.expr_struct(trait_span, ctor_path, fields)
167-
}
168-
VariantData::Tuple(..) => {
169-
let subcalls = all_fields.iter().map(subcall).collect();
170-
let path = cx.expr_path(ctor_path);
171-
cx.expr_call(trait_span, path, subcalls)
172-
}
173-
VariantData::Unit(..) => {
174-
cx.expr_path(ctor_path)
175-
}
176-
}
106+
cx.expr_struct(trait_span, ctor_path, fields)
107+
}
108+
VariantData::Tuple(..) => {
109+
let subcalls = all_fields.iter().map(subcall).collect();
110+
let path = cx.expr_path(ctor_path);
111+
cx.expr_call(trait_span, path, subcalls)
112+
}
113+
VariantData::Unit(..) => {
114+
cx.expr_path(ctor_path)
177115
}
178116
}
179117
}

trunk/src/libsyntax_ext/deriving/decodable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ fn expand_deriving_decodable_imp(cx: &mut ExtCtxt,
7474
},
7575
explicit_self: None,
7676
args: vec!(Ptr(Box::new(Literal(Path::new_local(typaram))),
77-
Borrowed(None, Mutability::Mutable))),
77+
Borrowed(None, Mutability::Mutable))),
7878
ret_ty: Literal(Path::new_(
7979
pathvec_std!(cx, core::result::Result),
8080
None,

trunk/src/libsyntax_ext/deriving/encodable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ fn expand_deriving_encodable_imp(cx: &mut ExtCtxt,
150150
},
151151
explicit_self: borrowed_explicit_self(),
152152
args: vec!(Ptr(Box::new(Literal(Path::new_local(typaram))),
153-
Borrowed(None, Mutability::Mutable))),
153+
Borrowed(None, Mutability::Mutable))),
154154
ret_ty: Literal(Path::new_(
155155
pathvec_std!(cx, core::result::Result),
156156
None,

trunk/src/libsyntax_ext/deriving/generic/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,6 @@ impl<'a> MethodDef<'a> {
857857
explicit_self: ast::ExplicitSelf,
858858
arg_types: Vec<(Ident, P<ast::Ty>)> ,
859859
body: P<Expr>) -> ast::ImplItem {
860-
861860
// create the generics that aren't for Self
862861
let fn_generics = self.generics.to_generics(cx, trait_.span, type_ident, generics);
863862

@@ -991,7 +990,6 @@ impl<'a> MethodDef<'a> {
991990
body = cx.expr_match(trait_.span, arg_expr.clone(),
992991
vec!( cx.arm(trait_.span, vec!(pat.clone()), body) ))
993992
}
994-
995993
body
996994
}
997995

trunk/src/llvm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit 25c7dc370359433ca02f29919dfa36f94432155e
1+
Subproject commit 751345228a0ef03fd147394bb5104359b7a808be
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# If this file is modified, then llvm will be forcibly cleaned and then rebuilt.
22
# The actual contents of this file do not matter, but to trigger a change on the
33
# build bots then the contents should be changed so git updates the mtime.
4-
2016-03-18
4+
2016-04-26

trunk/src/test/compile-fail/deriving-copyclone.rs

Lines changed: 0 additions & 48 deletions
This file was deleted.

trunk/src/test/run-pass/copy-out-of-array-1.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
//
1313
// (Compare with compile-fail/move-out-of-array-1.rs)
1414

15+
// pretty-expanded FIXME #23616
16+
1517
#[derive(Copy, Clone)]
1618
struct C { _x: u8 }
1719

trunk/src/test/run-pass/deriving-copyclone.rs

Lines changed: 0 additions & 48 deletions
This file was deleted.

trunk/src/test/run-pass/hrtb-opt-in-copy.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
// did not consider that a match (something I would like to revise in
1717
// a later PR).
1818

19+
// pretty-expanded FIXME #23616
20+
1921
#![allow(dead_code)]
2022

2123
use std::marker::PhantomData;

trunk/src/test/run-pass/issue-13264.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// pretty-expanded FIXME #23616
12+
1113
use std::ops::Deref;
1214

1315
struct Root {

trunk/src/test/run-pass/issue-3121.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// pretty-expanded FIXME #23616
12+
1113
#![allow(unknown_features)]
1214
#![feature(box_syntax)]
1315

0 commit comments

Comments
 (0)