Skip to content

Commit 5f231be

Browse files
committed
---
yaml --- r: 144372 b: refs/heads/try2 c: 8c25b7f h: refs/heads/master v: v3
1 parent 12305b8 commit 5f231be

File tree

13 files changed

+338
-106
lines changed

13 files changed

+338
-106
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: bbe347cee79df9cb68ee490ba957e515e3da70a1
8+
refs/heads/try2: 8c25b7f0e8c01d3946e7e7e6912e225b30b60f89
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ 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

branches/try2/doc/tutorial.md

Lines changed: 31 additions & 1 deletion
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-
two traits are automatically derived and implemented
1867+
three traits are automatically derived and implemented
18681868
for all applicable types by the compiler,
18691869
and may not be overridden:
18701870

@@ -1877,6 +1877,12 @@ 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+
18801886
> ***Note:*** These two traits were referred to as 'kinds' in earlier
18811887
> iterations of the language, and often still are.
18821888
@@ -2135,6 +2141,30 @@ select the method to call at runtime.
21352141

21362142
This usage of traits is similar to Java interfaces.
21372143

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+
21382168
## Trait inheritance
21392169

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

branches/try2/mk/tests.mk

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,24 @@ TEST_RATCHET_NOISE_PERCENT=10.0
7373

7474
# Whether to ratchet or merely save benchmarks
7575
ifdef CFG_RATCHET_BENCH
76-
CRATE_TEST_BENCH_ARGS=\
76+
CRATE_TEST_EXTRA_ARGS=\
7777
--test $(TEST_BENCH) \
7878
--ratchet-metrics $(call TEST_RATCHET_FILE,$(1),$(2),$(3),$(4)) \
7979
--ratchet-noise-percent $(TEST_RATCHET_NOISE_PERCENT)
8080
else
81-
CRATE_TEST_BENCH_ARGS=\
81+
CRATE_TEST_EXTRA_ARGS=\
8282
--test $(TEST_BENCH) \
8383
--save-metrics $(call TEST_RATCHET_FILE,$(1),$(2),$(3),$(4))
8484
endif
8585

86+
# If we're sharding the testsuite between parallel testers,
87+
# pass this argument along to the compiletest and crate test
88+
# invocations.
89+
ifdef TEST_SHARD
90+
CTEST_TESTARGS += --test-shard=$(TEST_SHARD)
91+
CRATE_TEST_EXTRA_ARGS += --test-shard=$(TEST_SHARD)
92+
endif
93+
8694
define DEF_TARGET_COMMANDS
8795

8896
ifdef CFG_UNIXY_$(1)
@@ -401,7 +409,7 @@ $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
401409
@$$(call E, run: $$<)
402410
$$(Q)$$(call CFG_RUN_TEST_$(2),$$<,$(2),$(3)) $$(TESTARGS) \
403411
--logfile $$(call TEST_LOG_FILE,$(1),$(2),$(3),$(4)) \
404-
$$(call CRATE_TEST_BENCH_ARGS,$(1),$(2),$(3),$(4)) \
412+
$$(call CRATE_TEST_EXTRA_ARGS,$(1),$(2),$(3),$(4)) \
405413
&& touch $$@
406414
endef
407415

@@ -415,7 +423,7 @@ $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
415423
@$(CFG_ADB) shell '(cd $(CFG_ADB_TEST_DIR); LD_LIBRARY_PATH=. \
416424
./$$(notdir $$<) \
417425
--logfile $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log \
418-
$$(call CRATE_TEST_BENCH_ARGS,$(1),$(2),$(3),$(4)))' \
426+
$$(call CRATE_TEST_EXTRA_ARGS,$(1),$(2),$(3),$(4)))' \
419427
> tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
420428
@cat tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
421429
@touch tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).log

branches/try2/src/compiletest/common.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ pub struct config {
6868
// Percent change in metrics to consider noise
6969
ratchet_noise_percent: Option<f64>,
7070

71+
// "Shard" of the testsuite to run: this has the form of
72+
// two numbers (a,b), and causes only those tests with
73+
// positional order equal to a mod b to run.
74+
test_shard: Option<(uint,uint)>,
75+
7176
// A command line to prefix program execution with,
7277
// for running under valgrind
7378
runtool: Option<~str>,

branches/try2/src/compiletest/compiletest.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ pub fn parse_config(args: ~[~str]) -> config {
7575
optopt("", "target", "the target to build for", "TARGET"),
7676
optopt("", "adb-path", "path to the android debugger", "PATH"),
7777
optopt("", "adb-test-dir", "path to tests for the android debugger", "PATH"),
78+
optopt("", "test-shard", "run shard A, of B shards, worth of the testsuite", "A.B"),
7879
optflag("h", "help", "show this message"),
7980
];
8081

@@ -148,6 +149,7 @@ pub fn parse_config(args: ~[~str]) -> config {
148149
~"") { true }
149150
else { false }
150151
} else { false },
152+
test_shard: test::opt_shard(getopts::opt_maybe_str(matches, "test-shard")),
151153
verbose: getopts::opt_present(matches, "verbose")
152154
}
153155
}
@@ -172,6 +174,10 @@ pub fn log_config(config: &config) {
172174
logv(c, fmt!("adb_path: %s", config.adb_path));
173175
logv(c, fmt!("adb_test_dir: %s", config.adb_test_dir));
174176
logv(c, fmt!("adb_device_status: %b", config.adb_device_status));
177+
match config.test_shard {
178+
None => logv(c, ~"test_shard: (all)"),
179+
Some((a,b)) => logv(c, fmt!("test_shard: %u.%u", a, b))
180+
}
175181
logv(c, fmt!("verbose: %b", config.verbose));
176182
logv(c, fmt!("\n"));
177183
}
@@ -234,6 +240,7 @@ pub fn test_opts(config: &config) -> test::TestOpts {
234240
ratchet_metrics: config.ratchet_metrics.clone(),
235241
ratchet_noise_percent: config.ratchet_noise_percent.clone(),
236242
save_metrics: config.save_metrics.clone(),
243+
test_shard: config.test_shard.clone()
237244
}
238245
}
239246

branches/try2/src/libextra/json.rs

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

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-
}
467-
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-
}
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+
}
472468

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-
}
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+
}
478475

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))
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+
}
482480
}
483481

484482
pub struct Parser<T> {
@@ -1307,7 +1305,10 @@ impl<A:ToJson> ToJson for Option<A> {
13071305
}
13081306

13091307
impl to_str::ToStr for Json {
1310-
fn to_str(&self) -> ~str { to_str(self) }
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+
}
13111312
}
13121313

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

13591360
#[test]
13601361
fn test_write_null() {
1361-
assert_eq!(to_str(&Null), ~"null");
1362-
assert_eq!(to_pretty_str(&Null), ~"null");
1362+
assert_eq!(Null.to_str(), ~"null");
1363+
assert_eq!(Null.to_pretty_str(), ~"null");
13631364
}
13641365
13651366
13661367
#[test]
13671368
fn test_write_number() {
1368-
assert_eq!(to_str(&Number(3f)), ~"3");
1369-
assert_eq!(to_pretty_str(&Number(3f)), ~"3");
1369+
assert_eq!(Number(3f).to_str(), ~"3");
1370+
assert_eq!(Number(3f).to_pretty_str(), ~"3");
13701371
1371-
assert_eq!(to_str(&Number(3.1f)), ~"3.1");
1372-
assert_eq!(to_pretty_str(&Number(3.1f)), ~"3.1");
1372+
assert_eq!(Number(3.1f).to_str(), ~"3.1");
1373+
assert_eq!(Number(3.1f).to_pretty_str(), ~"3.1");
13731374
1374-
assert_eq!(to_str(&Number(-1.5f)), ~"-1.5");
1375-
assert_eq!(to_pretty_str(&Number(-1.5f)), ~"-1.5");
1375+
assert_eq!(Number(-1.5f).to_str(), ~"-1.5");
1376+
assert_eq!(Number(-1.5f).to_pretty_str(), ~"-1.5");
13761377
1377-
assert_eq!(to_str(&Number(0.5f)), ~"0.5");
1378-
assert_eq!(to_pretty_str(&Number(0.5f)), ~"0.5");
1378+
assert_eq!(Number(0.5f).to_str(), ~"0.5");
1379+
assert_eq!(Number(0.5f).to_pretty_str(), ~"0.5");
13791380
}
13801381
13811382
#[test]
13821383
fn test_write_str() {
1383-
assert_eq!(to_str(&String(~"")), ~"\"\"");
1384-
assert_eq!(to_pretty_str(&String(~"")), ~"\"\"");
1384+
assert_eq!(String(~"").to_str(), ~"\"\"");
1385+
assert_eq!(String(~"").to_pretty_str(), ~"\"\"");
13851386

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

13901391
#[test]
13911392
fn test_write_bool() {
1392-
assert_eq!(to_str(&Boolean(true)), ~"true");
1393-
assert_eq!(to_pretty_str(&Boolean(true)), ~"true");
1393+
assert_eq!(Boolean(true).to_str(), ~"true");
1394+
assert_eq!(Boolean(true).to_pretty_str(), ~"true");
13941395
1395-
assert_eq!(to_str(&Boolean(false)), ~"false");
1396-
assert_eq!(to_pretty_str(&Boolean(false)), ~"false");
1396+
assert_eq!(Boolean(false).to_str(), ~"false");
1397+
assert_eq!(Boolean(false).to_pretty_str(), ~"false");
13971398
}
13981399
13991400
#[test]
14001401
fn test_write_list() {
1401-
assert_eq!(to_str(&List(~[])), ~"[]");
1402-
assert_eq!(to_pretty_str(&List(~[])), ~"[]");
1402+
assert_eq!(List(~[]).to_str(), ~"[]");
1403+
assert_eq!(List(~[]).to_pretty_str(), ~"[]");
14031404
1404-
assert_eq!(to_str(&List(~[Boolean(true)])), ~"[true]");
1405+
assert_eq!(List(~[Boolean(true)]).to_str(), ~"[true]");
14051406
assert_eq!(
1406-
to_pretty_str(&List(~[Boolean(true)])),
1407+
List(~[Boolean(true)]).to_pretty_str(),
14071408
~"\
14081409
[\n \
14091410
true\n\
14101411
]"
14111412
);
14121413

1413-
assert_eq!(to_str(&List(~[
1414+
let longTestList = List(~[
14141415
Boolean(false),
14151416
Null,
1416-
List(~[String(~"foo\nbar"), Number(3.5f)])
1417-
])), ~"[false,null,[\"foo\\nbar\",3.5]]");
1417+
List(~[String(~"foo\nbar"), Number(3.5f)])]);
1418+
1419+
assert_eq!(longTestList.to_str(),
1420+
~"[false,null,[\"foo\\nbar\",3.5]]");
14181421
assert_eq!(
1419-
to_pretty_str(&List(~[
1420-
Boolean(false),
1421-
Null,
1422-
List(~[String(~"foo\nbar"), Number(3.5f)])
1423-
])),
1422+
longTestList.to_pretty_str(),
14241423
~"\
14251424
[\n \
14261425
false,\n \
@@ -1435,28 +1434,30 @@ mod tests {
14351434

14361435
#[test]
14371436
fn test_write_object() {
1438-
assert_eq!(to_str(&mk_object([])), ~"{}");
1439-
assert_eq!(to_pretty_str(&mk_object([])), ~"{}");
1437+
assert_eq!(mk_object([]).to_str(), ~"{}");
1438+
assert_eq!(mk_object([]).to_pretty_str(), ~"{}");
14401439
14411440
assert_eq!(
1442-
to_str(&mk_object([(~"a", Boolean(true))])),
1441+
mk_object([(~"a", Boolean(true))]).to_str(),
14431442
~"{\"a\":true}"
14441443
);
14451444
assert_eq!(
1446-
to_pretty_str(&mk_object([(~"a", Boolean(true))])),
1445+
mk_object([(~"a", Boolean(true))]).to_pretty_str(),
14471446
~"\
14481447
{\n \
14491448
\"a\": true\n\
14501449
}"
14511450
);
14521451

1453-
assert_eq!(
1454-
to_str(&mk_object([
1452+
let complexObj = mk_object([
14551453
(~"b", List(~[
14561454
mk_object([(~"c", String(~"\x0c\r"))]),
14571455
mk_object([(~"d", String(~""))])
14581456
]))
1459-
])),
1457+
]);
1458+
1459+
assert_eq!(
1460+
complexObj.to_str(),
14601461
~"{\
14611462
\"b\":[\
14621463
{\"c\":\"\\f\\r\"},\
@@ -1465,12 +1466,7 @@ mod tests {
14651466
}"
14661467
);
14671468
assert_eq!(
1468-
to_pretty_str(&mk_object([
1469-
(~"b", List(~[
1470-
mk_object([(~"c", String(~"\x0c\r"))]),
1471-
mk_object([(~"d", String(~""))])
1472-
]))
1473-
])),
1469+
complexObj.to_pretty_str(),
14741470
~"\
14751471
{\n \
14761472
\"b\": [\n \
@@ -1494,8 +1490,8 @@ mod tests {
14941490
14951491
// We can't compare the strings directly because the object fields be
14961492
// printed in a different order.
1497-
assert_eq!(a.clone(), from_str(to_str(&a)).unwrap());
1498-
assert_eq!(a.clone(), from_str(to_pretty_str(&a)).unwrap());
1493+
assert_eq!(a.clone(), from_str(a.to_str()).unwrap());
1494+
assert_eq!(a.clone(), from_str(a.to_pretty_str()).unwrap());
14991495
}
15001496
15011497
#[test]

0 commit comments

Comments
 (0)