Skip to content

Commit c1c078d

Browse files
committed
---
yaml --- r: 95237 b: refs/heads/dist-snap c: fdb49aa h: refs/heads/master i: 95235: ce69baf v: v3
1 parent 74e8d18 commit c1c078d

File tree

3 files changed

+40
-22
lines changed

3 files changed

+40
-22
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: b17dc4a946838a7f0a1d8eb752536243e322e8de
9+
refs/heads/dist-snap: fdb49aa917184ebf23f11c29974ceb895824b5bc
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librustc/middle/check_match.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use syntax::codemap::{Span, dummy_sp, Spanned};
2828
use syntax::visit;
2929
use syntax::visit::{Visitor,fn_kind};
3030

31-
pub struct MatchCheckCtxt {
31+
struct MatchCheckCtxt {
3232
tcx: ty::ctxt,
3333
method_map: method_map,
3434
moves_map: moves::MovesMap
@@ -64,7 +64,7 @@ pub fn check_crate(tcx: ty::ctxt,
6464
tcx.sess.abort_if_errors();
6565
}
6666

67-
pub fn check_expr(v: &mut CheckMatchVisitor,
67+
fn check_expr(v: &mut CheckMatchVisitor,
6868
cx: @MatchCheckCtxt,
6969
ex: @Expr,
7070
s: ()) {
@@ -115,7 +115,7 @@ pub fn check_expr(v: &mut CheckMatchVisitor,
115115
}
116116

117117
// Check for unreachable patterns
118-
pub fn check_arms(cx: &MatchCheckCtxt, arms: &[Arm]) {
118+
fn check_arms(cx: &MatchCheckCtxt, arms: &[Arm]) {
119119
let mut seen = ~[];
120120
for arm in arms.iter() {
121121
for pat in arm.pats.iter() {
@@ -154,14 +154,14 @@ pub fn check_arms(cx: &MatchCheckCtxt, arms: &[Arm]) {
154154
}
155155
}
156156

157-
pub fn raw_pat(p: @Pat) -> @Pat {
157+
fn raw_pat(p: @Pat) -> @Pat {
158158
match p.node {
159159
PatIdent(_, _, Some(s)) => { raw_pat(s) }
160160
_ => { p }
161161
}
162162
}
163163

164-
pub fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, pats: ~[@Pat]) {
164+
fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, pats: ~[@Pat]) {
165165
assert!((!pats.is_empty()));
166166
let ext = match is_useful(cx, &pats.map(|p| ~[*p]), [wild()]) {
167167
not_useful => {
@@ -209,12 +209,12 @@ pub fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, pats: ~[@Pat]) {
209209
cx.tcx.sess.span_err(sp, msg);
210210
}
211211

212-
pub type matrix = ~[~[@Pat]];
212+
type matrix = ~[~[@Pat]];
213213

214-
pub enum useful { useful(ty::t, ctor), useful_, not_useful }
214+
enum useful { useful(ty::t, ctor), useful_, not_useful }
215215

216216
#[deriving(Eq)]
217-
pub enum ctor {
217+
enum ctor {
218218
single,
219219
variant(DefId),
220220
val(const_val),
@@ -235,7 +235,7 @@ pub enum ctor {
235235

236236
// Note: is_useful doesn't work on empty types, as the paper notes.
237237
// So it assumes that v is non-empty.
238-
pub fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@Pat]) -> useful {
238+
fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@Pat]) -> useful {
239239
if m.len() == 0u { return useful_; }
240240
if m[0].len() == 0u { return not_useful; }
241241
let real_pat = match m.iter().find(|r| r[0].id != 0) {
@@ -314,7 +314,7 @@ pub fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@Pat]) -> useful {
314314
}
315315
}
316316

317-
pub fn is_useful_specialized(cx: &MatchCheckCtxt,
317+
fn is_useful_specialized(cx: &MatchCheckCtxt,
318318
m: &matrix,
319319
v: &[@Pat],
320320
ctor: ctor,
@@ -330,7 +330,7 @@ pub fn is_useful_specialized(cx: &MatchCheckCtxt,
330330
}
331331
}
332332

333-
pub fn pat_ctor_id(cx: &MatchCheckCtxt, p: @Pat) -> Option<ctor> {
333+
fn pat_ctor_id(cx: &MatchCheckCtxt, p: @Pat) -> Option<ctor> {
334334
let pat = raw_pat(p);
335335
match pat.node {
336336
PatWild => { None }
@@ -366,7 +366,7 @@ pub fn pat_ctor_id(cx: &MatchCheckCtxt, p: @Pat) -> Option<ctor> {
366366
}
367367
}
368368

369-
pub fn is_wild(cx: &MatchCheckCtxt, p: @Pat) -> bool {
369+
fn is_wild(cx: &MatchCheckCtxt, p: @Pat) -> bool {
370370
let pat = raw_pat(p);
371371
match pat.node {
372372
PatWild => { true }
@@ -380,7 +380,7 @@ pub fn is_wild(cx: &MatchCheckCtxt, p: @Pat) -> bool {
380380
}
381381
}
382382

383-
pub fn missing_ctor(cx: &MatchCheckCtxt,
383+
fn missing_ctor(cx: &MatchCheckCtxt,
384384
m: &matrix,
385385
left_ty: ty::t)
386386
-> Option<ctor> {
@@ -505,7 +505,7 @@ pub fn missing_ctor(cx: &MatchCheckCtxt,
505505
}
506506
}
507507

508-
pub fn ctor_arity(cx: &MatchCheckCtxt, ctor: &ctor, ty: ty::t) -> uint {
508+
fn ctor_arity(cx: &MatchCheckCtxt, ctor: &ctor, ty: ty::t) -> uint {
509509
match ty::get(ty).sty {
510510
ty::ty_tup(ref fs) => fs.len(),
511511
ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_rptr(*) => 1u,
@@ -528,11 +528,11 @@ pub fn ctor_arity(cx: &MatchCheckCtxt, ctor: &ctor, ty: ty::t) -> uint {
528528
}
529529
}
530530

531-
pub fn wild() -> @Pat {
531+
fn wild() -> @Pat {
532532
@Pat {id: 0, node: PatWild, span: dummy_sp()}
533533
}
534534

535-
pub fn specialize(cx: &MatchCheckCtxt,
535+
fn specialize(cx: &MatchCheckCtxt,
536536
r: &[@Pat],
537537
ctor_id: &ctor,
538538
arity: uint,
@@ -798,12 +798,12 @@ pub fn specialize(cx: &MatchCheckCtxt,
798798
}
799799
}
800800

801-
pub fn default(cx: &MatchCheckCtxt, r: &[@Pat]) -> Option<~[@Pat]> {
801+
fn default(cx: &MatchCheckCtxt, r: &[@Pat]) -> Option<~[@Pat]> {
802802
if is_wild(cx, r[0]) { Some(r.tail().to_owned()) }
803803
else { None }
804804
}
805805

806-
pub fn check_local(v: &mut CheckMatchVisitor,
806+
fn check_local(v: &mut CheckMatchVisitor,
807807
cx: &MatchCheckCtxt,
808808
loc: @Local,
809809
s: ()) {
@@ -817,7 +817,7 @@ pub fn check_local(v: &mut CheckMatchVisitor,
817817
check_legality_of_move_bindings(cx, false, [ loc.pat ]);
818818
}
819819

820-
pub fn check_fn(v: &mut CheckMatchVisitor,
820+
fn check_fn(v: &mut CheckMatchVisitor,
821821
cx: &MatchCheckCtxt,
822822
kind: &visit::fn_kind,
823823
decl: &fn_decl,
@@ -834,7 +834,7 @@ pub fn check_fn(v: &mut CheckMatchVisitor,
834834
}
835835
}
836836

837-
pub fn is_refutable(cx: &MatchCheckCtxt, pat: &Pat) -> bool {
837+
fn is_refutable(cx: &MatchCheckCtxt, pat: &Pat) -> bool {
838838
match cx.tcx.def_map.find(&pat.id) {
839839
Some(&DefVariant(enum_id, _, _)) => {
840840
if ty::enum_variants(cx.tcx, enum_id).len() != 1u {
@@ -872,7 +872,7 @@ pub fn is_refutable(cx: &MatchCheckCtxt, pat: &Pat) -> bool {
872872

873873
// Legality of move bindings checking
874874

875-
pub fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
875+
fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
876876
has_guard: bool,
877877
pats: &[@Pat]) {
878878
let tcx = cx.tcx;

branches/dist-snap/src/librustc/middle/trans/glue.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ pub fn trans_struct_drop_flag(bcx: @mut Block, t: ty::t, v0: ValueRef, dtor_did:
423423
bcx = drop_ty(bcx, llfld_a, fld.mt.ty);
424424
}
425425

426+
Store(bcx, C_u8(0), drop_flag);
426427
bcx
427428
}
428429
}
@@ -594,6 +595,23 @@ pub fn make_take_glue(bcx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
594595
bcx
595596
}
596597
ty::ty_opaque_closure_ptr(_) => bcx,
598+
ty::ty_struct(did, _) => {
599+
let tcx = bcx.tcx();
600+
let bcx = iter_structural_ty(bcx, v, t, take_ty);
601+
602+
match ty::ty_dtor(tcx, did) {
603+
ty::TraitDtor(_, false) => {
604+
// Zero out the struct
605+
unsafe {
606+
let ty = Type::from_ref(llvm::LLVMTypeOf(v));
607+
memzero(&B(bcx), v, ty);
608+
}
609+
610+
}
611+
_ => { }
612+
}
613+
bcx
614+
}
597615
_ if ty::type_is_structural(t) => {
598616
iter_structural_ty(bcx, v, t, take_ty)
599617
}

0 commit comments

Comments
 (0)