Skip to content

Commit c081ffb

Browse files
committed
auto merge of #6121 : luqmana/rust/newtype-cc, r=graydon
#6086
2 parents 84e22f2 + 10f290e commit c081ffb

File tree

5 files changed

+29
-0
lines changed

5 files changed

+29
-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
@@ -912,6 +912,7 @@ pub impl mem_categorization_ctxt {
912912
self.cat_pattern(subcmt, *subpat, op);
913913
}
914914
}
915+
Some(&ast::def_fn(*)) |
915916
Some(&ast::def_struct(*)) => {
916917
for subpats.each |subpat| {
917918
let cmt_field = self.cat_anon_struct_field(*subpat,

src/librustc/middle/resolve.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4277,6 +4277,7 @@ pub impl Resolver {
42774277
pat_enum(path, _) => {
42784278
// This must be an enum variant, struct or const.
42794279
match self.resolve_path(path, ValueNS, false, visitor) {
4280+
Some(def @ def_fn(*)) |
42804281
Some(def @ def_variant(*)) |
42814282
Some(def @ def_struct(*)) |
42824283
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 => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2013 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+
// xfail-fast
12+
// aux-build:newtype_struct_xc.rs
13+
14+
extern mod newtype_struct_xc;
15+
16+
fn main() {
17+
let x = newtype_struct_xc::Au(21);
18+
match x {
19+
newtype_struct_xc::Au(n) => assert_eq!(n, 21)
20+
}
21+
}

0 commit comments

Comments
 (0)