Skip to content

Commit 485cf67

Browse files
committed
---
yaml --- r: 163203 b: refs/heads/snap-stage3 c: 086c949 h: refs/heads/master i: 163201: a26c464 163199: 0f3924e v: v3
1 parent 32c1e8d commit 485cf67

File tree

3 files changed

+42
-10
lines changed

3 files changed

+42
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 9146a919b616e39e528e4d7100d16eef52f1f852
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 418d1bfc9a3a71ce1beaced9ec6592ad614646b0
4+
refs/heads/snap-stage3: 086c9493c822e8de53bdb5ccf6b32d2e05c3963f
55
refs/heads/try: 20cbbffeefc1f35e2ea63afce7b42fbd79611d42
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/librustc/middle/borrowck/fragments.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,10 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>,
346346
Rc<LoanPath<'tcx>>)>) {
347347
let parent_ty = parent_lp.to_type();
348348

349-
let add_fragment_sibling_local = |field_name| {
349+
let add_fragment_sibling_local = |field_name, variant_did| {
350350
add_fragment_sibling_core(
351-
this, tcx, gathered_fragments, parent_lp.clone(), mc, field_name, origin_lp);
351+
this, tcx, gathered_fragments, parent_lp.clone(), mc, field_name, origin_lp,
352+
variant_did);
352353
};
353354

354355
match (&parent_ty.sty, enum_variant_info) {
@@ -363,7 +364,7 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>,
363364
for i in range(0, tuple_len) {
364365
if i == tuple_idx { continue }
365366
let field_name = mc::PositionalField(i);
366-
add_fragment_sibling_local(field_name);
367+
add_fragment_sibling_local(field_name, None);
367368
}
368369
}
369370

@@ -376,7 +377,7 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>,
376377
continue;
377378
}
378379
let field_name = mc::NamedField(f.name);
379-
add_fragment_sibling_local(field_name);
380+
add_fragment_sibling_local(field_name, None);
380381
}
381382
}
382383
mc::PositionalField(tuple_idx) => {
@@ -385,7 +386,7 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>,
385386
continue
386387
}
387388
let field_name = mc::PositionalField(i);
388-
add_fragment_sibling_local(field_name);
389+
add_fragment_sibling_local(field_name, None);
389390
}
390391
}
391392
}
@@ -414,7 +415,7 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>,
414415
continue;
415416
}
416417
let field_name = mc::NamedField(variant_arg_ident.name);
417-
add_fragment_sibling_local(field_name);
418+
add_fragment_sibling_local(field_name, Some(variant_info.id));
418419
}
419420
}
420421
mc::PositionalField(tuple_idx) => {
@@ -424,7 +425,7 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>,
424425
continue;
425426
}
426427
let field_name = mc::PositionalField(i);
427-
add_fragment_sibling_local(field_name);
428+
add_fragment_sibling_local(field_name, None);
428429
}
429430
}
430431
}
@@ -447,10 +448,11 @@ fn add_fragment_sibling_core<'tcx>(this: &MoveData<'tcx>,
447448
parent: Rc<LoanPath<'tcx>>,
448449
mc: mc::MutabilityCategory,
449450
new_field_name: mc::FieldName,
450-
origin_lp: &Rc<LoanPath<'tcx>>) -> MovePathIndex {
451+
origin_lp: &Rc<LoanPath<'tcx>>,
452+
enum_variant_did: Option<ast::DefId>) -> MovePathIndex {
451453
let opt_variant_did = match parent.kind {
452454
LpDowncast(_, variant_did) => Some(variant_did),
453-
LpVar(..) | LpUpvar(..) | LpExtend(..) => None,
455+
LpVar(..) | LpUpvar(..) | LpExtend(..) => enum_variant_did,
454456
};
455457

456458
let loan_path_elem = LpInterior(mc::InteriorField(new_field_name));
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
enum Homura {
12+
Madoka {
13+
name: String,
14+
age: u32,
15+
},
16+
}
17+
18+
fn main() {
19+
let homura = Homura::Madoka {
20+
name: "Akemi".into_string(),
21+
age: 14,
22+
};
23+
24+
match homura {
25+
Homura::Madoka {
26+
name,
27+
age,
28+
} => (),
29+
};
30+
}

0 commit comments

Comments
 (0)