Skip to content

Commit 38be3a3

Browse files
committed
---
yaml --- r: 77615 b: refs/heads/master c: 6a05aa6 h: refs/heads/master i: 77613: c5e893b 77611: 1e05725 77607: e063156 77599: 55c4793 v: v3
1 parent d1e36e0 commit 38be3a3

File tree

13 files changed

+88
-262
lines changed

13 files changed

+88
-262
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: dad2ccc9b3b27d3f438eeea53b771cc85f6dfa32
2+
refs/heads/master: 6a05aa6a203189658d0d63ceab91bdc88734e83b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 60fba4d7d677ec098e6a43014132fe99f7547363
55
refs/heads/try: ebfe63cd1c0b5d23f7ea60c69b4fde2e30cfd42a

trunk/.gitattributes

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,3 @@ src/rt/msvc/* -whitespace
88
src/rt/vg/* -whitespace
99
src/rt/linenoise/* -whitespace
1010
src/rt/jemalloc/**/* -whitespace
11-
src/rt/jemalloc/include/jemalloc/jemalloc.h.in text eol=lf
12-
src/rt/jemalloc/include/jemalloc/jemalloc_defs.h.in text eol=lf
13-
src/rt/jemalloc/include/jemalloc/internal/jemalloc_internal.h.in text eol=lf

trunk/doc/tutorial.md

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,7 +1864,7 @@ so you could not apply `head` to a type
18641864
that does not implement `Clone`.
18651865

18661866
While most traits can be defined and implemented by user code,
1867-
three traits are automatically derived and implemented
1867+
two traits are automatically derived and implemented
18681868
for all applicable types by the compiler,
18691869
and may not be overridden:
18701870

@@ -1877,12 +1877,6 @@ These are types that do not contain anything intrinsically mutable.
18771877
Intrinsically mutable values include `@mut`
18781878
and `Cell` in the standard library.
18791879

1880-
* `'static` - Non-borrowed types.
1881-
These are types that do not contain any data whose lifetime is bound to
1882-
a particular stack frame. These are types that do not contain any
1883-
borrowed pointers, or types where the only contained borrowed pointers
1884-
have the `'static` lifetime.
1885-
18861880
> ***Note:*** These two traits were referred to as 'kinds' in earlier
18871881
> iterations of the language, and often still are.
18881882
@@ -2141,30 +2135,6 @@ select the method to call at runtime.
21412135

21422136
This usage of traits is similar to Java interfaces.
21432137

2144-
By default, each of the three storage classes for traits enforce a
2145-
particular set of built-in kinds that their contents must fulfill in
2146-
order to be packaged up in a trait object of that storage class.
2147-
2148-
* The contents of owned traits (`~Trait`) must fulfill the `Send` bound.
2149-
* The contents of managed traits (`@Trait`) must fulfill the `'static` bound.
2150-
* The contents of borrowed traits (`&Trait`) are not constrained by any bound.
2151-
2152-
Consequently, the trait objects themselves automatically fulfill their
2153-
respective kind bounds. However, this default behavior can be overridden by
2154-
specifying a list of bounds on the trait type, for example, by writing `~Trait:`
2155-
(which indicates that the contents of the owned trait need not fulfill any
2156-
bounds), or by writing `~Trait:Send+Freeze`, which indicates that in addition
2157-
to fulfilling `Send`, contents must also fulfill `Freeze`, and as a consequence,
2158-
the trait itself fulfills `Freeze`.
2159-
2160-
* `~Trait:Send` is equivalent to `~Trait`.
2161-
* `@Trait:'static` is equivalent to `@Trait`.
2162-
* `&Trait:` is equivalent to `&Trait`.
2163-
2164-
Builtin kind bounds can also be specified on closure types in the same way (for
2165-
example, by writing `fn:Freeze()`), and the default behaviours are the same as
2166-
for traits of the same storage class.
2167-
21682138
## Trait inheritance
21692139

21702140
We can write a trait declaration that _inherits_ from other traits, called _supertraits_.

trunk/src/libextra/json.rs

Lines changed: 64 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -459,24 +459,26 @@ impl<E: serialize::Encoder> serialize::Encodable<E> for Json {
459459
}
460460
}
461461

462-
impl Json{
463-
/// Encodes a json value into a io::writer. Uses a single line.
464-
pub fn to_writer(&self, wr: @io::Writer) {
465-
let mut encoder = Encoder(wr);
466-
self.encode(&mut encoder)
467-
}
462+
/// Encodes a json value into a io::writer
463+
pub fn to_writer(wr: @io::Writer, json: &Json) {
464+
let mut encoder = Encoder(wr);
465+
json.encode(&mut encoder)
466+
}
468467

469-
/// Encodes a json value into a io::writer.
470-
/// Pretty-prints in a more readable format.
471-
pub fn to_pretty_writer(&self, wr: @io::Writer) {
472-
let mut encoder = PrettyEncoder(wr);
473-
self.encode(&mut encoder)
474-
}
468+
/// Encodes a json value into a string
469+
pub fn to_str(json: &Json) -> ~str {
470+
io::with_str_writer(|wr| to_writer(wr, json))
471+
}
475472

476-
/// Encodes a json value into a string
477-
pub fn to_pretty_str(&self) -> ~str {
478-
io::with_str_writer(|wr| self.to_pretty_writer(wr))
479-
}
473+
/// Encodes a json value into a io::writer
474+
pub fn to_pretty_writer(wr: @io::Writer, json: &Json) {
475+
let mut encoder = PrettyEncoder(wr);
476+
json.encode(&mut encoder)
477+
}
478+
479+
/// Encodes a json value into a string
480+
pub fn to_pretty_str(json: &Json) -> ~str {
481+
io::with_str_writer(|wr| to_pretty_writer(wr, json))
480482
}
481483

482484
pub struct Parser<T> {
@@ -1305,10 +1307,7 @@ impl<A:ToJson> ToJson for Option<A> {
13051307
}
13061308

13071309
impl to_str::ToStr for Json {
1308-
/// Encodes a json value into a string
1309-
fn to_str(&self) -> ~str {
1310-
io::with_str_writer(|wr| self.to_writer(wr))
1311-
}
1310+
fn to_str(&self) -> ~str { to_str(self) }
13121311
}
13131312

13141313
impl to_str::ToStr for Error {
@@ -1359,67 +1358,69 @@ mod tests {
13591358

13601359
#[test]
13611360
fn test_write_null() {
1362-
assert_eq!(Null.to_str(), ~"null");
1363-
assert_eq!(Null.to_pretty_str(), ~"null");
1361+
assert_eq!(to_str(&Null), ~"null");
1362+
assert_eq!(to_pretty_str(&Null), ~"null");
13641363
}
13651364
13661365
13671366
#[test]
13681367
fn test_write_number() {
1369-
assert_eq!(Number(3f).to_str(), ~"3");
1370-
assert_eq!(Number(3f).to_pretty_str(), ~"3");
1368+
assert_eq!(to_str(&Number(3f)), ~"3");
1369+
assert_eq!(to_pretty_str(&Number(3f)), ~"3");
13711370
1372-
assert_eq!(Number(3.1f).to_str(), ~"3.1");
1373-
assert_eq!(Number(3.1f).to_pretty_str(), ~"3.1");
1371+
assert_eq!(to_str(&Number(3.1f)), ~"3.1");
1372+
assert_eq!(to_pretty_str(&Number(3.1f)), ~"3.1");
13741373
1375-
assert_eq!(Number(-1.5f).to_str(), ~"-1.5");
1376-
assert_eq!(Number(-1.5f).to_pretty_str(), ~"-1.5");
1374+
assert_eq!(to_str(&Number(-1.5f)), ~"-1.5");
1375+
assert_eq!(to_pretty_str(&Number(-1.5f)), ~"-1.5");
13771376
1378-
assert_eq!(Number(0.5f).to_str(), ~"0.5");
1379-
assert_eq!(Number(0.5f).to_pretty_str(), ~"0.5");
1377+
assert_eq!(to_str(&Number(0.5f)), ~"0.5");
1378+
assert_eq!(to_pretty_str(&Number(0.5f)), ~"0.5");
13801379
}
13811380
13821381
#[test]
13831382
fn test_write_str() {
1384-
assert_eq!(String(~"").to_str(), ~"\"\"");
1385-
assert_eq!(String(~"").to_pretty_str(), ~"\"\"");
1383+
assert_eq!(to_str(&String(~"")), ~"\"\"");
1384+
assert_eq!(to_pretty_str(&String(~"")), ~"\"\"");
13861385

1387-
assert_eq!(String(~"foo").to_str(), ~"\"foo\"");
1388-
assert_eq!(String(~"foo").to_pretty_str(), ~"\"foo\"");
1386+
assert_eq!(to_str(&String(~"foo")), ~"\"foo\"");
1387+
assert_eq!(to_pretty_str(&String(~"foo")), ~"\"foo\"");
13891388
}
13901389

13911390
#[test]
13921391
fn test_write_bool() {
1393-
assert_eq!(Boolean(true).to_str(), ~"true");
1394-
assert_eq!(Boolean(true).to_pretty_str(), ~"true");
1392+
assert_eq!(to_str(&Boolean(true)), ~"true");
1393+
assert_eq!(to_pretty_str(&Boolean(true)), ~"true");
13951394
1396-
assert_eq!(Boolean(false).to_str(), ~"false");
1397-
assert_eq!(Boolean(false).to_pretty_str(), ~"false");
1395+
assert_eq!(to_str(&Boolean(false)), ~"false");
1396+
assert_eq!(to_pretty_str(&Boolean(false)), ~"false");
13981397
}
13991398
14001399
#[test]
14011400
fn test_write_list() {
1402-
assert_eq!(List(~[]).to_str(), ~"[]");
1403-
assert_eq!(List(~[]).to_pretty_str(), ~"[]");
1401+
assert_eq!(to_str(&List(~[])), ~"[]");
1402+
assert_eq!(to_pretty_str(&List(~[])), ~"[]");
14041403
1405-
assert_eq!(List(~[Boolean(true)]).to_str(), ~"[true]");
1404+
assert_eq!(to_str(&List(~[Boolean(true)])), ~"[true]");
14061405
assert_eq!(
1407-
List(~[Boolean(true)]).to_pretty_str(),
1406+
to_pretty_str(&List(~[Boolean(true)])),
14081407
~"\
14091408
[\n \
14101409
true\n\
14111410
]"
14121411
);
14131412

1414-
let longTestList = List(~[
1413+
assert_eq!(to_str(&List(~[
14151414
Boolean(false),
14161415
Null,
1417-
List(~[String(~"foo\nbar"), Number(3.5f)])]);
1418-
1419-
assert_eq!(longTestList.to_str(),
1420-
~"[false,null,[\"foo\\nbar\",3.5]]");
1416+
List(~[String(~"foo\nbar"), Number(3.5f)])
1417+
])), ~"[false,null,[\"foo\\nbar\",3.5]]");
14211418
assert_eq!(
1422-
longTestList.to_pretty_str(),
1419+
to_pretty_str(&List(~[
1420+
Boolean(false),
1421+
Null,
1422+
List(~[String(~"foo\nbar"), Number(3.5f)])
1423+
])),
14231424
~"\
14241425
[\n \
14251426
false,\n \
@@ -1434,30 +1435,28 @@ mod tests {
14341435

14351436
#[test]
14361437
fn test_write_object() {
1437-
assert_eq!(mk_object([]).to_str(), ~"{}");
1438-
assert_eq!(mk_object([]).to_pretty_str(), ~"{}");
1438+
assert_eq!(to_str(&mk_object([])), ~"{}");
1439+
assert_eq!(to_pretty_str(&mk_object([])), ~"{}");
14391440
14401441
assert_eq!(
1441-
mk_object([(~"a", Boolean(true))]).to_str(),
1442+
to_str(&mk_object([(~"a", Boolean(true))])),
14421443
~"{\"a\":true}"
14431444
);
14441445
assert_eq!(
1445-
mk_object([(~"a", Boolean(true))]).to_pretty_str(),
1446+
to_pretty_str(&mk_object([(~"a", Boolean(true))])),
14461447
~"\
14471448
{\n \
14481449
\"a\": true\n\
14491450
}"
14501451
);
14511452

1452-
let complexObj = mk_object([
1453+
assert_eq!(
1454+
to_str(&mk_object([
14531455
(~"b", List(~[
14541456
mk_object([(~"c", String(~"\x0c\r"))]),
14551457
mk_object([(~"d", String(~""))])
14561458
]))
1457-
]);
1458-
1459-
assert_eq!(
1460-
complexObj.to_str(),
1459+
])),
14611460
~"{\
14621461
\"b\":[\
14631462
{\"c\":\"\\f\\r\"},\
@@ -1466,7 +1465,12 @@ mod tests {
14661465
}"
14671466
);
14681467
assert_eq!(
1469-
complexObj.to_pretty_str(),
1468+
to_pretty_str(&mk_object([
1469+
(~"b", List(~[
1470+
mk_object([(~"c", String(~"\x0c\r"))]),
1471+
mk_object([(~"d", String(~""))])
1472+
]))
1473+
])),
14701474
~"\
14711475
{\n \
14721476
\"b\": [\n \
@@ -1490,8 +1494,8 @@ mod tests {
14901494
14911495
// We can't compare the strings directly because the object fields be
14921496
// printed in a different order.
1493-
assert_eq!(a.clone(), from_str(a.to_str()).unwrap());
1494-
assert_eq!(a.clone(), from_str(a.to_pretty_str()).unwrap());
1497+
assert_eq!(a.clone(), from_str(to_str(&a)).unwrap());
1498+
assert_eq!(a.clone(), from_str(to_pretty_str(&a)).unwrap());
14951499
}
14961500
14971501
#[test]

trunk/src/libextra/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ impl MetricMap {
907907
/// Write MetricDiff to a file.
908908
pub fn save(&self, p: &Path) {
909909
let f = io::file_writer(p, [io::Create, io::Truncate]).unwrap();
910-
self.to_json().to_pretty_writer(f);
910+
json::to_pretty_writer(f, &self.to_json());
911911
}
912912

913913
/// Compare against another MetricMap. Optionally compare all

trunk/src/librustc/back/arm.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use driver::session::sess_os_to_meta_os;
1313
use driver::session;
1414
use metadata::loader::meta_section_name;
1515

16-
pub fn get_target_strs(target_os: session::os) -> target_strs::t {
16+
pub fn get_target_strs(target_triple: ~str, target_os: session::os) -> target_strs::t {
1717
return target_strs::t {
1818
module_asm: ~"",
1919

@@ -61,13 +61,7 @@ pub fn get_target_strs(target_os: session::os) -> target_strs::t {
6161
}
6262
},
6363

64-
target_triple: match target_os {
65-
session::os_macos => ~"arm-apple-darwin",
66-
session::os_win32 => ~"arm-pc-mingw32",
67-
session::os_linux => ~"arm-unknown-linux-gnueabihf",
68-
session::os_android => ~"arm-linux-androideabi",
69-
session::os_freebsd => ~"arm-unknown-freebsd"
70-
},
64+
target_triple: target_triple,
7165

7266
cc_args: ~[~"-marm"]
7367
};

trunk/src/librustc/back/mips.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use driver::session;
1313
use driver::session::sess_os_to_meta_os;
1414
use metadata::loader::meta_section_name;
1515

16-
pub fn get_target_strs(target_os: session::os) -> target_strs::t {
16+
pub fn get_target_strs(target_triple: ~str, target_os: session::os) -> target_strs::t {
1717
return target_strs::t {
1818
module_asm: ~"",
1919

@@ -61,13 +61,7 @@ pub fn get_target_strs(target_os: session::os) -> target_strs::t {
6161
}
6262
},
6363

64-
target_triple: match target_os {
65-
session::os_macos => ~"mips-apple-darwin",
66-
session::os_win32 => ~"mips-pc-mingw32",
67-
session::os_linux => ~"mips-unknown-linux-gnu",
68-
session::os_android => ~"mips-unknown-android-gnu",
69-
session::os_freebsd => ~"mips-unknown-freebsd"
70-
},
64+
target_triple: target_triple,
7165

7266
cc_args: ~[]
7367
};

trunk/src/librustc/back/x86.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use driver::session::sess_os_to_meta_os;
1414
use driver::session;
1515
use metadata::loader::meta_section_name;
1616

17-
pub fn get_target_strs(target_os: session::os) -> target_strs::t {
17+
pub fn get_target_strs(target_triple: ~str, target_os: session::os) -> target_strs::t {
1818
return target_strs::t {
1919
module_asm: ~"",
2020

@@ -44,13 +44,7 @@ pub fn get_target_strs(target_os: session::os) -> target_strs::t {
4444
}
4545
},
4646

47-
target_triple: match target_os {
48-
session::os_macos => ~"i686-apple-darwin",
49-
session::os_win32 => ~"i686-pc-mingw32",
50-
session::os_linux => ~"i686-unknown-linux-gnu",
51-
session::os_android => ~"i686-unknown-android-gnu",
52-
session::os_freebsd => ~"i686-unknown-freebsd"
53-
},
47+
target_triple: target_triple,
5448

5549
cc_args: ~[~"-m32"]
5650
};

trunk/src/librustc/back/x86_64.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use driver::session::sess_os_to_meta_os;
1414
use driver::session;
1515
use metadata::loader::meta_section_name;
1616

17-
pub fn get_target_strs(target_os: session::os) -> target_strs::t {
17+
pub fn get_target_strs(target_triple: ~str, target_os: session::os) -> target_strs::t {
1818
return target_strs::t {
1919
module_asm: ~"",
2020

@@ -52,13 +52,7 @@ pub fn get_target_strs(target_os: session::os) -> target_strs::t {
5252
}
5353
},
5454

55-
target_triple: match target_os {
56-
session::os_macos => ~"x86_64-apple-darwin",
57-
session::os_win32 => ~"x86_64-pc-mingw32",
58-
session::os_linux => ~"x86_64-unknown-linux-gnu",
59-
session::os_android => ~"x86_64-unknown-android-gnu",
60-
session::os_freebsd => ~"x86_64-unknown-freebsd",
61-
},
55+
target_triple: target_triple,
6256

6357
cc_args: ~[~"-m64"]
6458
};

0 commit comments

Comments
 (0)