Skip to content

Commit 3f78e0e

Browse files
committed
librustc: Fix bug preventing cross-crate struct destructuring from working. rs=bugfix
1 parent ac2b045 commit 3f78e0e

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

src/librustc/middle/resolve.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4454,11 +4454,17 @@ impl Resolver {
44544454
let class_def = def_class(class_id);
44554455
self.record_def(pattern.id, class_def);
44564456
}
4457+
Some(definition @ def_class(class_id))
4458+
if self.structs.contains_key(class_id) => {
4459+
self.record_def(pattern.id, definition);
4460+
}
44574461
Some(definition @ def_variant(_, variant_id))
44584462
if self.structs.contains_key(variant_id) => {
44594463
self.record_def(pattern.id, definition);
44604464
}
4461-
_ => {
4465+
result => {
4466+
debug!("(resolving pattern) didn't find struct \
4467+
def: %?", result);
44624468
self.session.span_err(
44634469
path.span,
44644470
fmt!("`%s` does not name a structure",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#[crate_type="lib"];
2+
3+
pub struct S {
4+
x: int,
5+
y: int
6+
}
7+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// xfail-fast
2+
extern mod struct_destructuring_cross_crate;
3+
4+
fn main() {
5+
let x = struct_destructuring_cross_crate::S { x: 1, y: 2 };
6+
let struct_destructuring_cross_crate::S { x: a, y: b } = x;
7+
assert a == 1;
8+
assert b == 2;
9+
}

0 commit comments

Comments
 (0)