Skip to content

Commit 8a63c9c

Browse files
committed
---
yaml --- r: 152061 b: refs/heads/try2 c: c7fe4ff h: refs/heads/master i: 152059: 76791fb v: v3
1 parent 50fc90a commit 8a63c9c

File tree

22 files changed

+80
-361
lines changed

22 files changed

+80
-361
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 30bf73fd789ad1414284f59b005e85304ff963ad
8+
refs/heads/try2: c7fe4ffe3d8315dfe98bee6d040b5a0381daab91
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ let ys = xs;
11061106
11071107
xs = Nil;
11081108
1109-
// `xs` can't be used again
1109+
// `xs` can be used again
11101110
~~~
11111111

11121112
A destructor call will only occur for a variable that has not been moved from,

branches/try2/src/libcollections/hashmap.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,20 +2003,6 @@ mod test_map {
20032003
assert_eq!(m1, m2);
20042004
}
20052005

2006-
#[test]
2007-
fn test_show() {
2008-
let mut map: HashMap<int, int> = HashMap::new();
2009-
let empty: HashMap<int, int> = HashMap::new();
2010-
2011-
map.insert(1, 2);
2012-
map.insert(3, 4);
2013-
2014-
let map_str = format!("{}", map);
2015-
2016-
assert!(map_str == "{1: 2, 3: 4}".to_owned() || map_str == "{3: 4, 1: 2}".to_owned());
2017-
assert_eq!(format!("{}", empty), "{}".to_owned());
2018-
}
2019-
20202006
#[test]
20212007
fn test_expand() {
20222008
let mut m = HashMap::new();

branches/try2/src/libcollections/treemap.rs

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
//! trees. The only requirement for the types is that the key implements
1313
//! `TotalOrd`.
1414
15-
use std::cmp::Ordering;
16-
use std::fmt::Show;
17-
use std::fmt;
18-
use std::iter::Peekable;
1915
use std::iter;
16+
use std::iter::{Peekable};
17+
use std::cmp::Ordering;
2018
use std::mem::{replace, swap};
2119
use std::ptr;
2220

@@ -69,19 +67,6 @@ impl<K: Ord + TotalOrd, V: Ord> Ord for TreeMap<K, V> {
6967
fn lt(&self, other: &TreeMap<K, V>) -> bool { lt(self, other) }
7068
}
7169

72-
impl<K: TotalOrd + Show, V: Show> Show for TreeMap<K, V> {
73-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
74-
try!(write!(f, r"\{"));
75-
76-
for (i, (k, v)) in self.iter().enumerate() {
77-
if i != 0 { try!(write!(f, ", ")); }
78-
try!(write!(f, "{}: {}", *k, *v));
79-
}
80-
81-
write!(f, r"\}")
82-
}
83-
}
84-
8570
impl<K: TotalOrd, V> Container for TreeMap<K, V> {
8671
fn len(&self) -> uint { self.length }
8772
}
@@ -562,19 +547,6 @@ impl<T: Ord + TotalOrd> Ord for TreeSet<T> {
562547
fn lt(&self, other: &TreeSet<T>) -> bool { self.map < other.map }
563548
}
564549

565-
impl<T: TotalOrd + Show> Show for TreeSet<T> {
566-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
567-
try!(write!(f, r"\{"));
568-
569-
for (i, x) in self.iter().enumerate() {
570-
if i != 0 { try!(write!(f, ", ")); }
571-
try!(write!(f, "{}", *x));
572-
}
573-
574-
write!(f, r"\}")
575-
}
576-
}
577-
578550
impl<T: TotalOrd> Container for TreeSet<T> {
579551
#[inline]
580552
fn len(&self) -> uint { self.map.len() }
@@ -1356,20 +1328,6 @@ mod test_treemap {
13561328
assert!(a < b && a <= b);
13571329
}
13581330

1359-
#[test]
1360-
fn test_show() {
1361-
let mut map: TreeMap<int, int> = TreeMap::new();
1362-
let empty: TreeMap<int, int> = TreeMap::new();
1363-
1364-
map.insert(1, 2);
1365-
map.insert(3, 4);
1366-
1367-
let map_str = format!("{}", map);
1368-
1369-
assert!(map_str == "{1: 2, 3: 4}".to_owned());
1370-
assert_eq!(format!("{}", empty), "{}".to_owned());
1371-
}
1372-
13731331
#[test]
13741332
fn test_lazy_iterator() {
13751333
let mut m = TreeMap::new();
@@ -1765,18 +1723,4 @@ mod test_set {
17651723
assert!(set.contains(x));
17661724
}
17671725
}
1768-
1769-
#[test]
1770-
fn test_show() {
1771-
let mut set: TreeSet<int> = TreeSet::new();
1772-
let empty: TreeSet<int> = TreeSet::new();
1773-
1774-
set.insert(1);
1775-
set.insert(2);
1776-
1777-
let set_str = format!("{}", set);
1778-
1779-
assert!(set_str == "{1, 2}".to_owned());
1780-
assert_eq!(format!("{}", empty), "{}".to_owned());
1781-
}
17821726
}

branches/try2/src/libgetopts/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
671671
hasarg: hasarg,
672672
..} = (*optref).clone();
673673

674-
let mut row = String::from_owned_str(" ".repeat(4));
674+
let mut row = " ".repeat(4);
675675

676676
// short option
677677
match short_name.len() {

branches/try2/src/librustc/middle/check_match.rs

Lines changed: 22 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -863,18 +863,9 @@ fn default(cx: &MatchCheckCtxt, r: &[@Pat]) -> Option<Vec<@Pat> > {
863863

864864
fn check_local(cx: &mut MatchCheckCtxt, loc: &Local) {
865865
visit::walk_local(cx, loc, ());
866-
867-
let name = match loc.source {
868-
LocalLet => "local",
869-
LocalFor => "`for` loop"
870-
};
871-
872-
let mut spans = vec![];
873-
find_refutable(cx, loc.pat, &mut spans);
874-
875-
for span in spans.iter() {
876-
cx.tcx.sess.span_err(*span,
877-
format!("refutable pattern in {} binding", name).as_slice());
866+
if is_refutable(cx, loc.pat) {
867+
cx.tcx.sess.span_err(loc.pat.span,
868+
"refutable pattern in local binding");
878869
}
879870

880871
// Check legality of move bindings.
@@ -888,65 +879,53 @@ fn check_fn(cx: &mut MatchCheckCtxt,
888879
sp: Span) {
889880
visit::walk_fn(cx, kind, decl, body, sp, ());
890881
for input in decl.inputs.iter() {
891-
let mut spans = vec![];
892-
find_refutable(cx, input.pat, &mut spans);
893-
894-
for span in spans.iter() {
895-
cx.tcx.sess.span_err(*span,
882+
if is_refutable(cx, input.pat) {
883+
cx.tcx.sess.span_err(input.pat.span,
896884
"refutable pattern in function argument");
897885
}
898886
}
899887
}
900888

901-
fn find_refutable(cx: &MatchCheckCtxt, pat: &Pat, spans: &mut Vec<Span>) {
902-
macro_rules! this_pattern {
903-
() => {
904-
{
905-
spans.push(pat.span);
906-
return
907-
}
908-
}
909-
}
889+
fn is_refutable(cx: &MatchCheckCtxt, pat: &Pat) -> bool {
910890
let opt_def = cx.tcx.def_map.borrow().find_copy(&pat.id);
911891
match opt_def {
912892
Some(DefVariant(enum_id, _, _)) => {
913893
if ty::enum_variants(cx.tcx, enum_id).len() != 1u {
914-
this_pattern!()
894+
return true;
915895
}
916896
}
917-
Some(DefStatic(..)) => this_pattern!(),
897+
Some(DefStatic(..)) => return true,
918898
_ => ()
919899
}
920900

921901
match pat.node {
922902
PatUniq(sub) | PatRegion(sub) | PatIdent(_, _, Some(sub)) => {
923-
find_refutable(cx, sub, spans)
903+
is_refutable(cx, sub)
924904
}
925-
PatWild | PatWildMulti | PatIdent(_, _, None) => {}
905+
PatWild | PatWildMulti | PatIdent(_, _, None) => { false }
926906
PatLit(lit) => {
927907
match lit.node {
928908
ExprLit(lit) => {
929909
match lit.node {
930-
LitNil => {} // `()`
931-
_ => this_pattern!(),
910+
LitNil => false, // `()`
911+
_ => true,
932912
}
933913
}
934-
_ => this_pattern!(),
914+
_ => true,
935915
}
936916
}
937-
PatRange(_, _) => { this_pattern!() }
917+
PatRange(_, _) => { true }
938918
PatStruct(_, ref fields, _) => {
939-
for f in fields.iter() {
940-
find_refutable(cx, f.pat, spans);
941-
}
919+
fields.iter().any(|f| is_refutable(cx, f.pat))
942920
}
943-
PatTup(ref elts) | PatEnum(_, Some(ref elts))=> {
944-
for elt in elts.iter() {
945-
find_refutable(cx, *elt, spans)
946-
}
921+
PatTup(ref elts) => {
922+
elts.iter().any(|elt| is_refutable(cx, *elt))
923+
}
924+
PatEnum(_, Some(ref args)) => {
925+
args.iter().any(|a| is_refutable(cx, *a))
947926
}
948-
PatEnum(_,_) => {}
949-
PatVec(..) => { this_pattern!() }
927+
PatEnum(_,_) => { false }
928+
PatVec(..) => { true }
950929
}
951930
}
952931

branches/try2/src/librustc/middle/privacy.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -297,23 +297,6 @@ impl<'a> Visitor<()> for EmbargoVisitor<'a> {
297297
}
298298
}
299299

300-
ast::ItemTy(ref ty, _) if public_first => {
301-
match ty.node {
302-
ast::TyPath(_, _, id) => {
303-
match self.tcx.def_map.borrow().get_copy(&id) {
304-
ast::DefPrimTy(..) => {},
305-
def => {
306-
let did = def_id_of_def(def);
307-
if is_local(did) {
308-
self.exported_items.insert(did.node);
309-
}
310-
}
311-
}
312-
}
313-
_ => {}
314-
}
315-
}
316-
317300
_ => {}
318301
}
319302

branches/try2/src/libserialize/json.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,6 +1434,36 @@ impl<T: Iterator<char>> Parser<T> {
14341434
},
14351435
},
14361436
_ => return self.error(InvalidEscape),
1437+
/*=======
1438+
'u' => {
1439+
// Parse \u1234.
1440+
let mut i = 0u;
1441+
let mut n = 0u;
1442+
while i < 4u && !self.eof() {
1443+
self.bump();
1444+
n = match self.ch_or_null() {
1445+
c @ '0' .. '9' => n * 16u + (c as uint) - ('0' as uint),
1446+
'a' | 'A' => n * 16u + 10u,
1447+
'b' | 'B' => n * 16u + 11u,
1448+
'c' | 'C' => n * 16u + 12u,
1449+
'd' | 'D' => n * 16u + 13u,
1450+
'e' | 'E' => n * 16u + 14u,
1451+
'f' | 'F' => n * 16u + 15u,
1452+
_ => return self.error(UnrecognizedHex)
1453+
};
1454+
1455+
i += 1u;
1456+
}
1457+
1458+
// Error out if we didn't parse 4 digits.
1459+
if i != 4u {
1460+
return self.error(NotFourDigit);
1461+
}
1462+
1463+
res.push_char(char::from_u32(n as u32).unwrap());
1464+
}
1465+
_ => return self.error(InvalidEscape),
1466+
>>>>>>> Add a streaming parser to serialize::json.*/
14371467
}
14381468
escape = false;
14391469
} else if self.ch_is('\\') {

branches/try2/src/libstd/str.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,24 @@ Unicode string manipulation (`str` type)
1616
1717
Rust's string type is one of the core primitive types of the language. While
1818
represented by the name `str`, the name `str` is not actually a valid type in
19-
Rust. Each string must also be decorated with a pointer. `String` is used
20-
for an owned string, so there is only one commonly-used `str` type in Rust:
21-
`&str`.
19+
Rust. Each string must also be decorated with its ownership. This means that
20+
there is one common kind of string in Rust:
2221
23-
`&str` is the borrowed string type. This type of string can only be created
24-
from other strings, unless it is a static string (see below). As the word
25-
"borrowed" implies, this type of string is owned elsewhere, and this string
26-
cannot be moved out of.
22+
* `&str` - This is the borrowed string type. This type of string can only be
23+
created from the other kind of string. As the name "borrowed"
24+
implies, this type of string is owned elsewhere, and this string
25+
cannot be moved out of.
2726
28-
As an example, here's some code that uses a string.
27+
As an example, here's the one kind of string.
2928
3029
```rust
3130
fn main() {
3231
let borrowed_string = "This string is borrowed with the 'static lifetime";
3332
}
3433
```
3534
36-
From the example above, you can see that Rust's string literals have the
37-
`'static` lifetime. This is akin to C's concept of a static string.
35+
From the example above, you can see that Rust has 1 different kind of string
36+
literal. The "borrowed literal" is akin to C's concept of a static string.
3837
3938
String literals are allocated statically in the rodata of the
4039
executable/library. The string then has the type `&'static str` meaning that
@@ -510,7 +509,7 @@ pub fn from_utf8_lossy<'a>(v: &'a [u8]) -> MaybeOwned<'a> {
510509
Section: MaybeOwned
511510
*/
512511

513-
/// A `MaybeOwned` is a string that can hold either a `String` or a `&str`.
512+
/// A MaybeOwned is a string that can hold either a String or a &str.
514513
/// This can be useful as an optimization when an allocation is sometimes
515514
/// needed but not always.
516515
pub enum MaybeOwned<'a> {
@@ -520,7 +519,7 @@ pub enum MaybeOwned<'a> {
520519
Owned(String)
521520
}
522521

523-
/// `SendStr` is a specialization of `MaybeOwned` to be sendable
522+
/// SendStr is a specialization of `MaybeOwned` to be sendable
524523
pub type SendStr = MaybeOwned<'static>;
525524

526525
impl<'a> MaybeOwned<'a> {
@@ -911,10 +910,9 @@ impl OwnedStr for String {
911910
}
912911

913912
#[inline]
914-
fn append(self, rhs: &str) -> String {
915-
let mut new_str = String::from_owned_str(self);
916-
new_str.push_str(rhs);
917-
new_str
913+
fn append(mut self, rhs: &str) -> String {
914+
self.push_str(rhs);
915+
self
918916
}
919917
}
920918

branches/try2/src/libstd/string.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ impl String {
6868
}
6969
}
7070

71-
/// Creates a new string buffer from the given owned string, taking care not to copy it.
71+
#[allow(missing_doc)]
72+
#[deprecated = "obsoleted by the removal of ~str"]
7273
#[inline]
7374
pub fn from_owned_str(string: String) -> String {
7475
string

0 commit comments

Comments
 (0)