Skip to content

Commit b4cf589

Browse files
edwardwalexcrichton
authored andcommitted
---
yaml --- r: 151611 b: refs/heads/try2 c: 21867fa h: refs/heads/master i: 151609: 80c0301 151607: c2abc88 v: v3
1 parent f319ce2 commit b4cf589

File tree

2 files changed

+22
-35
lines changed

2 files changed

+22
-35
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 5bf268d0b028d8e8abe62166c533f8515955bc6b
8+
refs/heads/try2: 21867fa1279c38189faccfb430c8bd6bffe0ef9e
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/check_match.rs

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -266,15 +266,15 @@ fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@Pat]) -> useful {
266266
val(const_bool(false)),
267267
0u, left_ty)
268268
}
269-
ref u => (*u).clone(),
269+
u => u,
270270
}
271271
}
272272
ty::ty_enum(eid, _) => {
273273
for va in (*ty::enum_variants(cx.tcx, eid)).iter() {
274274
match is_useful_specialized(cx, m, v, variant(va.id),
275275
va.args.len(), left_ty) {
276276
not_useful => (),
277-
ref u => return (*u).clone(),
277+
u => return u,
278278
}
279279
}
280280
not_useful
@@ -296,7 +296,7 @@ fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@Pat]) -> useful {
296296
for n in iter::range(0u, max_len + 1) {
297297
match is_useful_specialized(cx, m, v, vec(n), n, left_ty) {
298298
not_useful => (),
299-
ref u => return (*u).clone(),
299+
u => return u,
300300
}
301301
}
302302
not_useful
@@ -312,21 +312,21 @@ fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@Pat]) -> useful {
312312
}
313313
}
314314
}
315-
Some(ref ctor) => {
315+
Some(ctor) => {
316316
match is_useful(cx,
317317
&m.iter().filter_map(|r| {
318318
default(cx, r.as_slice())
319319
}).collect::<matrix>(),
320320
v.tail()) {
321-
useful_ => useful(left_ty, (*ctor).clone()),
322-
ref u => (*u).clone(),
321+
useful_ => useful(left_ty, ctor),
322+
u => u,
323323
}
324324
}
325325
}
326326
}
327-
Some(ref v0_ctor) => {
328-
let arity = ctor_arity(cx, v0_ctor, left_ty);
329-
is_useful_specialized(cx, m, v, (*v0_ctor).clone(), arity, left_ty)
327+
Some(v0_ctor) => {
328+
let arity = ctor_arity(cx, &v0_ctor, left_ty);
329+
is_useful_specialized(cx, m, v, v0_ctor, arity, left_ty)
330330
}
331331
}
332332
}
@@ -345,7 +345,7 @@ fn is_useful_specialized(cx: &MatchCheckCtxt,
345345
cx, &ms, specialize(cx, v, &ctor, arity, lty).unwrap().as_slice());
346346
match could_be_useful {
347347
useful_ => useful(lty, ctor),
348-
ref u => (*u).clone(),
348+
u => u,
349349
}
350350
}
351351

@@ -416,9 +416,9 @@ fn missing_ctor(cx: &MatchCheckCtxt,
416416
let mut found = Vec::new();
417417
for r in m.iter() {
418418
let r = pat_ctor_id(cx, *r.get(0));
419-
for id in r.iter() {
420-
if !found.contains(id) {
421-
found.push((*id).clone());
419+
for id in r.move_iter() {
420+
if !found.contains(&id) {
421+
found.push(id);
422422
}
423423
}
424424
}
@@ -820,30 +820,17 @@ fn specialize(cx: &MatchCheckCtxt,
820820
let num_elements = before.len() + after.len();
821821
if num_elements < arity && slice.is_some() {
822822
let mut result = Vec::new();
823-
for pat in before.iter() {
824-
result.push((*pat).clone());
825-
}
826-
for _ in iter::range(0, arity - num_elements) {
827-
result.push(wild())
828-
}
829-
for pat in after.iter() {
830-
result.push((*pat).clone());
831-
}
832-
for pat in r.tail().iter() {
833-
result.push((*pat).clone());
834-
}
823+
let wilds = Vec::from_elem(arity - num_elements, wild());
824+
result.push_all_move(before);
825+
result.push_all_move(wilds);
826+
result.push_all_move(after);
827+
result.push_all(r.tail());
835828
Some(result)
836829
} else if num_elements == arity {
837830
let mut result = Vec::new();
838-
for pat in before.iter() {
839-
result.push((*pat).clone());
840-
}
841-
for pat in after.iter() {
842-
result.push((*pat).clone());
843-
}
844-
for pat in r.tail().iter() {
845-
result.push((*pat).clone());
846-
}
831+
result.push_all_move(before);
832+
result.push_all_move(after);
833+
result.push_all(r.tail());
847834
Some(result)
848835
} else {
849836
None

0 commit comments

Comments
 (0)