Skip to content

Commit a23a1a0

Browse files
committed
---
yaml --- r: 58807 b: refs/heads/incoming c: 517bfc9 h: refs/heads/master i: 58805: 56e8e31 58803: a8daddc 58799: 70403c7 v: v3
1 parent ec24627 commit a23a1a0

File tree

10 files changed

+111
-60
lines changed

10 files changed

+111
-60
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c50a9d5b664478e533ba1d1d353213d70c8ad589
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/incoming: 24cda9fbc20cad2d7f59a40973a51ff6355ababb
9+
refs/heads/incoming: 517bfc91d1481cb8b247c7a5f19528136987ee4e
1010
refs/heads/dist-snap: 00dbbd01c2aee72982b3e0f9511ae1d4428c3ba9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libcore/char.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use option::{None, Option, Some};
1616
use str;
1717
use u32;
1818
use uint;
19-
use unicode::{derived_property, general_category};
19+
use unicode;
2020

2121
#[cfg(notest)] use cmp::Eq;
2222

@@ -53,17 +53,18 @@ use unicode::{derived_property, general_category};
5353
Cn Unassigned a reserved unassigned code point or a noncharacter
5454
*/
5555

56-
pub fn is_alphabetic(c: char) -> bool { derived_property::Alphabetic(c) }
57-
pub fn is_XID_start(c: char) -> bool { derived_property::XID_Start(c) }
58-
pub fn is_XID_continue(c: char) -> bool { derived_property::XID_Continue(c) }
56+
pub use is_alphabetic = unicode::derived_property::Alphabetic;
57+
pub use is_XID_start = unicode::derived_property::XID_Start;
58+
pub use is_XID_continue = unicode::derived_property::XID_Continue;
59+
5960

6061
/**
6162
* Indicates whether a character is in lower case, defined
6263
* in terms of the Unicode General Category 'Ll'
6364
*/
6465
#[inline(always)]
6566
pub fn is_lowercase(c: char) -> bool {
66-
return general_category::Ll(c);
67+
return unicode::general_category::Ll(c);
6768
}
6869

6970
/**
@@ -72,7 +73,7 @@ pub fn is_lowercase(c: char) -> bool {
7273
*/
7374
#[inline(always)]
7475
pub fn is_uppercase(c: char) -> bool {
75-
return general_category::Lu(c);
76+
return unicode::general_category::Lu(c);
7677
}
7778

7879
/**
@@ -83,9 +84,9 @@ pub fn is_uppercase(c: char) -> bool {
8384
#[inline(always)]
8485
pub fn is_whitespace(c: char) -> bool {
8586
return ('\x09' <= c && c <= '\x0d')
86-
|| general_category::Zs(c)
87-
|| general_category::Zl(c)
88-
|| general_category::Zp(c);
87+
|| unicode::general_category::Zs(c)
88+
|| unicode::general_category::Zl(c)
89+
|| unicode::general_category::Zp(c);
8990
}
9091

9192
/**
@@ -95,18 +96,18 @@ pub fn is_whitespace(c: char) -> bool {
9596
*/
9697
#[inline(always)]
9798
pub fn is_alphanumeric(c: char) -> bool {
98-
return derived_property::Alphabetic(c) ||
99-
general_category::Nd(c) ||
100-
general_category::Nl(c) ||
101-
general_category::No(c);
99+
return unicode::derived_property::Alphabetic(c) ||
100+
unicode::general_category::Nd(c) ||
101+
unicode::general_category::Nl(c) ||
102+
unicode::general_category::No(c);
102103
}
103104

104105
/// Indicates whether the character is numeric (Nd, Nl, or No)
105106
#[inline(always)]
106107
pub fn is_digit(c: char) -> bool {
107-
return general_category::Nd(c) ||
108-
general_category::Nl(c) ||
109-
general_category::No(c);
108+
return unicode::general_category::Nd(c) ||
109+
unicode::general_category::Nl(c) ||
110+
unicode::general_category::No(c);
110111
}
111112

112113
/**

branches/incoming/src/libcore/core.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,12 @@ pub mod unstable;
247247

248248
/* For internal use, not exported */
249249

250-
mod unicode;
250+
pub mod unicode;
251251
#[path = "num/cmath.rs"]
252-
mod cmath;
253-
mod stackwalk;
252+
pub mod cmath;
253+
pub mod stackwalk;
254254
#[path = "rt/mod.rs"]
255-
mod rt;
255+
pub mod rt;
256256

257257
// A curious inner-module that's not exported that contains the binding
258258
// 'core' so that macro-expanded references to core::error and such

branches/incoming/src/libcore/gc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use libc::{size_t, uintptr_t};
4444
use option::{None, Option, Some};
4545
use ptr;
4646
use hashmap::HashSet;
47-
use stackwalk::walk_stack;
47+
use stackwalk;
4848
use sys;
4949

5050
pub use stackwalk::Word;
@@ -230,7 +230,7 @@ unsafe fn walk_gc_roots(mem: Memory, sentinel: **Word, visitor: Visitor) {
230230
// frame is marked by a sentinel, which is a box pointer stored on
231231
// the stack.
232232
let mut reached_sentinel = ptr::is_null(sentinel);
233-
for walk_stack |frame| {
233+
for stackwalk::walk_stack |frame| {
234234
let pc = last_ret;
235235
let Segment {segment: next_segment, boundary: boundary} =
236236
find_segment_for_frame(frame.fp, segment);

branches/incoming/src/libcore/prelude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub use io::{print, println};
3131
/* Reexported types and traits */
3232

3333
pub use clone::Clone;
34-
pub use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater};
34+
pub use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater, Equiv};
3535
pub use container::{Container, Mutable, Map, Set};
3636
pub use hash::Hash;
3737
pub use old_iter::{BaseIter, ReverseIter, MutableIter, ExtendedIter, EqIter};

branches/incoming/src/libcore/to_bytes.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,7 @@ impl<A> IterBytes for *const A {
419419
}
420420
}
421421

422-
423-
trait ToBytes {
422+
pub trait ToBytes {
424423
fn to_bytes(&self, lsb0: bool) -> ~[u8];
425424
}
426425

branches/incoming/src/librustc/middle/typeck/check/_match.rs

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -114,37 +114,53 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: @ast::Path,
114114
ty::ty_enum(_, ref expected_substs) => {
115115
// Lookup the enum and variant def ids:
116116
let v_def = lookup_def(pcx.fcx, pat.span, pat.id);
117-
let (enm, var) = ast_util::variant_def_ids(v_def);
118-
119-
// Assign the pattern the type of the *enum*, not the variant.
120-
let enum_tpt = ty::lookup_item_type(tcx, enm);
121-
instantiate_path(pcx.fcx, path, enum_tpt, pat.span, pat.id,
122-
pcx.block_region);
123-
124-
// check that the type of the value being matched is a subtype
125-
// of the type of the pattern:
126-
let pat_ty = fcx.node_ty(pat.id);
127-
demand::subtype(fcx, pat.span, expected, pat_ty);
128-
129-
// Get the expected types of the arguments.
130-
arg_types = {
131-
let vinfo =
132-
ty::enum_variant_with_id(tcx, enm, var);
133-
let var_tpt = ty::lookup_item_type(tcx, var);
134-
vinfo.args.map(|t| {
135-
if var_tpt.generics.type_param_defs.len() ==
136-
expected_substs.tps.len()
137-
{
138-
ty::subst(tcx, expected_substs, *t)
139-
}
140-
else {
141-
*t // In this case, an error was already signaled
142-
// anyway
143-
}
144-
})
145-
};
146-
147-
kind_name = "variant";
117+
match ast_util::variant_def_ids(v_def) {
118+
Some((enm, var)) => {
119+
// Assign the pattern the type of the *enum*, not the variant.
120+
let enum_tpt = ty::lookup_item_type(tcx, enm);
121+
instantiate_path(pcx.fcx, path, enum_tpt, pat.span, pat.id,
122+
pcx.block_region);
123+
124+
// check that the type of the value being matched is a subtype
125+
// of the type of the pattern:
126+
let pat_ty = fcx.node_ty(pat.id);
127+
demand::subtype(fcx, pat.span, expected, pat_ty);
128+
129+
// Get the expected types of the arguments.
130+
arg_types = {
131+
let vinfo =
132+
ty::enum_variant_with_id(tcx, enm, var);
133+
let var_tpt = ty::lookup_item_type(tcx, var);
134+
vinfo.args.map(|t| {
135+
if var_tpt.generics.type_param_defs.len() ==
136+
expected_substs.tps.len()
137+
{
138+
ty::subst(tcx, expected_substs, *t)
139+
}
140+
else {
141+
*t // In this case, an error was already signaled
142+
// anyway
143+
}
144+
})
145+
};
146+
147+
kind_name = "variant";
148+
}
149+
None => {
150+
let resolved_expected =
151+
fcx.infcx().ty_to_str(fcx.infcx().resolve_type_vars_if_possible(expected));
152+
fcx.infcx().type_error_message_str(pat.span,
153+
|actual| {
154+
fmt!("mismatched types: expected `%s` but found %s",
155+
resolved_expected, actual)},
156+
~"a structure pattern",
157+
None);
158+
fcx.write_error(pat.id);
159+
kind_name = "[error]";
160+
arg_types = (copy subpats).get_or_default(~[]).map(|_|
161+
ty::mk_err());
162+
}
163+
}
148164
}
149165
ty::ty_struct(struct_def_id, ref expected_substs) => {
150166
// Lookup the struct ctor def id

branches/incoming/src/libsyntax/ast_util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ pub fn stmt_id(s: &stmt) -> node_id {
4141
}
4242
}
4343
44-
pub fn variant_def_ids(d: def) -> (def_id, def_id) {
44+
pub fn variant_def_ids(d: def) -> Option<(def_id, def_id)> {
4545
match d {
4646
def_variant(enum_id, var_id) => {
47-
return (enum_id, var_id);
47+
Some((enum_id, var_id))
4848
}
49-
_ => fail!(~"non-variant in variant_def_ids")
49+
_ => None
5050
}
5151
}
5252
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
struct S(Either<uint, uint>);
12+
13+
fn main() {
14+
match S(Left(5)) {
15+
Right(_) => {} //~ ERROR mismatched types: expected `S` but found `core::either::Either
16+
_ => {}
17+
}
18+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
struct S(Either<uint, uint>);
12+
13+
fn main() {
14+
match *S(Left(5)) {
15+
S(_) => {} //~ ERROR mismatched types: expected `core::either::Either<uint,uint>` but found a structure pattern
16+
}
17+
}

0 commit comments

Comments
 (0)