Skip to content

Commit b50aa82

Browse files
committed
librustc: Fix pattern matching on cross crate newtype structs.
1 parent dbcc3fe commit b50aa82

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

src/librustc/middle/check_match.rs

+2
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,8 @@ pub fn specialize(cx: @MatchCheckCtxt,
551551
Some(vec::append(args, vec::from_slice(r.tail())))
552552
}
553553
def_variant(_, _) => None,
554+
555+
def_fn(*) |
554556
def_struct(*) => {
555557
// FIXME #4731: Is this right? --pcw
556558
let new_args;

src/librustc/middle/mem_categorization.rs

+1
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,7 @@ pub impl mem_categorization_ctxt {
915915
self.cat_pattern(subcmt, *subpat, op);
916916
}
917917
}
918+
Some(&ast::def_fn(*)) |
918919
Some(&ast::def_struct(*)) => {
919920
for subpats.each |subpat| {
920921
let cmt_field = self.cat_anon_struct_field(*subpat,

src/librustc/middle/resolve.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4279,6 +4279,7 @@ pub impl Resolver {
42794279
pat_enum(path, _) => {
42804280
// This must be an enum variant, struct or const.
42814281
match self.resolve_path(path, ValueNS, false, visitor) {
4282+
Some(def @ def_fn(*)) |
42824283
Some(def @ def_variant(*)) |
42834284
Some(def @ def_struct(*)) |
42844285
Some(def @ def_const(*)) => {

src/librustc/middle/trans/_match.rs

+4
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ pub fn variant_opt(bcx: block, pat_id: ast::node_id)
291291
}
292292
::core::util::unreachable();
293293
}
294+
ast::def_fn(*) |
294295
ast::def_struct(_) => {
295296
return lit(UnitLikeStructLit(pat_id));
296297
}
@@ -818,6 +819,7 @@ pub fn get_options(bcx: block, m: &[@Match], col: uint) -> ~[Opt] {
818819
// This could be one of: a tuple-like enum variant, a
819820
// struct-like enum variant, or a struct.
820821
match ccx.tcx.def_map.find(&cur.id) {
822+
Some(&ast::def_fn(*)) |
821823
Some(&ast::def_variant(*)) => {
822824
add_to_set(ccx.tcx, &mut found,
823825
variant_opt(bcx, cur.id));
@@ -1011,6 +1013,7 @@ pub fn any_tuple_struct_pat(bcx: block, m: &[@Match], col: uint) -> bool {
10111013
match pat.node {
10121014
ast::pat_enum(_, Some(_)) => {
10131015
match bcx.tcx().def_map.find(&pat.id) {
1016+
Some(&ast::def_fn(*)) |
10141017
Some(&ast::def_struct(*)) => true,
10151018
_ => false
10161019
}
@@ -1780,6 +1783,7 @@ pub fn bind_irrefutable_pat(bcx: block,
17801783
}
17811784
}
17821785
}
1786+
Some(&ast::def_fn(*)) |
17831787
Some(&ast::def_struct(*)) => {
17841788
match *sub_pats {
17851789
None => {

0 commit comments

Comments
 (0)